[Closed] spinner in scripting
Hi,
I’m new to maxscripting and I want to make a spinner that controls the rotation of an object called “boxrot” .
Making a spinner in rolloutfloater (the GUI part) I can do, but how do I make the spinner work to rotate the boxrot object.
kindly show me the script. (fill the script)
bxrol = newrolloutfloater “My dialog” 200 100
rollout myroll “Box rotate”
(
spinner sp1 “box rotate”
)
addrollout myroll bxrol
Hi rakitha:
Well, I’ll give it a try, but have in mind that one spiner is most likely to control only one of the axes of rotation. I’ll use the Z axis for the example:
bxrol = newrolloutfloater "My dialog" 200 100
rollout myroll "Box rotate"
(
spinner sp1 "box rotate" range:[0,360,0] type:#float scale:1
on sp1 changed val do
(
$boxrot[size=2].rotation.controller.Z_Rotation = val[/size]
[size=2])[/size]
)
addrollout myroll bxrol
This assumes that the object has a Euler_XYZ controller assigned to the rotation.
In this case, you have used the on – changed event to handle what happens when the spinner is updated or changed. The easiest way of accessing this events is to open a new script in the MaxScript section of utilities panel in max, and then select: Edit -> New Rollout.
There you can visualy construct your dialog, and then you can change the right pane to Event Handlers, intead of the Value Tab, to find out which events the control support and what parameters they take. If you click on the name of an specific event you can enter the code directly for the event and Max constructs the syntax properly.
For a rotation control though, I wouldnt do it this way, Ill try to add a custom attribute in an Attribute holder modifier with an independent controller to controll the rotation, that way your control can always be at hand, in your objects hierarchy instead of a floating window.
Hope it helps,
Rafael Polit Jr.
Quito, Ecuador.
its:
spinner sp1 “test spinner” range:[0,100,0]
on sp1 changed val do
(
$box01.rotation.controller.z_rotation = sp1.value
)
or use this:
$box01.rotation.controller[3].value
eek
eek, Im sorry to dissagree… although your solution works, its a doubling of computational efforts… the spinner value is already passed as a parameter of the event in the VAL variable. To re-evaluate sp1.value is a double effort not needed.
Also, be adviced that the question probably comes froma a novice in scripting. He is asking to control the rotation of an object named boxrot ussing $box01 might confuse further more the learning of the syntax.
Im not looking to pick a fight, just trying to sort out things so what trascends is the help that rakitha asked for.
Rafael Polit Jr.
Quito, Ecuador.
Hi again,
nice, the script u gave me is working at the moment.
cheers.