-
-
Save Onefabis/76d0c23c0a8755b40809 to your computer and use it in GitHub Desktop.
Maya - Joint Hierarchy Alphabetical Renamer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: