Notifications
Clear all

[Closed] controlling reactor settings

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

3 Replies

prismatic isn’t a modifier, is it? 😮

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

ohhh excellent, thanx for that very much appreciated ,

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.

… bump …

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