python - Making the name of shape node to be the same as the parent -
how can make name of shape node have similar name parent node? (assuming there 1 shape node per geometry/object)
for eg. parent_geo called test_geo1
, shape node testing_geo2shape
instead of test_geo1shape
i tried doing following:
all = cmds.ls(sl=true, dag=true, shapes=true) shape in all: prt = cmds.listrelatives(shape, parent=true) in prt: child = cmds.listrelatives(i, c = true) c in child: cmds.rename(c, str(prt) + "shape")
and funky names such u_test_geo1__shape
etc
all = cmds.ls(sl=true, dag=true, shapes=true) shape in all: ''' shape contain dag path exm.: grp_a grp_ashape grp_b grp_bshape print cmds.ls('grp_a', dag=1, shapes=1) >>('grp_a|grp_ashape', 'grp_b|grp_bshape') rename object, have dag path input of rename command unique, can split dag path '|'[0] parent ''' cmds.rename(shape, "{0}shape".format(cmds.listrelatives(shape, parent=true)[0]))
tested hierarchy like:
grp_a shape grp_a grp_b same name shape grp_c grp_c shape grp_c grp_d same name shape grp_c grp_e same name shape grp_c
select top grp
Comments
Post a Comment