← Back to maya
Batch Rename Skin Clusters in Maya Using Python
25 Apr 26 (1mo ago)
I rename my DAG objects religiously. But the actual nodes? No, not really. The exception is when I'm trying to use mGear Export/Import Skin Weights, an absolute life saver. Helps identify which object's skinCluster I am manually editing on a text file, which actually happens more often than you think.
Without renaming, you'd have to wrangle on endless and useless skinCluster1, skinCluster5 names.
import maya.cmds as cmds
def rename_skin_clusters_on_selection():
selected_objects = cmds.ls(selection=True) or []
if not selected_objects:
cmds.warning("Please select at least one object.")
return
for obj in selected_objects:
history = cmds.listHistory(obj) or []
skin_clusters = cmds.ls(history, type="skinCluster")
if skin_clusters:
current_skin_cluster = skin_clusters[0]
new_name = f"{obj}_skinCluster"
if current_skin_cluster != new_name:
try:
cmds.rename(current_skin_cluster, new_name)
print(f"Success: '{current_skin_cluster}' renamed to '{new_name}'")
except Exception as e:
cmds.warning(f"Could not rename skinCluster on '{obj}'. Error: {e}")
else:
print(f"Skipped: '{obj}' already has a skinCluster named '{new_name}'")
else:
print(f"Ignored: No skinCluster found on '{obj}'.")
rename_skin_clusters_on_selection()