Skip to content

Instantly share code, notes, and snippets.

@jakecraige
Last active November 15, 2015 15:50
Show Gist options
  • Save jakecraige/1b25a99238479d3ce5a0 to your computer and use it in GitHub Desktop.
Save jakecraige/1b25a99238479d3ce5a0 to your computer and use it in GitHub Desktop.
Maya - Joint Hierarchy Alphabetical Renamer
import maya.cmds as mc
window = mc.window(title="Joint Hierarchy Renamer", widthHeight=(500, 55))
mc.columnLayout(adjustableColumn=True)
mc.text(label="Instructions: select top of joint hierarchy")
textField = mc.textFieldButtonGrp(label="New name prefix:", buttonLabel="Rename", buttonCommand="rename_joints()")
mc.showWindow(window)
def rename_joints():
joint_prefix = mc.textFieldButtonGrp(textField, text=1, q=1)
def joint_name(idx):
return joint_prefix + "_" + chr(ord("a") + idx) + "01"
selected_joint = mc.ls(sl=True, type="joint")
mc.select(selected_joint, hierarchy=True)
joint_hierarchy = mc.ls(sl=True, type="joint")
joint_hierarchy.reverse()
for idx, jnt in enumerate(joint_hierarchy, start=1):
new_name = joint_name(len(joint_hierarchy) - idx)
mc.rename(jnt, new_name)
mc.deleteUI(window, window=True)
@jakecraige
Copy link
Author

This is great for renaming finger hierarchies or any hierarchy that you want to rename down the chain with a constant prefix with alphabetical names.

Ex:

  1. Select top joint of index finger
  2. Run script
  3. Enter bind_l_index and click "Rename"
  4. All joints are renamed like:
    • bind_l_index_a01
    • bind_l_index_b01
    • etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment