PDA

View Full Version : Showing and hiding objects...


jbw
03-05-2004, 03:00 PM
Please can someone help me... I'm starting to get really wound up with myself for not being able to sort this. I've been using Max for about 5 years now and have never touched on Maxscript... until now.
All I need to do is create a script that will create a floater with 2 buttons in it. One button will show objects that end in a certain word and hide other objects that end in another. The other button will reverse the above action.
Please can someone give me a push in the right direction. Whilst this is most likely the easiest script you guys have come across... I'm completely out of my league. I've been looking at the help file and I've been experimenting and playing with scripts for a couple of days but nothing is working. I've followed the macro recorder to find out how maxscript uses unhide and hide but all I get are syntax errors. My syntax errors kick in whenever I place another line in a do action?

rollout FloaterRenderUtil "HiResFloater"
(
button HiRes "Hi-Res"
button LowRes "Low-Res"

on HiRes pressed do
hide $*LowRes
unhide $*HiRes

)

ta,
jbw

Cthulhu
03-05-2004, 03:14 PM
you just forgot the parenthesis around your codeblock. if there is more than one line after a 'do', you need to put them around, so it should look like this:

on HiRes pressed do
(
hide $*LowRes
unhide $*HiRes
)

jbw
03-05-2004, 04:54 PM
Cthulhu - thank you for your help. Worked a treat.
Sorry to burden you guys but I'm now getting another error! :cry:
My script now looks like this:

rollout FloaterExample "FloaterExample"
(
button HiRes "Hi-Res"
button LowRes "Low-Res"

on HiRes pressed do
(
hide $*LowRes
unhide $*HiRes
)

on LowRes pressed do
(
clearselection()
hide $*HiRes
unhide $*LowRes
)

-- create the rollout window and add the rollout
if FloaterExampleFloater != undefined do
(
closerolloutfloater FloaterExampleFloater
)
FloaterExampleFloater = newRolloutFloater "FloaterExample Floater" 200 500
addRollout FloaterExample FloaterExampleFloater

Now I get:

-- Syntax error: at if, expected <rollout clause>
-- In line: if FloaterExampleFloater != undefined do

in the listener window? I blagged that lower part from the floater example script thinking I was being clever. Obviously not? Anyone shove me in the right direction?

By the way, I generally use 3d (Max and LW) for character animation and was considering really getting stuck into this max script (I know a bit of wiring and expression stuff). Is it worth it for what I do?

ta,
jbw

Cthulhu
03-05-2004, 05:07 PM
and again, you forgot a parenthesis ;) you should take a deeper look into the structur of maxscript...
it should look like this:

rollout floaterExample "FloaterExample"
( <- this defines the beginning of the rollout block

buttons ...

on button pressed do
( <- beginning of the button code block
...
) <- end of the button code block

) <- now close the rollout block

-- create the rollout window and add the rollout
if FloaterExampleFloater != undefined do
(
closerolloutfloater FloaterExampleFloater
)
FloaterExampleFloater = newRolloutFloater "FloaterExample Floater" 200 500
addRollout FloaterExample FloaterExampleFloater

hope this helps you..

jbw
03-08-2004, 10:34 AM
Cthulhu - thank you so much for showing me where I was going wrong. I'm gonna take your advice and take a good look at the structure of max scripts. I'm sure I'll be back at some point.

Anyhow a virtual beer for your troubles! :beer:

ta,
jbw

CGTalk Moderation
01-17-2006, 04:00 PM
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.