Duplicate Windows in MEL


#1

Hi,

I have a little problem and I am sure there is a very simple solution to it. All I want is for old windows to be closed when I execute the script. I broke the script down to the important parts, so hopefully someone can tell me what is missing:

string $mapWin;

if(`window -ex $mapWin`)
{
    deleteUI -window $mapWin;
}

string $mapWin = `window -t "UV MAPPER V1.1"
                  -wh 350 400`;		         
                         
       columnLayout -adj true;
                         
showWindow $mapWin;

Thank you.


#2

There is no problem with that code, that is the standard way people do this using the if and deleteUI and it works on my end


#3

Thank you for your reply. I tried it on multiple computers, its producing more and more windows on top of each other. Might there be some weird setting in Maya that I overlooked?


#4

yeah i see your problem now, little rusty with my mel since i only use python now but you have to define the window path name when you create the window

string $mapWin = "UVMapper";
 
 if(`window -ex $mapWin`)
 {
 	deleteUI -window $mapWin;
 }
 
 string $mapWin = `window -t "UV MAPPER V1.1" -wh 350 400 $mapWin`;				 
 						 
 	   columnLayout -adj true;
 						 
 showWindow $mapWin;
 

this ensures that it will always use the same path name thus the if statemeant will always kill it


#5

Thats great. Thank you very much. :keenly: