Home Coding, Scripting, Shaders

Select surface objects script(Maya)

Kalugin89
polycounter lvl 7
Offline / Send Message
Kalugin89 polycounter lvl 7
Hi all! I want to make a script in Maya for switching Select surface objects command. Now i have two separate scripts for this:

setObjectPianckMask "Surface" true;

and

setObjectPickMask "Surface" false;

How to combine them into one so that modes can be switched at the press of a button?

Replies

  • Hymil
    Online / Send Message
    Hymil polygon
    Not the most elegant solution but here is a script in Python that does what you want (not familiar with MEL). Just turn this into a shelf button or the like. It works by checking a stored value done with "optionVar" and if the var is True then runs the mel.eval to turn the object off and vice versa. It's wrapped in a try statement since if the optionVar doesn't exist yet, it'll throw an error. And in this case, just using the error catch to create the stored variable.


    from maya import cmds
    from maya import mel

    try:
        if cmds.optionVar(q="Surface Select"):
            mel.eval('setObjectPickMask "Surface" false')
            cmds.optionVar(iv=("Surface Select", 0))
        else:
            mel.eval('setObjectPickMask "Surface" true')
            cmds.optionVar(iv=("Surface Select", 1))
    except TypeError: 
        cmds.optionVar(iv=("Surface Select", 1))
  • Kalugin89
    Offline / Send Message
    Kalugin89 polycounter lvl 7
    Thanks a lot!! It 's  very helpfull!
Sign In or Register to comment.