[Closed] how to "assign track" in script controller?
how do i script the equivalent to “assign track” in a script controller?
by hand, i can create a variable (“varTest”) and assign it (via assign track) to a custom attribute spinner on another object…
$Box01.modifiers[#Attribute_Holder].Custom_Attributes.test
… and everything works fine.
however, if i try this via script using addConstant, addTarget, addObject, or addNode – they all error with something along the lines of “Target needs to be object or subAnim, got: 0.0” or
“Unable to convert: 0.0 to type: <node>”
what am i missing?
after much noodling, i’ve found i’m missing a controller on my custom attribute spinner. here’s a test case…
clearListener()
--create a test box and sphere, the box's CA will drive the z position of the sphere
bx = box()
spr = sphere()
--add the script controller to the z axis of the sphere
sprC = s.position.controller[3].controller = float_script()
--create the CA spinner on the box
select bx
modPanel.addModToSelection (EmptyModifier())
Test_Attr = attributes Test_Spinners
(
parameters testparams rollout:Test_Rollout
(
test_spnr type:#float UI:test_spnr default:0
)
rollout Test_Rollout "test" width:160 height:204
(
spinner test_spnr pos:[10, 10] range:[0,100,0] fieldwidth:30
)
)
custAttributes.add (modPanel.getCurrentObject() ) Test_Attr #unique
--add a controller, in this case a bezier_float() to the spinner
b.modifiers[#Attribute_Holder].Test_Spinners.test_spnr.controller = bezier_float()
--assign the new controller as the target for a variable "test" in the script controller
sprC.AddTarget "test" b.modifiers[#Attribute_Holder].Test_Spinners.test_spnr.controller
--add the script to drive the sphere's position based on the spinner value
sprC.script = "test * .5"
the interesting thing is even though i assign this as the target…
$Box01.modifiers[#Attribute_Holder].Test_Spinners.test_spnr.controller
it evaluates in the script controller dialog as…
$Box01.modifiers[#Attribute_Holder].Test_Spinners.‘test_spnr’
if i try to assign the above as the target, it errors out. what is the significance of the ‘test_spnr’ statement?
& why can i assign the track by hand, but have to assign a controller to be able to assign my script?
thanks!
The .addTarget method needs an object or subanim, if you gave it
$Box01.modifiers[#Attribute_Holder].Test_Spinners[1]
it should work, since the [1] is indexing the first subanim in Test_Spinners, which is your test_spnr.