PDA

View Full Version : controlling reactor settings


redwatty
02-18-2009, 04:14 PM
Hi I have wrote a little script for my friend, he has several springs and things in his scene and wants to control their parameters all at once. I have wrote the script but it isn't changing the values, any ideas why?


--variables
cvStrengthValue = 100
cvTauValue = 100
--main function
fn changeValue =
(
if $ == undefined then (MessageBox "Please select at least one object" title:"changeValue")
else
(
for i in selection do
(
if i.modifiers.count == 0 then continue
else
(
for j = 1 to i.modifiers.count do
(
if classof i.modifiers[j] == Prismatic then
(
i.modifiers[j].strength = cvStrength
i.modifiers[j].tau = cvTau
--i.modifiers[j].something = cvSomething
--i.modifiers[j].something else = cvSomethingElse
)
)
)
)
)
)
--UI
rollout cvRollout "changeValues"
(
group "Set Values:"
(
spinner cvStrengthSpinner "Strength: " range:[0,200,cvStrengthValue] fieldWidth:50 type:#integer align:#right
spinner cvTauSpinner "Tau: " range:[0,200,cvTauValue] fieldWidth:50 type:#integer align:#right
)
on cvStrengthSpinner changed val do cvStrengthValue = val
on cvTauSpinner changed val do cvTauValue = val
)
rf = newRolloutFloater "ChangeValueMainRollout" 200 200 -- creates a new rollout floater
addRollout cvRollout rf rolledUp:true--adds viewport rollout to new rollout floater

ZeBoxx2
02-18-2009, 04:59 PM
prismatic isn't a modifier, is it? :o

in addition, you're not calling your function anywhere after the spinners are changed; you're only changing the variable values?

lastly, your variable names mismatch; e.g. you define cvStrengthValue, but then in the function you reference cvStrength?

keeping the above in mind, some changes...

--main function
fn changeValue cvStrengthValue cvTauValue =
(
if $ == undefined then (MessageBox "Please select at least one object" title:"changeValue")
else
(
for o in selection where (classOf o == Prismatic) do (
o.strength = cvStrengthValue
o.tau = cvTauValue
)
)
)
--UI
rollout cvRollout "changeValues"
(
group "Set Values:"
(
spinner cvStrengthSpinner "Strength: " range:[0,200,cvStrengthValue] fieldWidth:50 type:#integer align:#right
spinner cvTauSpinner "Tau: " range:[0,200,cvTauValue] fieldWidth:50 type:#integer align:#right
)
fn setValues = (
changeValue cvStrengthSpinner.value cvTauSpinner.value
)
on cvStrengthSpinner changed val do ( setValues() )
on cvTauSpinner changed val do ( setValues() )
)
rf = newRolloutFloater "ChangeValueMainRollout" 200 200 -- creates a new rollout floater
addRollout cvRollout rf rolledUp:true--adds viewport rollout to new rollout floater

redwatty
02-19-2009, 12:12 AM
ohhh excellent, thanx for that very much appreciated :beer: :cool: ,

I'm expanding the script to also support CarWheel and also wanted to support point-point, but how do you refer to point-point as I can't find it in the max help files.

redwatty
03-03-2009, 05:57 PM
... bump ...

sorry, I don't script too much, am quite new to it.

CGTalk Moderation
03-03-2009, 05:57 PM
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.