[Closed] How to make a simple button ?
I have never done any max script before, and would like to know how
I would script a simple button. I have a basic idea of how to do it but not sure.
As an example … If I click on a box, it will set a value of another object or multiple objects to a value I choose.
I want to set the hight of box B to 100 by clicking on box A ?
Any help will be appreciated.
THANKS.
You want to click on a box to change other boxes? Why would you want to do that?
Some more info would be useful. I thought you wanted a simple button. What you describe is at the edge of advanced scripting and probably requires a lot more knowledge…
Do you want to run a script before that? Or do you want it to be a callback monitoring what you are doing and changing things as you go? How do you want to specify which objects to affect? Selection? How do you specify the value? A spinner? Or via the height of the Box A? Or something else?
Please try to write down step by step what you think the workflow of your tool would be.
Then you (and we all) can try to find the right commands to do what you want.
If you have just a vague idea what you want, or cannot describe your idea to others, chances are that writing the script will not be very easy…
Well … I wanted to make a button for morph sliders.
for a face rig.
you would click on an object “the button” in the script you would hard code what
values would change on what objects “morphs” I want it to set all targets to “0”
except for the morph that button represents. that morph target will then be set to “100”
It is just easier to key morphs without having to set them all to 0 then ramp back up the one you want.
I hope that is clear ? I just tried to simplify the concept by using boxes for the test.
I have used for years a system for lipsync which does exactly what you suggest. I always thought it is better to set all the targets at 0 and then set the one you want to the value you need. As im not at my work computer i cant post you the script file, but i’ll tell you how i do it.
I created a function called “zeromorph” , which uses a simple for/loop to step through the channels of the selected objects morpher modifier. This lives in startup/scripts and is called by the button press in max. the reason for this is it simplifies the code and doesn’t matter how many morph targets you add.
on button MBP pressed do
(
zeromorph()
-- >> set morph value in this line <<--
)
this is much less code than listing the morpher channel and the value on every button. sorry i cant give you the exact code, but its sunday evening and i dont have access to the MXS help file.
Thanks pudgerboy…
That is a step in the right direction. how would I apply that to an object in the scene like
a box. What I mean is the box will be the button that controls the morpher.
I want to add it to a floating interface made out of max objects.
THANKS !
Okay Omar, did a little DVD for your chronicles… lol. Check it out… I have an object (rectangle)
It has a edit spline modifier (that I made a check in)
And an attribute holder (which holds the “open” attribute thingy)
http://omega3d.boy1da.com/CheckObject.zip
ca = attributes checkobject
(
parameters objs rollout:adjust
(
requestValue type:#float ui:morpherValue
)
rollout adjust "Adjust value"
(
-- Runs if the object is selected
fn checkstatus =
(
if $Rectangle01.modifiers[2].enabled == false then
(
$Sphere01.morpher[1].value = checkobj.modifiers[1].requestValue
$Rectangle01.modifiers[2].enabled = true
) else (
if $Rectangle01.modifiers[2].enabled == true then
(
$Sphere01.morpher[1].value = 0
$Rectangle01.modifiers[2].enabled = false
)
)
)
on adjust open do checkStatus()
spinner morpherValue "MorphValue:" range:[0,100,100] type:#integer
)
)
custattributes.add $Rectangle01.modifiers[1] ca
(THIS IS A ROUGH PIECE… you need the maxfile to use it… or else its bananas… lol
I tried something like this , so that I can click a box to change the radius of the teapot
as a test. but it didn’t work…
on pickObject $Box04 then $Teapot01 .radius = 100
I got this much to work BUT it only does it once. then if i click it again it does nothing
I have to run the script again to get it to work again . How do I keep it active ?
(
[size=3]pickObject $Box04
( $Teapot01 .radius = 100 )
)
[/size]
Here is a better – more explained version of the script thingy… I will check your code in a sec.
Here is a video of what I got to work so far… 6.56 MB
Hi,
try this:
(
deleteAllChangeHandlers id:#foo
when select $Box01 changes id:#foo do
(
if selection[1]==$Box01 do $teapot01.radius+=50
)
)
Also, I would recommend Paul Neale’s attribute holder to make pressets of the slider values
of a morpher
so you could reset all values of a morpher with a simple button