How can I query selected in tool settings/paint in Maya similar to how its done with the channel box

maya

#1

I been trying to find info about this, I want to be able to query the influences I have selected so I can make a script to help with skinning


#2

Just to clarify, do you mean query things like textFields and textScrollLists for their current values and selected items, the way you can use the channelBox command to ask about and set the values in the channelBox?


#3

The channelbox was a example of you can select items and query them, like selecting the XYZ translates of a object then being able to print it. I cant find a way to query what I have selected in the inf’s menu of the paint tools i’ve only figured it out for the inf im painting on.


#4

The Influences list in the Paint Skin Weights tool is a treeView. You can get a list of existing treeViews like this:

cmds.lsUI(type="treeView")

There were two names in my output, and for me, the one we want has the id “theSkinClusterInflList”.

I don’t see a way to query what’s selected in it in the treeView documentation (nor wrap the selection callbacks, as I can’t query them either), but I do see that you can get the children, and you can ask specifically if a child is selected, so we can roll our own get-selected:

def getPaintWeightsWindowSelectedInfls (tv):
    kids = cmds.treeView(tv, query=True, children=True)
    return filter(lambda x: cmds.treeView(tv, query=True, itemSelected=x), kids)

Now I can get the selected children like this:

getPaintWeightsWindowSelectedInfls("theSkinClusterInflList")

Hopefully that answers the question. Feel free to clarify further if not, or ask any follow-up questions.