[Closed] Making a custom spinner
Hi all,
Getting more into maxscript, I’m really new and have hit a little bumpt. I’m starting with really simple practical applications.
I basically have a sphere that I have created, and want to create a maxscript that will have a spinner to control the radius of that sphere.
I’ve named the sphere right_eye, and have named it as a variable then assigned a spinners value to it, yet it doesn’t seem to be working. Am i going about this the entirely wrong way?
Thanks
rollout setfield “Eye Parameters”
(
spinner eyeradius “Eye Size”: “type#float range:[5,15,5]
(
eyesize =$right_eye.radius
eyesize = eyeradius
)
)
fieldFloater = newRolloutFloater “Eye Maker” 200 150
addRollout setField fieldFloater
You need to use an event handler to update the data, not by trying to set the controller in the code. You can read more about the Spinner Event Handlers at the bottom of the page here.
- This code will never work as you expect:
eyesize =$right_eye.radius
eyesize = eyeradius
as you are replacing the variable, not creating an instance of the spinner controller assigned to the radius controller.
-Eric
Argh! Thanks, that was so blatant, reassigning the variable!
Thanks for the push in the right direction!
if ((setfield != undefined) and (setfield.isDisplayed)) do (destroyDialog setfield)
rollout setfield "Eye Parameters"
(
spinner spn_eRadius "Eye Size " type:#float range:[5,15,5]
button btn_Create "Create"
on btn_Create pressed do
(
sphere name:"rEye"
)
on spn_eRadius changed val do
(
$rEye.radius = val
)
)
createdialog setfield 200 60
Check out John Wainwrights Maxscript 101
http://vimeo.com/19276145
Hey thanks man,
I was looking into controllers and starting to get frustrated, I will check those out…these ‘basic’ excercises that I had planned aren’t as basic as I thought!
Back to the learning board!
Like Eric said, another way is to directly assign the radius controller to the controller property of the spinner UI control –
if ((setfield != undefined) and (setfield.isDisplayed)) do (destroyDialog setfield)
rollout setfield "Eye Parameters"
(
spinner spn_eRadius "Eye Size " type:#float range:[5,15,5]
button btn_Create "Create"
on btn_Create pressed do
(
sphere name:"rEye"
$rEye.radius.controller = bezier_float()
spn_eRadius.controller = $rEye.radius.controller
)
)
createdialog setfield 200 60
Thanks for that, really handy, I think I was defining the controller incorrectly.
Much appreciated!