Home Technical Talk

Maya/Mel Script question

interpolator
Offline / Send Message
Hito interpolator
I'm trying to make some selection shelf buttons, specifically for selecting limbs, or fingers or the like... by clicking on a control object and have the active selection extend to include the hierarchy. e.g. clicking on the wrist might select metacarpals and all the fingers. clicking on the knuckle would select the remaining finger joints of that finger. I also want to limit this to only include visible objects in the viewport... so I don't select IK controls while in FK mode, or vice versa.

I tried the MEL select command with various flagcombinations, -hi -vis -a -r; none seems to do what I want or expect the button to do.

how can I do this properly?

Replies

  • DireWolf
    Options
    Offline / Send Message
    The way MEL/Python works. When you specified the name of the object to be selected, it WILL select it regardless of visibily.

    What you can do is use the name to check for visibility before doing the selection. I'm gonna use joint1 as example here with Python.
    from maya import cmds
    
    item = 'joint1'
    
    if cmds.getAttr(item + '.visibility'):
        cmds.select(item)
    

    cmds.getAttr('joint1.visibility') <--- return True if visibility is on. With this condition, the select command will only be call if joint1 is visible.
Sign In or Register to comment.