[Closed] Trigger a block controler animation by script
Not a ready made solution, but a quick grab from my messy toolbox. The one function prints out copy/pastable array string that holds all the splines knots data, ehh well their positions at least, forget the bezier stuff
The other one turns the array it into a spline again…
fn printSpline =
(
sp=$
k=1
out="sp_array=#("
while ( k <= (numKnots sp 1)) do
(
in coordsys world (p=getKnotPoint sp 1 k)
out=out+(p[1] as string)+","
out=out+(p[2] as string)+","
out=out+(p[3] as string)+","
k=k+1
)
out=out+")"
print out
)
------------------
fn ArraytoSpline arr =(
local temp = splineShape ()
addNewSpline temp
for j=1 to (arr.count/3) do (
l=(j*3)-2
addKnot temp 1 #corner #line [arr[l+0], arr[l+1] , arr[l+2 ]]
)
close temp 1
updateShape temp
return temp
)
as you see everything is animatable and renderable, and works in real-time update…
Denis-
Very cool, Thanks for the great example. though im still not sure how this can trigger a preset animation like one from a block controller. Im not even sure if the the block controllers are even acessable through script.
Thanks
-Michael
yep or even a point cache just some way to get a canned animation to be triggered
-Michael
The Block Controller is a Global List array, so depending on how your animations are setup yes you can trigger them. For example, if they are all linear P/R/S then all you need to do is ramp the weight from 0-100.
With PointCache I would think you simply set:
obj.point_cache.playbacktype = 1 –Custom Start
obj.point_cache.playbackstart = 50 –Playback start frame, set this equal to your animation range and set to current frame on your proximity test
For loop you would just add the length value of the cache (obj.point_cache.recordEnd-obj.point_cache.recordStart) to the playbackstart every length.
Or something like that. Sorry just thinking out loud while system churns through CAD data.
-Eric
Wow, block controllers. Haven’t heard any one talking about them in a very very long while. Wasn’t there major issues with them that made them useless? I remember trying to use them many times and they always failed me. This of course was back in about Max 3.