Is there a way to return selected objects in Mayas Shape editor?

319 views
Skip to first unread message

GerardVOK

unread,
May 31, 2019, 1:28:39 AM5/31/19
to Python Programming for Autodesk Maya


Hi all.


I am writing a tool to construct a techAnim working scene for my tech artists. I want to simply create some groups in the shape editor and place new blendshapes under these. I also want to be able to rename a selected target or targets in the shape editor via a script.


There is nothing exposed to the user to allow one to script the grouping of one or more blendshapes in the shape editor.  I can not assume that there are no preexisting blendshapes or groups already created.

 

mc.getAttr('shapeEditorManager.blendShapeDirectory', mi=True)  gives logical indices.. If there are spaces between the indices due to groups and blendshapes being deleted then this is useless. If I create a group mc.ShapeEditorNewGroup()  then this doesnt necessarily add to the end of this array of indices so I cant simply assume its the last in the index. This command cant take in a name to give to the group, and worse doesnt return anything at all to identify the index used. If it did I could move on with this. I cant yet  understand the pattern in the choice of index Maya uses. I have taken a brief look at the Api but nothing yet seems obvious.

Anyone out there with ideas? Simple question how can I return selected items in the shape editor in order to rename them or group them?


Thanks

Gerard.

AK Eric

unread,
Jun 25, 2019, 12:05:26 AM6/25/19
to Python Programming for Autodesk Maya
Yep, it's not "obvious".   My notes are here:

I use pymel simply because it makes optionVars convenient.
Snip:

import pymel.core as pm
selData = [item for item in pm.optionVar["blendShapeEditorTreeViewSelection"] if item][0].split("/")
bsIndices = []
for item in selData:
    if not item:
        continue
    bsNode, index = item.split(".")
    bsIndices.append((bsNode, int(index)))

print bsIndices
[(u'blendA', 0), (u'blendA', 1), (u'blendA', 2), (u'blendB', 0)]
Reply all
Reply to author
Forward
0 new messages