[Closed] spring controller
Hello guys,
First attempt here with maxscript, so if i look totaly newbie, it is the truth
i am trying to create a simple script that toggles spring controller ON and OFF, by setting interations to 0 (off) back to 2 (on)
well i am doing it simply draging the code into a tab i created.
this is the code for the SpringON button:
macroScript Macro7
category:“DragAndDrop”
toolTip:””
(
$.transform.controller.IK_Goal.controller.Position.controller.steps = 2
)
the SpringOFF button is the ssame code, just set steps = 0
but i have a problem, this just works for the selected object individually. i want to select multiple objects which has a spring controller and aplay the script…
Please help me in this one.
Thanks in advance
Well i found the right sintaxe
Just type this and drag to a toolbar to create a button
Spring ON
for o in selection do (o.pos.controller.steps = 2)
Spring OFF
[size=1]for o in selection do[size=2] (o.pos.controller.steps = 0)[/size]
[size=2][/size]
[size=2]Now you can toggle spring controler on and off!
[/size][/size]
Hi André, pretty nice you are learning maxScript, it´s a very powerfull tool :).
May I suggest you another aproach for toggling on/off all the position springs on the scene.
The way you did is good, but if the “position spring” isn´t on the same place in different objects, your script will break.
like on your first example:
“$.transform.controller.IK_Goal.controller.Position .controller.steps = 2”
the PosSpring is inside an IkGoal.
And in here:
“for o in selection do (o.pos.controller.steps = 2)”
[size=2]it´s right on the first controller.
Well. I know 2 ways for doing this, with recursive functions and with with a command called “getClassInstances”
I think with getClassInstances will be easyer for you to understand, actually I don´t get recursive functions too well to be able to explain you
the “getClassInstances” expects a class as a parameter, so if you pass it the “SpringPositionController”, the getClassInstances will create an ARRAY with all the springs on the scene in it. Simple and clean.
heres an example:
xSpringArray = getClassInstances SpringPositionController
now, you just have to set some properties for the array and that´s it.
xSpringArray.Steps = 2 -> all the springs on the scene is on.
xSpringArray.Steps = 0 -> off
Well, thats it, hope it helped you
See Ya
[/size]