Home Coding, Scripting, Shaders

MEL - Browse Button Not working

polycounter lvl 5
Offline / Send Message
Pinned
jayantbhatt007 polycounter lvl 5

Hi, In my #MEL command browse button is not working I'm getting an error

 

// Error: line 56: Object 'rsTxtPath' not found. ANY IDEA?

 

 

proc ScreenCaptureWin()
{
global string $rsTxtPath, $rsTxtName;
string $sn = `file -q -sn`;
string $cfp = `dirname( $sn )`;

if (`window -exists ScreenCapture`) //closes window if already open
deleteUI ScreenCapture;

window -title "ScreenCapture" ScreenCapture; //creates window

rowColumnLayout -numberOfColumns 5 -columnAttach 1 "right" 1 -columnWidth 10 10 -columnWidth 50 10;
text -label "Path";
$rsTxtPath = `textField -w 200 -h 28 -tx $cfp -ed true rsTxtFld`;
symbolButton -w 60 -h 28 -image "openLoadGeneric.png" -c "rsFileDialog()" rsTxtPath;
button -w 60 -h 28 -label "Capture" -command "Capture";
symbolButton -w 60 -h 28 -image "refresh.png" -command "seleP()";
rowColumnLayout -numberOfColumns 2 -columnAttach 1 "left" 1 -columnWidth 10 10 -columnWidth 10 10;
text -label "Name";
$rsTxtName = `textField -w 100 -h 28 -ed true `;

// show the window we last created
showWindow;;
}

 


global proc Capture()
{
global string $rsTxtPath;
global string $rsTxtName;

string $path = `textField -q -tx $rsTxtPath`;
string $FileName = `textField -q -tx $rsTxtName`;
string $rsFileList[] = `getFileList -folder $path`;
int $rsFileCount = size($rsFileList);
string $k = ($path + ("/"+$FileName+".jpg"));
string $ff = ".png";
string $node[] = `ls -sl`;
setAttr "defaultRenderGlobals.imageFormat" 8;
playblast -st 1 -et 1 -v 0 -fmt "image" -qlt 100 -p 100 -w 1000 -h 1000 -fp 0 -cf $k;
clear $node;
}

proc seleP() //It is for relaod button automatically add path where the user saved the Maya file

{
string $selDir = `workspace -q -dir`;
textFieldButtonGrp -e -tx $selDir rsTxtPath ;
}

proc rsFileDialog()
{
string $rsPath[] = `fileDialog2 -ds 1 -fm 3`;
textFieldButtonGrp -e -tx $rsPath[0] rsTxtPath;
}

