Hi,
I am trying to duplicate a joint and rename it. Got a hit from @Theodox post from the stack overflow
It works well but I got an error whenever I try to change the “grp1” to “grp”. Which is weird because in the outliner there is a grp1 on the duplicate IK joint group
# Error: No object matches name
# Traceback (most recent call last):
# File "<maya console>", line 20, in <module>
# File "<maya console>", line 18, in hybridIKFK
# RuntimeError: No object matches name #
Here is the code in question
import maya.cmds as mc
def hybridIKFK():
jointBase = 'spine01_jnt_grp'
ikJoint = cmds.duplicate(jointBase, rr=True)
ikJoint += cmds.listRelatives(ikJoint, ad=True, f=True)
longnames = cmds.ls(ikJoint, l=True)
longnames.sort()
for item in longnames[::-1]:
shortname = item.rpartition("|")[-1]
cmds.rename(item, shortname.replace("_jnt", "_IK_con"))
for oldName in ikJoint: # this is the line that throws an error
cmds.rename(oldName, oldName.replace("grp1","grp"))
hybridIKFK()