2010

Table Of Contents
// Error: line 1: Object's name is not unique: testwindow //
All objects in Maya and user interface elements must have unique names.
To query a windows existence
1 Type the following command in the Script Editor input section, to delete
the hidden window:
deleteUI testwindow;
2 Check if the window exists by typing the following command:
window -exists testwindow;
The following result is output to the Script Editor.
// Result: 0 //
The exists flag of the window command changes the command so that
it either returns a one or zero depending on whether or not the window
exists.
3 Type the following in the Script Editor:
deleteUI non_existing_window; sphere;
An error is output to the Script Editor.
// Error: line 1: Object not found: non_existing_window
The sphere command does not execute as the script has halted on the
scripting error.
To be able to delete the existing user interface only if it exists, conditional
statements can be used.
To delete a window on condition
1 Type the following in a MEL tab of the Script Editor:
window testwindow; fake_command; showWindow;
The window is invisible as there is a scripting error, and the showWindow
command did not execute.
2 Type the following in a MEL tab of the Script Editor:
if (`window -exists testwindow`==1) { deleteUI testwindow; }
window -resizeToFitChildren 1 testwindow; columnLayout; text
-label "This window deleted the other one"; showWindow;
Window naming | 687