Maya Python Rename joints

Maya Python Rename joints

danispag
Enthusiast Enthusiast
5,082 Views
6 Replies
Message 1 of 7

Maya Python Rename joints

danispag
Enthusiast
Enthusiast

I have a joint chain and I would like to duplicate it twice and rename the 2 duplicate chains with _IK_ and _FK_ suffixes. My problem is that both chain are being renamed with the same suffix, in this case '_IK_'

can anyone help me with this please?

 

Code below and image attached (for better reference):

 

for index in range(0,2):
mylist = cmds.duplicate(rr=1, st=1)

if index == 0:
pm.mel.searchReplaceNames("result", "IK", "hierarchy")

if index > 0:
pm.mel.searchReplaceNames("result", "FK", "hierarchy")

0 Likes
Accepted solutions (2)
5,083 Views
6 Replies
Replies (6)
Message 2 of 7

rajasekaransurjen
Collaborator
Collaborator
Accepted solution

Hi,

Try this....

import maya.cmds as cmds
import maya.mel as mel


for index in range(0,2):
    mylist = cmds.duplicate(rr=1, st=1)

    if index == 0:
         mel.eval('searchReplaceNames "result" "IK" "hierarchy";')

    if index > 0:
         mel.eval('searchReplaceNames "IK" "FK" "hierarchy";')
Message 3 of 7

danispag
Enthusiast
Enthusiast

that's great. thanks so much.

However the parent joints end with a number eg: left_thigh_IK_JNT1  &  left_thigh_FK_JNT2.

is there a way to remove them?

0 Likes
Message 4 of 7

rajasekaransurjen
Collaborator
Collaborator
Accepted solution

Hi,

Try This...

import maya.cmds as cmds
import maya.mel as mel


for index in range(0,2):
    
    if index == 0:
        mylist = cmds.duplicate(rr=1, st=1, n='left_thigh_IK_JNT')
        mel.eval('searchReplaceNames "result" "IK" "hierarchy";')

    if index > 0:
        mylist = cmds.duplicate(rr=1, st=1, n='left_thigh_FK_JNT')
        mel.eval('searchReplaceNames "IK" "FK" "hierarchy";')
Message 5 of 7

danispag
Enthusiast
Enthusiast

it actually worked :D. Thanks sooo much

0 Likes
Message 6 of 7

rajasekaransurjen
Collaborator
Collaborator

You're welcome.

Message 7 of 7

Anonymous
Not applicable

Thank you!!!

0 Likes