in Programmer by
Like to query or edit the selection member of selection button? The attribute of the attribute button, etc?

1 Answer

0 votes
by
selected by
 
Best answer

For all the picker button queries and edits, you use MGPickerItem command, something like:

from maya import cmds
cmds.MGPickerItem(selButtonId, q=True, selectMembers=True)

You can get the id from the top-left corner of Attribute Editor panel and hard code them in command call, or you can name the button, and get id from the name.

Different buttons can share the same name, but ID is unique, so when you query or edit data, you need the ID.

To name the button, just select them, and input name in the name field. You can assign a name to a single button or multiple buttons at the same time this way.

Now, to get the button ID from the name:

from maya import cmds
matchedBtns = cmds.MGPickerView(q=True, getIdFromName='mySelectBtn')
if matchedBtns:
    members = cmds.MGPickerItem(matchedBtns[0], q=True, selectMembers=True)
    print (members)

Notice that we didn't specify the view id when using the MGPickerView command, which means we are dealing with the active view.

To get the view id so you are not only able to query or edit the active view but any views, please check out the MGPickerView command reference link below.

The reference for MGPickerView command

The reference for MGPickerItem command

Categories

...