View Full Version : MAXSCRIPT: option box
drunkirishmic 05-21-2003, 07:10 AM whats the command/how-to to get that option box next to a command in a quadmenu. i.e. http://www.drunkirishmic.com/CGTalk/optbox.gif
im doin a little script for myself and this would be very helpful.
thanks for any assistance
|
|
orpheo
05-21-2003, 02:08 PM
You just have to write your macro with the <on altExecute type do> command
for exemple:
macroScript Mysupascript
buttonText:"supascript"
category:"Mine"
toolTip:"works fine"
(
on altExecute type do
( rollout....
)
)
drunkirishmic
05-21-2003, 08:18 PM
thank you
drunkirishmic
05-22-2003, 04:09 AM
this is what i hav thus far:
--start script--
macroscript PolyCube
category:"Polygon Objects"
(
Box lengthsegs:1 widthsegs:1 heightsegs:1 length:10 width:10 height:10 mapCoords:off pos:[0,0,0] isSelected:on
on altExecute type do
(print "hello"
)
)
--end script--
the altExecute works and when i hit it, it prints hello. but if i just choose the polycube int the quad, it says max runtime error, no such handler #Execute.
i'll research it on my own, but if anyone knows the prob off hand i would appriciate it.
thanks
drunkirishmic
05-22-2003, 05:42 AM
ok, i fixed that part.
--start script--
macroscript PolyCube
category:"Polygon Objects"
(
on execute do
(
Box lengthsegs:1 widthsegs:1 heightsegs:1 length:10 width:10 height:10 mapCoords:off pos:[0,0,0] isSelected:on
)
on altExecute type do
(rollout hello "hello"
editText hello "hello" pos:[15,28] width:113 height:46
gw = newRolloutFloater 300 200
addNewRollout hello gw
)
)
--end script--
now i can get the popup box with the rollout in it. but i havent put anythin in the rollout. when i try to add an edittext thing, it says:
-- Type error: Call needs function or class, got: undefined
-- Syntax error: at ), expected <factor>
-- In line: )
i hav no clue what its talkin bout. again i will research it on my own.
thanks again
orpheo
05-22-2003, 08:39 AM
No big troubles, just several little mistakes
the rollout command must be between ()
rollout ...
(
edittext....
) --- end of rollout
and... addrollout (I don't think the addNewrollout command exist, got an error message)
so try something like this:
------------------------------------------------------------------------------
macroscript PolyCube
category:"Polygon Objects"
(
on execute do
(
Box lengthsegs:1 widthsegs:1 heightsegs:1 length:10 width:10 height:10 mapCoords:off pos:[0,0,0] isSelected:on
)
on altExecute type do
(
rollout hello "hello"
(
editText Text "hello" pos:[15,28] width:113 height:46
)
gw = newRolloutFloater "Polycube" 300 200
addRollout hello gw
)
)
------------------------------------------------------------------------------
it should works
Hope it helps
drunkirishmic
05-22-2003, 10:01 AM
thanks, it worked like a champ, ive run into another prob, but i will research a little more before buggin u guys
thanks for ur help
drunkirishmic
05-26-2003, 09:18 AM
ok, i have an apply button in the option box:
--start script--
macroscript PolyCube
category:"Polygon Objects"
(
on execute do
(
Box lengthsegs:1 widthsegs:1 heightsegs:1 length:10 width:10 height:10 mapCoords:off pos:[0,0,0] isSelected:on
)
--define altExecute rollout--
on altExecute type do
(
rollout hello "hello"
(
edittext length "Length" pos:[40,8] width:110 height:20
edittext width "Width" pos:[40,32] width:110 height:20
edittext height "Height" pos:[40,56] width:110 height:20
edittext lengthSegs "Length Segs" pos:[40,88] width:110 height:20
edittext widthSegs "Width Segs" pos:[40,112] width:110 height:20
edittext heightSegs "Height Segs" pos:[40,136] width:110 height:20
button apply "Apply"
)
gw = newRolloutFloater "Polycube" 300 200
addRollout hello gw
)
--define event handlers for roolout--
on length entered newLenght do
(
length = newLength
)
on width entered newWidth do
(
width = newWidth
)
on apply pressed do
(
Box lengthsegs:1 widthsegs:1 heightsegs:1 length:newLength width:newWidth height:10 mapCoords:off pos:[0,0,0] isSelected:on
)
)
--end script--
when i press the apply button, nothing happens, the recorder doesnt even respond. so i figure theres gotta be a problem in the script. is the event handler for when the user enters text correct? and am i referencing it properly in the apply button eventhandler?
im a newb at this, this is a pretty pointless script, more of a learning excercise than anything else.
thanks for any help
knightknight
05-26-2003, 01:42 PM
hi,
I think you need to create some locals. But I still only a learner so I'm not sure.
Anyway I've created a script a while back which does a simular thing, it works best if you use the quad menu in expert mode alot.
have a look.
Carl
Hi, here is a general layout to follow:
macroscript someName category:"Some Category"
(
on isVisible return someBooleanExpression --optional, return true when item should be visible!
on isChecked return someBooleanExpression --optional, return true when item should be checked!
on isEnabled return someBooleanExpression --optional, return false when item should be greyed out!
on execute do
(
--your main code here
)
on altExecute do
(
rollout someRollout "Rollout"
(
button someButton "Button"
--NOTE: The button handler IS PART OF THE ROLLOUT definition!
on someButton pressed do ...
)--end rollout
--CreateDialog usually looks better than a Floater...
createDialog someRollout 200 200
)--end altExecute
)--end macroScript
LFShade
05-26-2003, 09:43 PM
As Bobo suggests, a dialog is prettier than a rollout floater. I just want to add a tip from my own little bag of tricks. When you declare your dialog, try using this construct:
createDialog someRollout someRollout.width someRollout.height
This allows you to redefine the width and height of the rollout without having to remember to update the createDialog statement as well. So it's a bit of a timesaver:)
RH
drunkirishmic
05-27-2003, 01:02 AM
thanks bobo, that did the trick.
so now i have the script to do what i want, if all values are entered in the appropriate edittext boxes. but if they are not, then it just read the global variables for each. this wouldnt be so bad, if i could keep those values displayed in their editext boxes. i thought of doing an if then else statement, but ran into some problems.
i cant declare a variable in the if statement that references the entered text for that edittext box. man i hope this is making sense. basically what i want it to do is each edittext be given a default value and store that as newLength, etc. then if the user enters a new value, then the variable newLength will be given the newly entered value. then hit the apply button and presto, u have your object with parameters entered. basically what maya has for each of its objects. seems like it should be easy enough to accomplish.
this is what i have so far
--start script--
macroscript PolyCube
category:"Polygon Objects"
(
on execute do
(
Box lengthsegs:1 widthsegs:1 heightsegs:1 length:10 width:10 height:10 mapCoords:off pos:[0,0,0] isSelected:on
)
--define altExecute rollout--
on altExecute type do
(
rollout hello "hello"
(
edittext length "Length" text:"10" pos:[40,8] width:110 height:20
edittext width "Width" pos:[40,32] width:110 height:20
edittext height "Height" pos:[40,56] width:110 height:20
edittext lengthSegs "Length Segs" pos:[40,88] width:110 height:20
edittext widthSegs "Width Segs" pos:[40,112] width:110 height:20
edittext heightSegs "Height Segs" pos:[40,136] width:110 height:20
button apply "Apply"
--define event handlers for rollout--
global initLength = length.text
on length entered text do
(
global newLength = length.text as float
)
on width entered text do
(
global newWidth = width.text as float
)
on height entered text do
(
global newHeight = height.text as float
)
on lengthSegs entered text do
(
global newLengthSegs = lengthSegs.text as float
)
on widthSegs entered text do
(
global newWidthSegs = widthSegs.text as float
)
on heightSegs entered text do
(
global newHeightSegs = heightSegs.text as float
)
on apply pressed do
(
Box lengthsegs:newLengthSegs widthsegs:newWidthSegs heightsegs:newHeightSegs length:newLength width:newWidth height:newHeight mapCoords:off pos:[0,0,0] isSelected:on
)
)
createDialog hello 400 400
)
)
--end script--
drunkirishmic
05-27-2003, 07:59 AM
Holy Crap it works!
--script--
-------------------------------------------
-- Adds the Maya option box
-- to Polygon Primatives
-------------------------------------------
macroScript PolyCube
category:"Polygon Objects"
(
global newLength = 10
global newWidth = 10
global newHeight = 10
global newLengthSegs = 1
global newWidthSegs = 1
global newHeightSegs = 1
on execute do
(
Box lengthsegs:1 widthsegs:1 heightsegs:1 length:10 width:10 height:10 mapCoords:off pos:[0,0,0] isSelected:on
macros.run "Modifier Stack" "Convert_to_Poly"
)
--define altExecute rollout--
on altExecute type do
(
rollout cube "cube" width:268 height:159
(
edittext edLength "Length" text:(newLength as string)pos:[27,35] width:109 height:20
edittext edWidth "Width " text:(newWidth as string)pos:[26,59] width:110 height:20
edittext edHeight "Height" text:(newHeight as string)pos:[29,83] width:107 height:20
edittext edLengthSegs "Length Segs " text:(newLengthSegs as string)pos:[163,35] width:90 height:20
edittext edWidthSegs "Width Segs " text:(newWidthSegs as string)pos:[168,59] width:85 height:20
edittext edHeightSegs "Height Segs" text:(newHeightSegs as string)pos:[168,83] width:85 height:20
button apply "Apply" pos:[20,117] width:66 height:21
button ok "OK" pos:[101,117] width:66 height:21
button cancel "Cancel" pos:[182,117] width:66 height:21
GroupBox lblParam "Parameters" pos:[4,4] width:260 height:149
--define event handlers for rollout--
on edLength entered text do
(
global newLength = edLength.text as float
)
on edWidth entered text do
(
global newWidth = edWidth.text as float
)
on edHeight entered text do
(
global newHeight = edHeight.text as float
)
on edLengthSegs entered text do
(
global newLengthSegs = edLengthSegs.text as float
)
on edWidthSegs entered text do
(
global newWidthSegs = edWidthSegs.text as float
)
on edHeightSegs entered text do
(
global newHeightSegs = edHeightSegs.text as float
)
on apply pressed do
(
Box lengthsegs:newLengthSegs widthsegs:newWidthSegs heightsegs:newHeightSegs length:newLength width:newWidth height:newHeight mapCoords:off pos:[0,0,0] isSelected:on
macros.run "Modifier Stack" "Convert_to_Poly"
)
on ok pressed do
(
Box lengthsegs:newLengthSegs widthsegs:newWidthSegs heightsegs:newHeightSegs length:newLength width:newWidth height:newHeight mapCoords:off pos:[0,0,0] isSelected:on
macros.run "Modifier Stack" "Convert_to_Poly"
destroyDialog cube
)
on cancel pressed do
(
destroyDialog cube
)
)
createDialog cube cube.width cube.height
)
)
--end script--
i kno its probably one of the messiest scripts, but hey, it does the job i need it to do. thanks to orpheo, bobo, and lfshade.
i learned a great deal in this little adventure, now on to the other primatives.
drunkirishmic
05-28-2003, 05:20 AM
dammit, after looking through Carl's script, i find that edittext is probably not the best rollout element to use. so i will redo it.
plus his a butt load cleaner than mine.
back to the drawing board :cry:
drunkirishmic
05-29-2003, 12:57 AM
ok, i rewrote it, using carls script for some reference. i tried not to blatantly rip it off. there is a part in there about using a defualt name in there, i still hav to figure out befor ei can put that in, because now it just gives the object an empty name, just a small thing to correct. but the Cube, Sphere, Plane, Cylinder, and Cone are all done.
anyways, here is the script, hope someone finds at least a little use for it. thanks to carl knight, lfshade, bobo, and orpheo.
Quad Primatives (http://www.drunkirishmic.com/polyObjects.ms)
CGTalk Moderation
01-15-2006, 04:03 AM
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.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.