--dfdsfI somewhat managed to get it working in my following code but was met with another problem...
def fix_multi_shapes_nodes():
all_geos = cmds.ls(sl = True)
for geo in all_geos:
shapes = cmds.listRelatives(geo, fullPath=True, shapes=True)
print len(shapes)
# if it has only 1 shape, no fixing required
if len(shapes) == 1:
continue
# pop out the first shape, since we don't have to fix it
shapes = shapes[1:]
for shape in shapes:
new_transform = cmds.duplicate(shape, parentOnly=True)
cmds.parent(shape, new_transform, addObject=True, shape=True)
cmds.parent(shape, removeObject=True, shape=True)
fix_multi_shapes()Now while I am able to have the shapes nodes to be a individual geometry pieces, however I am getting issues with the naming, in which I am getting 'googleEarth_3342_1_geo', 'googleEarth_3342_1_geo2', ..., 'googleEarth_3342_1_geo22', 'googleEarth_3342_1_geo35' etc..I am trying to get the suffix to be just '_geo' by using .rstrip which is not helping because of the '3342'..This is the command where I do for the renaming:
sel_list = cmds.ls(sl=True)
for ind in sel_list:
new = re.sub(r'\d*$','', ind)
cmds.rename(ind, new)
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_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b93873a2-3e84-49cf-87db-1440f65cbde0%40googlegroups.com.