Notifications
Clear all

[Closed] DestroyDialog question

Hi all Ive got a floater window which has a load of buttons on which do loads of useful stuff for me. These are constructed in a rollout which is generated with the following maxscript;

rollout lodSpheres “LodGen stage 1”

What I want to do, is have the script perform a check whenever it is run, to see if this window is already open and if so, to kill the previous version. I tried to do this with just having;

DestroyDialog lodspheres

at the top of my script. This works if the window is already there, but seems to throw an error if the script is not present. So what I want to find out is if there is some way of saying (this is pseudo code btw!)

If lodSpheres exist

 DestroyDialog lodSpheres

else

 rollout lodSpheres "LodGen stage 1"     

Anyone out there know if this is possible or if Im going about this in completely the wrong manner? Any help would be really really appreciated!

Cheers,

Matt.

3 Replies

Here is the general rule for handling dialogs:

( --some local scope, for example this could be a MacroScript or whatever...

global myRolloutVariableWithUniqueName  --declare the rollout as GLOBAL
try(destroyDialog myRolloutVariableWithUniqueName)catch() --try to close it if it exists

rollout myRolloutVariableWithUniqueName "My Rollout" --define the actual rollout
(
button btn_test "Test"
)--end rollout

createDialog myRolloutVariableWithUniqueName --open the dialog
)--end local scope

You can execute this any number of times and never get two copies of the dialog.

 PEN

  try(destroyDialog myRollout)catch()
  rollout myRollout "My Rollout" ()
  createDialog myRollout
  

Edit: What Bobo said:S

I dont mean to sound like a fanboy or anything but WOW! Responses off you two is pretty impressive!

Thanks for the info I shall try that out and see how I get on.