Home Coding, Scripting, Shaders

Mel script having a hard time querying if face or object is selected.

polycount sponsor
Offline / Send Message
malcolm polycount sponsor
I have an if statement that I want to use to see if the object is selected or the polygon face is selected, when I use the right click menu to switch to face mode it appears to mess up the -q -polymeshFace and it will return true even though I'm in object mode. Does anyone know how to reliably query if you have faces selected or objects selected.

$maCheckIfFacesSelected = `selectType -q -polymeshFace`;

Replies

  • malcolm
    Options
    Offline / Send Message
    malcolm polycount sponsor
    Hey so I figured this out with some help from my friend at work. One reliable way to query if you have a face selected or not is to use gmatch. This is the code that works for me.

    string $maArray[];
    $maArray = `ls -sl`;

    if(`gmatch $maArray[0] "*.f*"`)

    {

    print "Some faces selected";

    }


    else

    {

    print "No faces selected";

    }

  • ZNADO
    Options
    Offline / Send Message
    ZNADO polycounter lvl 2
    hi,
    Need some help I want to remove the Maya Icon from my script   how to replace or remove it.
  • malcolm
    Options
    Offline / Send Message
    malcolm polycount sponsor
    Right click the button on the shelf you want to change and choose open. At the far right of icon name you can click the Maya icon and browse all the icons Maya comes with, if you want to use a custom icon from your desktop you can click the folder beside Maya icon. If you want no icon at all you could make a 32x32 pixel png that has no background so it will be 100% transparent when you load it into Maya.
  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    Another way you can do this is by using filterExpand

    //this gets the faces that are selected - 34 is the filter code for faces<br>string $selectionFaces[] = `filterExpand -sm 34`;&nbsp;<br><br>//test to see if faces are selected<br>if ( size($selectionFaces) == 0 ) {<br>&nbsp; &nbsp; print "no faces selected";<br>}
    https://help.autodesk.com/cloudhelp/2015/CHS/Maya-Tech-Docs/Commands/filterExpand.html
Sign In or Register to comment.