View Full Version : showWindow in Mel
duartevictorino
04-28-2010, 05:38 PM
Hey guys,
I was following "The Artists Guide to Mel - Building custom user interface windows" and after putting this piece of code:
string $ezWindow = `window -title "EZKeyer"
-wh 128 256
EZKeyer`;
showWindow $ezWindow;
gives me an error saying:
//Error: Object´s name is not unique: EZKeyer. //
can someone give me some help?!
thanks a lot!!
Duarte
delano
04-29-2010, 09:57 AM
Hey! Try adding this before your code:
if (`window -exists EZKeyer`){
deleteUI -window $ezWindow;
}
What it does is delete your window so you can avoid errors like that.
So here's what your code should look like when it's all said and done:
if (`window -exists EZKeyer`){
deleteUI -window $ezWindow;
}
string $ezWindow = `window -title "EZKeyer"
-wh 128 256
EZKeyer`;
showWindow $ezWindow;
Hope this helps!
duartevictorino
04-29-2010, 10:17 AM
Thanks a lot Delano!
I knew that with a If statement I could solve it..BUT..I just never understand why does it give that error without putting the if statement???!!!
how can the guy on the video do it..?? I would simply like to understand.
any ideas?!
cheers,
Duarte
chrisg
04-29-2010, 10:20 AM
Hi duartevictorino,
Think of the window taking up a space called 'EZKeyer' in Maya's memory. When you try to run the window after the first time, there already is something called 'EZKeyer' in memory, so Maya doesn't want to change that space. So we have to delete the space named 'EZKeyer' before we can re-create the window. Maya seems the window as existing, so it will not change it or over-write it unless we delete the original window first.
edit: This works in the video possibly because it's the first time he's created a window. It always will work the first time you run it after restarting Maya, because that data doesn't exist yet. It's only when you want to do it the 2nd time when the error appears.
duartevictorino
04-29-2010, 10:38 AM
Fast and simple.....THANKS A LOT
:bow
cheers :),
Duarte
duartevictorino
04-29-2010, 12:24 PM
thanks bravo2zero!!
No it's not complicated at all...I just didn't understand why maya kept that in memory but thanks a lot for that piece of code...it will be definitely handy.
cheers,
Duarte