Home Coding, Scripting, Shaders

Maya MEL Creating multiple Windows Error

polycounter lvl 5
Offline / Send Message
Pinned
jayantbhatt007 polycounter lvl 5
Hi I was just messing with the  Maya MEL script and somehow I created a small script for my workflow but there is one error. I don't to where to paste this line  

if ( `window -exists nameWindow` ) {
      deleteUI nameWindow;
}


HERE IS MY SCRIPT..........


// create a window with a menu bar

window -title "3DGhost" -menuBar true -w 220 -h 200;
// two frame layouts will be laid out in a columna
columnLayout;
// create a collapsible frame layout
frameLayout -collapsable true -label "Shapes";
{




// create a tearOff menu
menu -label "File" -tearOff true;
// add the menu items
menuItem -label "New" -command "NewScene";
menuItem -label "Open" -command "OpenScene";
menuItem -label "Save" -command "SaveScene";
menuItem -divider true -command "SaveScene";
menuItem -label "Quit" -command "quit";
// add a help menu
menu -label "Help" -helpMenu true;
menuItem -label "Help" -command "Help";
// add a help menu
menu -label "Credit" -helpMenu true;
menuItem -label "Jayant bhatt";

// add the other controls
flowLayout -columnSpacing 1 -w 220 -h 40;
    // create three symbol buttons with related mel command
symbolButton -image "cube.xpm" -command "polyCube";
symbolButton -image "sphere.xpm" -command "CreatePolygonSphere";
symbolButton -image "plane.xpm" -command "CreatePolygonPlane";
symbolButton -image "cylinder.xpm" -command "CreatePolygonCylinder";
symbolButton -image "circle.xpm" -command "CreateNURBSCircle";
symbolButton -image "text.xpm" -command "CreatePolygonType";
setParent ..;
setParent ..;
// three frame layouts will be laid out in a column
columnLayout;
// create a collapsible frame layout
frameLayout -collapsable true -label "Options";
// define the layout of controls added 
// to the window.
columnLayout;
// add the other controls
flowLayout -columnSpacing 1 -w 220 -h 40;
// create a couple of buttons
symbolButton -image "CenterPivot.png" -command "CenterPivot";
symbolButton -image "multiCut_NEX32.png" -command "dR_multiCutTool";
symbolButton -image "polyCircularize.png" -command "PolyCircularize";
symbolButton -image "detach.png" -command "DetachComponent";
symbolButton -w 35 -h 35 -image "addCreateGeneric_100.png" -command "CombinePolygons";
symbolButton -w 35 -h 35 -image "mergeConnections.png" -command "CombinePolygons";
                    
                    setParent ..;
                   setParent ..;
                   setParent ..;
                   
                   

// create a collapsible frame layout
frameLayout -collapsable true -label "Constraint";
// add the other controls
flowLayout -columnSpacing 5 -w 220 -h 40;


symbolButton -w 30 -h 30 -image "edges_NEX.png" -command "toolPropertyShow";

symbolButton -w 30 -h 30 -image "hyper_s_ON.png" -command "manipMoveSetXformConstraint edge";

symbolButton -w 30 -h 30 -image "hyper_s_OFF.png" -command "manipMoveSetXformConstraint none";


                   setParent ..;
                   setParent ..;
                   setParent ..;                
        
                   
                   
              
              



                 
showWindow;
}

