View Full Version : IscriptCTRL ??

06 June 2008, 01:51 AM
Interfaces: All script controllers expose the IScriptCtrl Interface since 3ds Max 8. This interface provides all methods to access the controller through MAXScript:

<boolean>SetConstant <value>Which <&fpvalue>Constant
Constant is In parameter Sets a given constant to the specified value.

i didnīt understand it.......someone can help me, please ?

test :

for i = 1 to (selection.count) do
b = selection[i]
P_script = position_script ()
b.controller.position.controller.Available.controller = P_script
b.position.controller[3].controller.script =
"Ppos = $test_obj.pos.controller[2].controller
val = $test.obj.modifiers[1].value
OldPos = [0,0,0]
SetConstant "OldPos" ---------------- HERE MY PROBLEM
at time (F-val)

-- Type error: Call needs function or class, got: "Ppos = $Ten_c1_Pt_lookAt_end.pos.controller.Zero_Pos_XYZ.controller
PrevPos = [0,0,0]
setConstant "

06 June 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.

06 June 2008, 04:53 AM
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[2].controller --create a target variable with a controller
P_script.script = "at time (F-test_obj.modifiers[1].value) Ppos" --set the script
)--end loop

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 June 2008, 05:40 AM
Thanks a lot Bobo !
=D !

CGTalk Moderation
06 June 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.