[Closed] spring controller On/Off
To whom it may concern,
Hi.
I am working on the movie right now.
I have a question to ask about a scene.
When I load the max file, I search the objects that are applied with the spring controller.
If I find the objects with the spring controller, what will be the script to change that
objects’ iteration value to 0(zero)?
I am doing this because the speed is going slow when I worked the objects with the spring controller.
So I thought that if I put the iteration value to 0(zero), then that will be functioned as I
turn off the spring controller on the objects.
Do you have any other suggestion to turn on/off the spring controller?
Or do you have any other script for that?
Please advise me.
I look forward to hearing from you soon.
Thanks.
Turning the iterations to 0 the X,Y,Z to 0 or if the spring is in a list turning the weight of the list to 0 all will stop the spring controller from evaluating.
Not sure if this is the best way but this should get you started,
make a selection set of all your spring controlled objects so you can easily select them all.
in the listener type:
[size=2]for i in selection do (i.pos.controller.steps = 0)
this sets all the spring controller iterations to Zero. For spring controllers nested in position lists try:
[size=2]for i in selection do (i.pos.controller.Spring.controller.steps = 0)
You could convert this into a button, or add a bit of conditonal code to make an on/off toggle button.
[/size][/size]
I don’t make selection set of all my spring controlled objects.because so many files…
First of all, I want to search all the spring controlled object in the file and then
change the iteration value of the objects.
Then how can I make the script for searching the spring controlled objects?
You will need a recursive functions that searchs for spring controllers as they could be any amount of list controllers deep on the position track.
I don’t have time to whip you up one now but I will see what I can do later for you.
Try this out. You could use it to search for any controller by class and then do what ever you want with it.
cons=#()
fn searchCons node conClass=
(
if node!=undefined then
(
if (classOf node)==conClass then
(
append cons node
)
for i = 1 to node.numSubs do
(
searchCons node[i].controller conClass
)
)
)
fn springOnOff steps=
(
cons=#()
for o in objects do
(
searchCons o.pos.controller SpringPositionController
)
for c in cons do
(
c.steps=steps
)
)
/* Test
clearListener()
springOnOff 2
*/
The getClassInstances method is ideal for this:
-- get all instances of the <SpringPositionController>
springCtrlArray = getClassInstances SpringPositionController
-- set the <steps> property for all instances to 2
springCtrlArray.steps = 2
- Martijn
Oh ya right. You know I always forget about that. Thanks for reminding me, I’m so used to writting recursive functions I just go for that each time.