Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

How to remove shape editor groups via script?

How to remove shape editor groups via script?

chanlon
Participant Participant
2,905 Views
4 Replies
Message 1 of 5

How to remove shape editor groups via script?

chanlon
Participant
Participant

 

One of our scenes is filled with an absurd amount of blend shape groups in the shape editor.  These groups number in the thousands and contain no blend shapes or targets.

 

I'm not clear how they get added as the group names reflect the file (versions) names.  Nothing in our process adds these groups and the setAttr on the shapeEditorManager node uses a somewhat obscure indexing to create the hierarchies.  I have a feeling something in the import process creates these entries, as we get a number of crashes in TDNshapeEditorManager::mergeDirectories on import.  This particular show is using Maya 2016.

 

Anyway, I want to remove them via a Python script, but my script is not working:

 

import maya.cmds as cmds
sz = cmds.getAttr('shapeEditorManager.blendShapeDirectory', s = True)
for i in range(0,sz):
    print 'Removing: {}'.format(i)
    cmds.removeMultiInstance('shapeEditorManager.blendShapeDirectory[{}]'.format(i), b=True)

 

This removes a few of the groups, but not all.  The return value of removeMultiInstance does indicate that the remove failed.

 

Is there another way to remove or clear the blendShapeDirectory attribute?  (other then editing a Maya ascii file)

 

Thanks,
Chris

 

0 Likes
Accepted solutions (1)
2,906 Views
4 Replies
Replies (4)
Message 2 of 5

jordan.giboney
Autodesk Support
Autodesk Support

Hi @chanlon

 

Thanks for posting! I've grabbed this info and will be reaching out to our Development Team about this. I will make sure to post all relevant info as soon as I receive it. 

 

Thanks for your pateince!



Jordan Giboney
Technical Solutions Engineer | Media & Entertainment
Installation & Licensing forums | Contact product support | Autodesk AREA


0 Likes
Message 3 of 5

chanlon
Participant
Participant
Accepted solution

Thanks Jordan!

 

As Stephen pointed it (in your email), the issue was that I wasn't using the logical indices to remove elements from the blendShapeDirectory attribute.  Using the logical indices to remove the elements worked.

 

Python below:

 

import maya.cmds as cmds
sz = cmds.getAttr('shapeEditorManager.blendShapeDirectory', s = True)

if sz > 0:
    logicalIndices = cmds.getAttr('shapeEditorManager.blendShapeDirectory', mi=True)
    # get the size of the array   
    numIndices = len(logicalIndices)
    print "Removing {} groups.".format(numIndices)
    for i in range(0, numIndices):
        # loop through and remove each one..
        cmds.removeMultiInstance('shapeEditorManager.blendShapeDirectory[ {} ]'.format( logicalIndices[i] ) )
    print "Finished."

0 Likes
Message 4 of 5

jordan.giboney
Autodesk Support
Autodesk Support

Hi @chanlon

 

Thanks for updating this post with your findings! Glad to hear that you and Stephen were able to figure it out and reconnect 🙂

 

Best of luck with your projects, and please do not hesitate to reach out if another need arises. Have a great day!



Jordan Giboney
Technical Solutions Engineer | Media & Entertainment
Installation & Licensing forums | Contact product support | Autodesk AREA


Message 5 of 5

gvok
Enthusiast
Enthusiast

Hello. I'm hoping I can piggy back from this thread for a problem that I have been having with the shape editor. I hope that you could offer me some kind of approach as I'm hitting the wall...

 

I need to script what should be 3 pretty straight forward things.

 

1) With a target selected in the shape editor UI I need to create a function that can rename the selected target or targets (in this case combining a frame number and a user defined name)

 

2)  with a list of blendshapes that I have created in a function, I need to take these and group them in the shape editor - via a script

 

3) I need to be able to query a group (in the shape editor) by name and add other blendshapes (newly created ones) to the group. 

 

If you have any ideas I would really appreciate the help. 

 
Here's a bit of a background to the issues..
 

 

I've run into a super frustrating issue that should have only taken minutes but I have spent hours on it so far with nothing to show. I am writing a tool to construct a techAnim working scene for my tech artists, and I want to simply create some groups in the shape editor and place new blendshapes under these.

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.

Any  ideas?

Thanks

Gerard van Ommen Kloeke

Tech Anim Lead - Mill Film, Adelaide.

0 Likes