import string
shapes = cmds.ls(shapes=True) # List shapes in scene
nonUniqueShapes = [n for n in shapes if '|' in n] # Find all non-unique shape nodes
nonUniqueShapes.sort(key=lambda x : x.count('|'), reverse=True) # Reverse list (children first)
for shape in nonUniqueShapes: # Rename
cmds.rename(shape, '{0}#'.format(shape.rpartition('|')[-1].rstrip(string.digits)))import maya.cmds as cmds
transforms = cmds.ls(transforms=True) # List transforms in the scene
for transform in transforms:
shapes = cmds.listRelatives(transform, shapes=True, noIntermediate=True) # Find the shapes from each transform (intermediate nodes not included)
if shapes is not None and len(shapes) > 1: # If the transform has multiple shapes..
cmds.delete(shapes[1:]) # Delete all but the first shape
On Fri, 12 Jun 2015 8:44 PM mjlefevre <matthew....@gmail.com> wrote:
* deleted my original reply because it had syntax errors..is there any way to edit posts? :)
moderators can edit posts.. but seeing as it is a mailing list... people have already received it in mail form :-)
Hey,
This might work. But are all the shapes duplicates? If not you would need to discern which shape you want to keep and which to delete.
import maya.cmds as cmds
transforms = cmds.ls(transforms=True) # List transforms in the scene
for transform in transforms:
shapes = cmds.listRelatives(transform, shapes=True, noIntermediate=True) # Find the shapes from each transform (intermediate nodes not included)
if shapes is not None and len(shapes) > 1: # If the transform has multiple shapes..
cmds.delete(shapes[1:]) # Delete all but the first shape
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/99b8363b-1798-4a58-b151-f0cfae0e625d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I sometimes wish I could edit an email I've sent. Maybe in the future? =)
--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/G0_ug0QEjug/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODr-KEW%2BDdk1g2-3fdUfh_y%3D_%3DdDXG2sjO9nLzTpmxpBQ%40mail.gmail.com.