06-05-2008, 02:44 AM
if you need to use the char " inside a string "", you need to put a \ before it.
i.e: "stringValue=\"this is a string\" ".
but dude! that's not enought to make work your script.
The methods provided by this interface are NOT to be used inside the script expression of the controller, but are meant to CREATE variables for the controller, just like you do normally via the Script Controller UI.
So the setConstant() method can be used to set a variable to a constant value by the script that creates the controller. Once you have called it, you can use the constant variable inside the .script string and it will contain the value you assigned to it.
Assuming your objects have Position List controllers, your code could look like
for b in selection do --loop through the selected objects
P_script = position_script () --create a new position script
b.controller.position.controller.Available.controller = P_script --assign to List
P_script.AddConstant "OldPos" [1,2,3] --create a constant variable
P_script.SetConstant "OldPos" [0,0,0] --set the variable to a different value
P_script.AddNode "Test_Obj" $test_obj --create a node variable
P_script.AddTarget "Ppos" $test_obj.pos.controller.controller --create a target variable with a controller
P_script.script = "at time (F-test_obj.modifiers.value) Ppos" --set the script
As you can see, you can add new variables, change their content and use them in the script to access scene data without $ references in the code. This makes the controller A) faster and B) independent on name changes and XRefs, since the nodes and controllers are stored as references in a parameter block and a pointer is used to access them internally. If you rename your object, the variable will remain valid.
I have not used the OldPos variable in the code, but it would be created and set to [0,0,0]. Of course, I don't have your scene so I could not test the rest, but this is the general approach...
06-05-2008, 05:40 AM
Thanks a lot Bobo !
06-05-2008, 05:40 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.