Maya 2024 Multiple Skin Clusters Python?

With Maya 2024 comes the feature of multiple Skin Clusters on one mesh but when trying to script and add a skin cluster with python Maya it comes up with the error: # RuntimeError: Selected geometry human_arm is already connected to a skinCluster. Is there a way to bypass this error ?

If you want to add multiple skin clusters to a mesh, a straightforward approach is to manually create them using “cmds.createNode” rather than “cmds.skinCluster”. The reason is that “cmds.skinCluster” has a built-in check for preexisting skin clusters, which will interfere with your intention to create multiple clusters. Therefore, by directly using “cmds.createNode”, you bypass this check and can create multiple skin clusters as needed.

import maya.cmds as cmds

def add_empty_skin_cluster(mesh, name):

    # Create a new skin cluster node without any influences or connections
    new_skin_cluster = cmds.createNode('skinCluster', name=name)

    # Get the shape node of the mesh
    mesh_shape = cmds.listRelatives(mesh, shapes=True, noIntermediate=True)[0]

    # Connect the mesh's worldMesh to the new skin cluster's inputGeometry
    cmds.connectAttr(f'{mesh_shape}.worldMesh[0]', f'{new_skin_cluster}.input[0].inputGeometry', force=True)

    # Connect the mesh's worldMatrix to the new skin cluster's bindPreMatrix
    cmds.connectAttr(f'{mesh}.worldMatrix[0]', f'{new_skin_cluster}.bindPreMatrix[0]', force=True)

    return new_skin_cluster

# Example:
selection = cmds.ls(sl = True)
skin_cluster_name = 'empty_skinCluster'

empty_skin_cluster = add_empty_skin_cluster(selection, skin_cluster_name)

Any additional functionality that you want to add can be created by connecting the attributes of the new skin clusters.

I hope this was helpful :slight_smile: !

1 Like