Replies

  • throttlekitty
    Just a quick guess that on lines 50 and 56, you didn't include a $ on rsTxtPath.
  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 5
    // Error: Line 56.53: "$rsTxtPath" is an undeclared variable.
  • Tekoppar
    Offline / Send Message
    Tekoppar polycounter lvl 10
    You need to declare $rsTxtPath outside both procs before you can use it as a global, so just add at the top of the script
    string $rsTxtPath;
  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 5
    I hope this command is fine. Now I'm getting an error " // Error: line 61: Object 'rsTxtPath' not found. " . Any Idea?


    global string $rsTxtPath, $rsTxtName;
    global proc ScreenCaptureWin()


    {

    string $sn = `file -q -sn`;
    string $cfp = `dirname( $sn )`;


    if (`window -exists ScreenCapture`) //closes window if already open
    deleteUI ScreenCapture;

    window -title "ScreenCapture" ScreenCapture; //creates window
    string $rsTxtPath;
    rowColumnLayout -numberOfColumns 5 -columnAttach 1 "right" 1 -columnWidth 10 10 -columnWidth 50 10;
    text -label "Path";
    $rsTxtPath = `textField -w 200 -h 28 -tx $cfp -ed true`;
    symbolButton -w 60 -h 28 -image "openLoadGeneric.png" -c "rsFileDialog()" rsTxtPath;
    button -w 60 -h 28 -label "Capture" -command "Capture";
    symbolButton -w 60 -h 28 -image "refresh.png" -command "seleP()";
    rowColumnLayout -numberOfColumns 2 -columnAttach 1 "left" 1 -columnWidth 10 10 -columnWidth 10 10;
    text -label "Name";
    $rsTxtName = `textField -w 100 -h 28 -ed true `;

    // show the window we last created
    showWindow;;
    }

     


    global proc Capture()

    {
    global string $rsTxtPath;
    global string $rsTxtName;


    string $path = `textField -q -tx $rsTxtPath rsTxtPath`;
    string $FileName = `textField -q -tx $rsTxtName`;
    string $rsFileList[] = `getFileList -folder $path`;
    int $rsFileCount = size($rsFileList);
    string $k = ($path + ("/"+$FileName+".jpg"));
    string $ff = ".png";
    string $node[] = `ls -sl`;
    setAttr "defaultRenderGlobals.imageFormat" 8;
    playblast -st 1 -et 1 -v 0 -fmt "image" -qlt 100 -p 100 -w 1000 -h 1000 -fp 0 -cf $k;
    clear $node;

    }

    proc seleP() //It is for relaod button automatically add path where the user saved the Maya file
    {  
    string $selDir = `workspace -q -dir`;
    textFieldButtonGrp -e -tx $selDir rsTxtPath;
    }
    proc rsFileDialog()
    {
    string $rsPath[] = `fileDialog2 -ds 1 -fm 3`;
    textFieldButtonGrp -e -tx $rsPath[0] rsTxtPath;
    }
  • Tekoppar
    Offline / Send Message
    Tekoppar polycounter lvl 10
    You forgot $ before rsTxtPath;
  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 5
    I did Now I'm getting a different error  ( // Error: Line 61.48: "$rsTxtPath" is an undeclared variable. ) Any help 




    global string $rsTxtPath, $rsTxtName;
    global proc ScreenCaptureWin()


    {

    string $sn = `file -q -sn`;
    string $cfp = `dirname( $sn )`;


    if (`window -exists ScreenCapture`) //closes window if already open
    deleteUI ScreenCapture;

    window -title "ScreenCapture" ScreenCapture; //creates window
    string $rsTxtPath;
    rowColumnLayout -numberOfColumns 5 -columnAttach 1 "right" 1 -columnWidth 10 10 -columnWidth 50 10;
    text -label "Path";
    $rsTxtPath = `textField -w 200 -h 28 -tx $cfp -ed true`;
    symbolButton -w 60 -h 28 -image "openLoadGeneric.png" -c "rsFileDialog()" $rsTxtPath;
    button -w 60 -h 28 -label "Capture" -command "Capture";
    symbolButton -w 60 -h 28 -image "refresh.png" -command "seleP()";
    rowColumnLayout -numberOfColumns 2 -columnAttach 1 "left" 1 -columnWidth 10 10 -columnWidth 10 10;
    text -label "Name";
    $rsTxtName = `textField -w 100 -h 28 -ed true `;

    // show the window we last created
    showWindow;;
    }

     


    global proc Capture()

    {
    global string $rsTxtPath;
    global string $rsTxtName;


    string $path = `textField -q -tx $rsTxtPath`;
    string $FileName = `textField -q -tx $rsTxtName`;
    string $rsFileList[] = `getFileList -folder $path`;
    int $rsFileCount = size($rsFileList);
    string $k = ($path + ("/"+$FileName+".jpg"));
    string $ff = ".png";
    string $node[] = `ls -sl`;
    setAttr "defaultRenderGlobals.imageFormat" 8;
    playblast -st 1 -et 1 -v 0 -fmt "image" -qlt 100 -p 100 -w 1000 -h 1000 -fp 0 -cf $k;
    clear $node;

    }

    proc seleP() //It is for relaod button automatically add path where the user saved the Maya file
    {  
    string $selDir = `workspace -q -dir`;
    textFieldButtonGrp -e -tx $selDir $rsTxtPath;
    }
    proc rsFileDialog()
    {
    string $rsPath[] = `fileDialog2 -ds 1 -fm 3`;
    textFieldButtonGrp -e -tx $rsPath[0] $rsTxtPath;
    }
  • Tekoppar
    Offline / Send Message
    Tekoppar polycounter lvl 10
    You forgot to declare the $rsTxtPath as a global since you're using it inside a function(proc).
    global string $rsTextPath

     Needs to be added inside every function(proc) that wants to use the global version.

  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 5
    Hi, I hope this time I'm right. Now Error is  // Error: line 65: Object '' not found. 



    global string $rsTxtPath;
    global string $rsTxtName;
    global proc ScreenCaptureWin()


    {

    string $sn = `file -q -sn`;
    string $cfp = `dirname( $sn )`;


    if (`window -exists ScreenCapture`) //closes window if already open
    deleteUI ScreenCapture;

    window -title "ScreenCapture" ScreenCapture; //creates window
    string $rsTxtPath;
    rowColumnLayout -numberOfColumns 5 -columnAttach 1 "right" 1 -columnWidth 10 10 -columnWidth 50 10;
    text -label "Path";
    $rsTxtPath = `textField -w 200 -h 28 -tx $cfp -ed true`;
    symbolButton -w 60 -h 28 -image "openLoadGeneric.png" -c "rsFileDialog()" $rsTxtPath;
    button -w 60 -h 28 -label "Capture" -command "Capture";
    symbolButton -w 60 -h 28 -image "refresh.png" -command "seleP()";
    rowColumnLayout -numberOfColumns 2 -columnAttach 1 "left" 1 -columnWidth 10 10 -columnWidth 10 10;
    text -label "Name";
    $rsTxtName = `textField -w 100 -h 28 -ed true `;

    // show the window we last created
    showWindow;;
    }

     


    global proc Capture()

    {
    global string $rsTxtPath;
    global string $rsTxtName;


    string $path = `textField -q -tx $rsTxtPath`;
    string $FileName = `textField -q -tx $rsTxtName`;
    string $rsFileList[] = `getFileList -folder $path`;
    int $rsFileCount = size($rsFileList);
    string $k = ($path + ("/"+$FileName+".jpg"));
    string $ff = ".png";
    string $node[] = `ls -sl`;
    setAttr "defaultRenderGlobals.imageFormat" 8;
    playblast -st 1 -et 1 -v 0 -fmt "image" -qlt 100 -p 100 -w 1000 -h 1000 -fp 0 -cf $k;
    clear $node;

    }

    proc seleP() //It is for relaod button automatically add path where the user saved the Maya file
    {  
    global string $rsTxtPath;
    string $selDir = `workspace -q -dir`;
    textFieldButtonGrp -e -tx $selDir $rsTxtPath;
    }

    proc rsFileDialog()
    {
    global string $rsTxtPath;
    string $rsPath[] = `fileDialog2 -ds 1 -fm 3`;
    textFieldButtonGrp -e -tx $rsPath[0] $rsTxtPath;
    }
  • Tekoppar
    Offline / Send Message
    Tekoppar polycounter lvl 10
    textFieldButtonGrp has no -e flag. Remove that and it works.
  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 5
    Thank you just a small doubt I added a condition to my procedure but it seems to be not working.

    global proc Capture()
    {
        global string $rsTxtFld, $rsTxtName;
        string $path = `textFieldButtonGrp -q -tx $rsTxtFld`;
        string $FileName = `textField -q -tx $rsTxtName`;
        string $k = ($path + ("/"+$FileName+".jpg")); 
        
         if (size($rsTxtFld) > 1)
         {print("select one or more object please ");confirmDialog -t"Select Error...." 
                        -m"Set Path Or Click Reload     " 
                            -button "Close" 
                            -cancelButton "Close" -dismissString "Close";}
                            
         else if (size($rsTxtFld) < 1)
        {
        
        setAttr "defaultRenderGlobals.imageFormat" 8;
        playblast -st 1 -et 1 -v 0 -fmt "image" -qlt 100 -p 100 -w 1920 -h 1080 -fp 0 -cf $k;
    }
        }  


  • Tekoppar
    Offline / Send Message
    Tekoppar polycounter lvl 10
    Is the string variable $rsTxtFld actually set to something? Try print($rsTxtFld) too see what value you get. there is no need for the else if, just do a normal
    string $test;<br>int $len = size($test);<br><br>if ($len > 0) {<br>    print("There are characters");<br>} else {<br>    print("There are no characters");<br>}<br>


  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 5
    Tekoppar said:
    Is the string variable $rsTxtFld actually set to something? Try print($rsTxtFld) too see what value you get. there is no need for the else if, just do a normal
    string $test;<br>int $len = size($test);<br><br>if ($len > 0) {<br>    print("There are characters");<br>} else {<br>    print("There are no characters");<br>}<br>


    Hi, Thank you so much Here is the final code


         string $path;
         int $fill = size($path);
         if ($fill < 1)
         {print("select one or more object please ");confirmDialog -t"Select Error...." 
                        -m"Set Path Or Click Reload     " 
                            -button "Close" 
                            -cancelButton "Close" -dismissString "Close";}
                            
         else 
        {
        
        setAttr "defaultRenderGlobals.imageFormat" 8;
        playblast -st 1 -et 1 -v 0 -fmt "image" -qlt 100 -p 100 -w 1920 -h 1080 -fp 0 -cf $k;
    }
        }   
Sign In or Register to comment.