Replies

  • renderhjs
    Options
    Offline / Send Message
    renderhjs sublime tool
    Pergaps specify in your topic or first message what "this script" language is. You might get more useful responses that way.
  • throttlekitty
    Options
    Offline / Send Message
    And some details on your problem are helpful. "some error" and "paste this line" are completely unknown to us.
  • jayantbhatt007
    Options
    Offline / Send Message
    jayantbhatt007 polycounter lvl 5
    And some details on your problem are helpful. "some error" and "paste this line" are completely unknown to us.
    // create a window with a menu bar

    window -title "3DGhost" -menuBar true -w 220 -h 200;
    // two frame layouts will be laid out in a columna
    columnLayout;
    // create a collapsible frame layout
    frameLayout -collapsable true -label "Shapes";
    {




    // create a tearOff menu
    menu -label "File" -tearOff true;
    // add the menu items
    menuItem -label "New" -command "NewScene";
    menuItem -label "Open" -command "OpenScene";
    menuItem -label "Save" -command "SaveScene";
    menuItem -divider true -command "SaveScene";
    menuItem -label "Quit" -command "quit";
    // add a help menu
    menu -label "Help" -helpMenu true;
    menuItem -label "Help" -command "Help";
    // add a help menu
    menu -label "Credit" -helpMenu true;
    menuItem -label "Jayant bhatt";

    // add the other controls
    flowLayout -columnSpacing 1 -w 220 -h 40;
        // create three symbol buttons with related mel command
    symbolButton -image "cube.xpm" -command "polyCube";
    symbolButton -image "sphere.xpm" -command "CreatePolygonSphere";
    symbolButton -image "plane.xpm" -command "CreatePolygonPlane";
    symbolButton -image "cylinder.xpm" -command "CreatePolygonCylinder";
    symbolButton -image "circle.xpm" -command "CreateNURBSCircle";
    symbolButton -image "text.xpm" -command "CreatePolygonType";
    setParent ..;
    setParent ..;
    // three frame layouts will be laid out in a column
    columnLayout;
    // create a collapsible frame layout
    frameLayout -collapsable true -label "Options";
    // define the layout of controls added 
    // to the window.
    columnLayout;
    // add the other controls
    flowLayout -columnSpacing 1 -w 220 -h 40;
    // create a couple of buttons
    symbolButton -image "CenterPivot.png" -command "CenterPivot";
    symbolButton -image "multiCut_NEX32.png" -command "dR_multiCutTool";
    symbolButton -image "polyCircularize.png" -command "PolyCircularize";
    symbolButton -image "detach.png" -command "DetachComponent";
    symbolButton -w 35 -h 35 -image "addCreateGeneric_100.png" -command "CombinePolygons";
    symbolButton -w 35 -h 35 -image "mergeConnections.png" -command "CombinePolygons";
                        
                        setParent ..;
                       setParent ..;
                       setParent ..;
                       
                       

    // create a collapsible frame layout
    frameLayout -collapsable true -label "Constraint";
    // add the other controls
    flowLayout -columnSpacing 5 -w 220 -h 40;


    symbolButton -w 30 -h 30 -image "edges_NEX.png" -command "toolPropertyShow";

    symbolButton -w 30 -h 30 -image "hyper_s_ON.png" -command "manipMoveSetXformConstraint edge";

    symbolButton -w 30 -h 30 -image "hyper_s_OFF.png" -command "manipMoveSetXformConstraint none";


                       setParent ..;
                       setParent ..;
                       setParent ..;                
            
                       
                       
                  
                  



                     
    showWindow;
    }
  • jayantbhatt007
    Options
    Offline / Send Message
    jayantbhatt007 polycounter lvl 5
  • jayantbhatt007
    Options
    Offline / Send Message
    jayantbhatt007 polycounter lvl 5
    renderhjs said:
    Pergaps specify in your topic or first message what "this script" language is. You might get more useful responses that way.

    thanks for your reply and I know you I have used your scripts also. Great work.
    Its MEL can  you help me it is urgent.I Would be great if tou can fix it.Works with maya 2017 and 2018.
  • TTools
    Options
    Offline / Send Message
    TTools polycounter lvl 4
    You were really close.   See below in red. You need to specify a name for the window object in order to access it specifically.  So when you create the window, note that I added a name for the window object, "jayantsWindow".  In this way, you can now run the check command if that window exists, and if so then delete it at the beginning of your script, and at the very end you specify to show that specific window.  Your window objects should always have a name, that way you can make commands specifically to them.  Leaving off a window object name is kind of like throwing them out there into the maya environment as an anonymous entity that you can't access later.  Make sense? 

    // delete window if it exists
    if ( `window -exists jayantsWindow` ) {
          deleteUI jayantsWindow;
    }

    // create a window with a menu bar

    window -title "3DGhost" -menuBar true -w 220 -h 200 jayantsWindow;
    // two frame layouts will be laid out in a columna
    columnLayout;
    // create a collapsible frame layout
    frameLayout -collapsable true -label "Shapes";
    {




    // create a tearOff menu
    menu -label "File" -tearOff true;
    // add the menu items
    menuItem -label "New" -command "NewScene";
    menuItem -label "Open" -command "OpenScene";
    menuItem -label "Save" -command "SaveScene";
    menuItem -divider true -command "SaveScene";
    menuItem -label "Quit" -command "quit";
    // add a help menu
    menu -label "Help" -helpMenu true;
    menuItem -label "Help" -command "Help";
    // add a help menu
    menu -label "Credit" -helpMenu true;
    menuItem -label "Jayant bhatt";

    // add the other controls
    flowLayout -columnSpacing 1 -w 220 -h 40;
        // create three symbol buttons with related mel command
    symbolButton -image "cube.xpm" -command "polyCube";
    symbolButton -image "sphere.xpm" -command "CreatePolygonSphere";
    symbolButton -image "plane.xpm" -command "CreatePolygonPlane";
    symbolButton -image "cylinder.xpm" -command "CreatePolygonCylinder";
    symbolButton -image "circle.xpm" -command "CreateNURBSCircle";
    symbolButton -image "text.xpm" -command "CreatePolygonType";
    setParent ..;
    setParent ..;
    // three frame layouts will be laid out in a column
    columnLayout;
    // create a collapsible frame layout
    frameLayout -collapsable true -label "Options";
    // define the layout of controls added 
    // to the window.
    columnLayout;
    // add the other controls
    flowLayout -columnSpacing 1 -w 220 -h 40;
    // create a couple of buttons
    symbolButton -image "CenterPivot.png" -command "CenterPivot";
    symbolButton -image "multiCut_NEX32.png" -command "dR_multiCutTool";
    symbolButton -image "polyCircularize.png" -command "PolyCircularize";
    symbolButton -image "detach.png" -command "DetachComponent";
    symbolButton -w 35 -h 35 -image "addCreateGeneric_100.png" -command "CombinePolygons";
    symbolButton -w 35 -h 35 -image "mergeConnections.png" -command "CombinePolygons";
                        
                        setParent ..;
                       setParent ..;
                       setParent ..;
                       
                       

    // create a collapsible frame layout
    frameLayout -collapsable true -label "Constraint";
    // add the other controls
    flowLayout -columnSpacing 5 -w 220 -h 40;


    symbolButton -w 30 -h 30 -image "edges_NEX.png" -command "toolPropertyShow";

    symbolButton -w 30 -h 30 -image "hyper_s_ON.png" -command "manipMoveSetXformConstraint edge";

    symbolButton -w 30 -h 30 -image "hyper_s_OFF.png" -command "manipMoveSetXformConstraint none";


                       setParent ..;
                       setParent ..;
                       setParent ..;                
            
                       
                       

                  



                     
    showWindow jayantsWindow;
    }
  • jayantbhatt007
    Options
    Offline / Send Message
    jayantbhatt007 polycounter lvl 5
    TTools said:
    You were really close.   See below in red. You need to specify a name for the window object in order to access it specifically.  So when you create the window, note that I added a name for the window object, "jayantsWindow".  In this way, you can now run the check command if that window exists, and if so then delete it at the beginning of your script, and at the very end you specify to show that specific window.  Your window objects should always have a name, that way you can make commands specifically to them.  Leaving off a window object name is kind of like throwing them out there into the maya environment as an anonymous entity that you can't access later.  Make sense? 

    // delete window if it exists
    if ( `window -exists jayantsWindow` ) {
          deleteUI jayantsWindow;
    }

    // create a window with a menu bar

    window -title "3DGhost" -menuBar true -w 220 -h 200 jayantsWindow;
    // two frame layouts will be laid out in a columna
    columnLayout;
    // create a collapsible frame layout
    frameLayout -collapsable true -label "Shapes";
    {




    // create a tearOff menu
    menu -label "File" -tearOff true;
    // add the menu items
    menuItem -label "New" -command "NewScene";
    menuItem -label "Open" -command "OpenScene";
    menuItem -label "Save" -command "SaveScene";
    menuItem -divider true -command "SaveScene";
    menuItem -label "Quit" -command "quit";
    // add a help menu
    menu -label "Help" -helpMenu true;
    menuItem -label "Help" -command "Help";
    // add a help menu
    menu -label "Credit" -helpMenu true;
    menuItem -label "Jayant bhatt";

    // add the other controls
    flowLayout -columnSpacing 1 -w 220 -h 40;
        // create three symbol buttons with related mel command
    symbolButton -image "cube.xpm" -command "polyCube";
    symbolButton -image "sphere.xpm" -command "CreatePolygonSphere";
    symbolButton -image "plane.xpm" -command "CreatePolygonPlane";
    symbolButton -image "cylinder.xpm" -command "CreatePolygonCylinder";
    symbolButton -image "circle.xpm" -command "CreateNURBSCircle";
    symbolButton -image "text.xpm" -command "CreatePolygonType";
    setParent ..;
    setParent ..;
    // three frame layouts will be laid out in a column
    columnLayout;
    // create a collapsible frame layout
    frameLayout -collapsable true -label "Options";
    // define the layout of controls added 
    // to the window.
    columnLayout;
    // add the other controls
    flowLayout -columnSpacing 1 -w 220 -h 40;
    // create a couple of buttons
    symbolButton -image "CenterPivot.png" -command "CenterPivot";
    symbolButton -image "multiCut_NEX32.png" -command "dR_multiCutTool";
    symbolButton -image "polyCircularize.png" -command "PolyCircularize";
    symbolButton -image "detach.png" -command "DetachComponent";
    symbolButton -w 35 -h 35 -image "addCreateGeneric_100.png" -command "CombinePolygons";
    symbolButton -w 35 -h 35 -image "mergeConnections.png" -command "CombinePolygons";
                        
                        setParent ..;
                       setParent ..;
                       setParent ..;
                       
                       

    // create a collapsible frame layout
    frameLayout -collapsable true -label "Constraint";
    // add the other controls
    flowLayout -columnSpacing 5 -w 220 -h 40;


    symbolButton -w 30 -h 30 -image "edges_NEX.png" -command "toolPropertyShow";

    symbolButton -w 30 -h 30 -image "hyper_s_ON.png" -command "manipMoveSetXformConstraint edge";

    symbolButton -w 30 -h 30 -image "hyper_s_OFF.png" -command "manipMoveSetXformConstraint none";


                       setParent ..;
                       setParent ..;
                       setParent ..;                
            
                       
                       

                  



                     
    showWindow jayantsWindow;
    }
    thanks sir
Sign In or Register to comment.