Skinning¶
Bind Skin¶
Functions for skin binding
Examples # bindskin hierarchy (closest distance) from zoo.libs.maya.cmds.skin import bindskin bindskin.bindSkinSelected(toSelectedBones=False, maximumInfluences=5, maxEditLimit=5, bindMethod=0, displayMessage=True)
# bindskin selected (closest distance) from zoo.libs.maya.cmds.skin import bindskin bindskin.bindSkinSelected(toSelectedBones=True, maximumInfluences=5, maxEditLimit=5, bindMethod=0, displayMessage=True)
# bindskin selected rigid bind (closest distance) from zoo.libs.maya.cmds.skin import bindskin bindskin.bindSkinSelected(toSelectedBones=True, maximumInfluences=0, maxEditLimit=5, bindMethod=0, displayMessage=True)
# bind skin heat map from zoo.libs.maya.cmds.skin import bindskin bindskin.bindSkinSelected(bindMethod=2)
#bind skin geodesic from zoo.libs.maya.cmds.skin import bindskin bindskin.bindSkinSelected(bindMethod=3)
# mirror x to -x from zoo.libs.maya.cmds.skin import bindskin bindskin.mirrorSkinSelection(mirrorMode=’YZ’, mirrorInverse=False)
# mirror -x to x from zoo.libs.maya.cmds.skin import bindskin bindskin.mirrorSkinSelection(mirrorMode=’YZ’, mirrorInverse=True)
# remove influence from zoo.libs.maya.cmds.skin import bindskin bindskin.removeInfluenceSelected()
# transfer skin weights zoo from zoo.libs.maya.cmds.skin import bindskin bindskin.transferSkinWeightsSelected()
# add joints to skin cluster from zoo.libs.maya.cmds.skin import bindskin bindskin.addJointsToSkinnedSelected()
# unbind skin from zoo.libs.maya.cmds.skin import bindskin bindskin.unbindSkinSelected()
# duplicate mesh before bind - orig shape duplicate from zoo.libs.maya.cmds.skin import bindskin bindskin.duplicateSelectedBeforeBind()
# change skin method to weight belnded (dual quat) from zoo.libs.maya.cmds.skin import bindskin bindskin.skinClusterMethodSwitch(skinningMethod=2, displayMessage=True)
# copy skin weights to the clipboard (mesh name is cpied and must be in scene for paste) from zoo.libs.maya.cmds.skin import bindskin bindskin.copySkinWeightsSel()
# paste skin weights from the copied mesh, see copySkinWeightsSel() from zoo.libs.maya.cmds.skin import bindskin bindskin.pasteSkinWeightsSel()
- hammerWeights()¶
- getAllSkinClusters(displayMessage=False)¶
Returns all valid skin clusters in a scene
- Parameters:
displayMessage (bool) – Report the message inside of maya?
- Return skinClusterList:
List of the skin cluster node names
- Rtype skinClusterList:
list
- checkValidOrigShape(mesh, deleteDeadShapes=False, displayMessage=False)¶
Checks for valid orig shape nodes, by checking if multiple orig shapes are present or that the object isn’t skinned or has no orig shape nodes returns the the orig shape node name or None on fail
- checkValidOrigShapeList(meshList, deleteDeadShapes=False, displayMessage=False)¶
List version of the function checkValidOrigShape
- cleanDeadOrigShapesSelected(displayMessage=True)¶
Cleans the unused original shape nodes from selected mesh Nodes are likely intermediate objects with no output connections, usually left over and unused nodes
- Parameters:
displayMessage (bool) – Report the message inside of maya?
- duplicateMeshBeforeBind(mesh, fullPath=True, suffix='_duplicate', message=True, deleteDeadShapes=False, transferShader=True)¶
Given a mesh will duplicate it ignoring the skinning, does this via the original shape node. Will fail if mesh isn’t skinned or no orig node
- Parameters:
mesh (str) – The mesh name to be duplicated
fullPath (bool) – return full path names not short
suffix (str) – The suffix to add to the duplicated mesh
message (bool) – Report the message inside of maya?
transferShader (bool) – Transfer the shader from the skinned mesh so that the new duplicate matches?
- Return duplicateMesh:
the name of the duplicated mesh
- Return type:
- duplicateSelectedBeforeBind(fullPath=True, suffix='_duplicate', message=True, selectDuplicate=True, transferShader=True)¶
Duplicates selected mesh/es before a skin cluster has been added, pre bind. Will fail if no skinning is present. Works by finding the original shape node and duplicating it
- Parameters:
- Return duplicatedMeshes:
a list of the duplicated mesh names
- Return type:
list
- combineSkinnedMeshes(objList, constructionHistory=False, centerPivot=True, mergeUVSets=True)¶
Combines meshes that have been skinned, joins them into one skinned object.
- Parameters:
- Return mesh:
The combined mesh name
- Rtype mesh:
str
- Return skinCluster:
The combined skin cluster name
- Rtype skinCluster:
str
- combineSkinnedMeshesSelected(constructionHistory=False, centerPivot=True, mergeUVSets=True, message=True)¶
Combines selected meshes that have been skinned, joins them into one skinned object.
- getSkinCluster(obj)¶
Checks if the given object has a skin cluster using mel, (doesn’t have a python equivalent). Long or short names must be converted to unique names, see namehandling.getUniqueShortName() documentation Returns empty string if no skin cluster found on object
- Parameters:
obj (str) – Maya obj name, usually a transform node, best if a long or unique name
- Return skinCluster:
The name of the skin cluster, or if not found/skinned will be an empty string “”
- Rtype skinned:
str
- getSkinClusterList(objList)¶
Returns a list of skin clusters from an objList
- Parameters:
objList (list) – Maya obj name list
- Return skinClusterList:
list of skin clusters
- Rtype skinClusterList:
list
- getSkinClustersSelected()¶
Find all the skin clusters related to selected objects (transforms) Works off the first shape node and selected must be the transform/s
- getJnts(objList)¶
returns only joints from an object list
- Parameters:
objList (list) – list of object names
- Return jntList:
List of joint names
- Rtype jntList:
list
- getSkinClusterFromJoint(joint)¶
Returns all skin clusters connected to a single joint
- Parameters:
joint (str) – A single joint name
- Return skinClusterList:
A list of skin clusters, will be empty if none found
- Rtype skinClusterList:
list(str)
- getSkinClustersFromJoints(jointList)¶
Returns all skin clusters connected to a joint list
- Parameters:
jointList (list(str)) – A list of Maya joint names
- Return skinClusterList:
A list of skin clusters, will be empty if none found
- Rtype skinClusterList:
list(str)
- filterSkinnedJoints(jointList)¶
Returns all skinned joints from a joint list. Found by seeing connected skin clusters to joint.worldMatrix
- Parameters:
jointList (list(str)) – A list of joints
- Return skinnedJointList:
A list of skinned joints
- Rtype skinnedJointList:
list(str)
- filterSkinnedMeshes(objList)¶
Returns meshes that are skinned from a list
- Parameters:
objList (list) – list of Maya object names
- Return skinnedMeshes:
list of skinned meshes
- Rtype skinnedMeshes:
list
- filterMeshes(objList, skinned=False)¶
Returns meshes/surfaces and joints that are ready for skinning from the list of objects
Tests for issues and reports errors
- Parameters:
objList (list(str)) – list of maya objects/nodes
- Return meshList:
list of mesh names, empty list if none
- Rtype meshList:
list(str)
- filterObjsForSkin(objList)¶
Returns meshes/surfaces/curves and joints that are ready for skinning from the list of objects
Tests for issues and reports errors
- skinClusterMethodSwitch(skinningMethod=2, displayMessage=True)¶
Switches the attribute .skinningMethod for all skinClusters on selected objects
- unbindSkinObjs(objList)¶
Python version of Maya’s unbind skin, this function is for an object list
- unbindSkinSelected()¶
python version of unbind skin on selected
- bindSkin(joints, meshes, toSelectedBones=True, maximumInfluences=5, maxEditLimit=5, bindMethod=0, displayMessage=True)¶
Skins meshes to joints based with skin variables
- Parameters:
toSelectedBones (bool) – on binds to selected off binds to hierarchy
maxInfluences (int) – 5 is default, 1 is a rigid bind, limits the amount of joint influences
maxEditLimit (int) – is after the weights have been assigned so influences can be set differently for skin editing
bindMethod (int) – closest distance = 0, hierarchy = 1, heat = 2 and geodesic = 3
displayMessage (bool) – Report the message inside of maya?
- bindSkinSelected(toSelectedBones=True, maximumInfluences=5, maxEditLimit=5, bindMethod=0, displayMessage=True)¶
Binds skin to mesh or meshes based off selection similar to the regular Maya behaviour. No in built cmds version
- Parameters:
toSelectedBones (bool) – on binds to selected off binds to hierarchy
maxInfluences (int) – 5 is default, 1 is a rigid bind, limits the amount of joint influences
maxEditLimit (int) – is after the weights have been assigned so influences can be set differently for skin editing
displayMessage (bool) – Report the message inside of maya?
- Param:
bindMethod: 0 = distance = 1 = hierarchy, 2 = heat, 3 = geodesic
- setMaxInfluencesOnSkinCluster(skinCluster, maxInfluences=4)¶
for a skin cluster set the max influences and turn maintain on
- setMaxInfluencesOnSkinClusterList(skinClusterList, maxInfluences=4)¶
- setMaxInfluencesOnSkinSelected(maxInfluences=4)¶
- checkInfluenceObj(obj, skinCluster)¶
Checks if an object is an influece of a skin cluster
- renameSelSkinClusters(suffix='skin')¶
Renames the skin clusters based off the selected object
- Parameters:
suffix (str) – skin cluster of pCube1 will be named pCube1_skin
- removeInfluence(objList, skinCluster)¶
Removes Influence Objects from a Skin Cluster Checks if influences are valid Returns object list of influences removed
- Parameters:
objList – the list of influence objects to be removed
skinCluster (str) – The skin luster name
- Return removedInfluenceList:
list of influence objects removed
- Return type:
list
- removeInfluenceSelected()¶
Removes influence objects from a skinned mesh. Last selected object should be the skinned mesh, other objects are the influences Will check for user error
- addJointsToSkinned(jointList, skinClusterList)¶
Adds joints as new influences to a skin cluster Select the mesh/es with skin cluster and the joints to assign jnts are assigned with zero weighting and do not affect existing weights
should check this no need for try
- addJointsToSkinnedSelected(displayMessage=True)¶
Adds joints to a skinned mesh, keeps the joints with a zero influence value
- Parameters:
displayMessage (bool) – Report the message inside of maya?
- disableSkinCluster(skinCluster)¶
Disables a single skin cluster
- Parameters:
skinCluster (str) – A single skin cluster name
- disableSkinClusterList(skinClusterList, displayMessage=True)¶
Disables a skin cluster list turning the node state to hasNoEffect (1)
- Parameters:
skinClusterList (list) – List of the skin cluster node names
displayMessage (bool) – Report the message inside of maya?
- renableSkinCluster(skinCluster)¶
Renables a disabled skin cluster by rebinding it, only works in mel, Maya trick.
Might be able to use resetInfluenceMatrices(skinCluster) instead
- Parameters:
skinCluster (str) – A single skin cluster name
- resetInfluenceMatrices(skinCluster)¶
Set bindPreMatrix the same as current worldInverseMatrix for each influence of given skinCluster
Credit http://syntetik.blogspot.com/2010/10/bindprematrix-in-skincluster.html
- Parameters:
skinCluster (str) – A single skin cluster name
- renableSkinClusterList(skinClusterList, displayMessage=True, keepSelection=True)¶
Re enables a skin cluster list that have previously had their nodestate set to hasNoEffect (1)
- toggleSkinCluster(skinCluster)¶
Toggles a single skin cluster node
- Parameters:
skinCluster (str) – A single skin cluster name
- toggleSkinClusterList(skinClusterList, displayMessage=True)¶
Toggles on/off a skin cluster list. Toggles off the state of the first skin cluster.
- toggleSkinClusterListSelected(displayMessage=True)¶
Toggles on/off the selected skin clusters from a mesh selection.
Toggles off the state of the first skin cluster.
- Parameters:
displayMessage (bool) – Report the message to the user?
- toggleAllSkinClusters(displayMessage=True)¶
Toggles all skin clusters in a scene Handy for quick move pivots on joints Uses the nodeState attribute on the cluster
Switching the nodestate to 1 (hasNoEffect) disables the skin cluster like a temp skin unbind without data loss
Maya trick by selecting any joint and the mesh of the existing skin cluster and > bind skin
Will return the cluster on skinning essentially skinning it at the current mesh/joint position
- copySkinWeightsSel(message=True)¶
Copies a skinned mesh and tracks it with a class singleton so it can be pasted later.
- pasteSkinWeightsSel(message=True)¶
Pastes the skinning from the copied mesh (in singleton skinInstance.copiedSkinMesh) to selected geo.
The new selection can be meshes or faces/verts/edges.
- transferSkinning(sourceMesh, targetMesh)¶
Transfers skin weights from the source mesh to the target, if the target already has a skin cluster will use the current
- transferSkinWeightsSelected()¶
Transfers skin weights from the first selected object to other objects iterates through a list so the transfer is from the first object selected to all other objects
- mirrorSkinClusterList(skinClusterList, surfaceAssociation='closestPoint', influenceAssociation='closestJoint', mirrorMode='YZ', mirrorInverse=False)¶
Mirrors Skin Clusters
- Parameters:
surfaceAssociation (str) – which surface style to mirror, “closestPoint”, “rayCast”, or “closestComponent”
influenceAssociation (str) – choose joint style to mirror “closestJoint”, “closestBone”, “label”, “name”, “oneToOne”
mirrorMode (str) – which plane to mirror over, XY, YZ, or XZ
mirrorInverse (bool) – Reverse the direction of the mirror. if true - to +
- mirrorSkinMeshList(objList, surfaceAssociation='closestPoint', influenceAssociation='closestJoint', mirrorMode='YZ', mirrorInverse=False)¶
Mirrors Skin Weights from skin clusters connected to the objects in the objList
- Parameters:
objList (list) – List of Maya Object Names
surfaceAssociation (str) – which surface style to mirror, “closestPoint”, “rayCast”, or “closestComponent”
influenceAssociation (str) – choose joint style to mirror “closestJoint”, “closestBone”, “label”, “name”, “oneToOne”
mirrorMode (str) – which plane to mirror over, XY, YZ, or XZ
mirrorInverse (bool) – Reverse the direction of the mirror. if true - to +
- Return skinClusterList:
list of the skin clusters mirrored
- Rtype skinClusterList:
list
- mirrorSkinSelection(surfaceAssociation='closestPoint', influenceAssociation='closestJoint', mirrorMode='YZ', mirrorInverse=False)¶
Mirrors Skin Weights from skin clusters assigned to the current meshes or joints Selections as object transforms
- Parameters:
surfaceAssociation (str) – which surface style to mirror, “closestPoint”, “rayCast”, or “closestComponent”
influenceAssociation (str) – choose joint style to mirror “closestJoint”, “closestBone”, “label”, “name”, “oneToOne”
mirrorMode (str) – which plane to mirror over, XY, YZ, or XZ
mirrorInverse (bool) – Reverse the direction of the mirror. if true - to +
Skin Replace Joints¶
from zoo.libs.maya.cmds.skin import skinreplacejoints skinreplacejoints.replaceJointsMatrixSuffix(boundText=”oldJnt”, replaceText=”newJnt”, prefix=False, message=True)
- replaceSkinMatrixJoint(boundJoint, replaceJoint, message=True)¶
Swaps the binding of a joint and replaces the bind to another joint.
Useful while swapping the skinning from one skeleton to another.
The skinning is swapped based on the matrix positions, so if the joint is in new locations the mesh may move.
- replaceSkinJointMatrixList(boundJoints, replaceJoints, filterSkinnedJoints=True, message=False)¶
Swaps the binding of a list of joints and replaces the bind to another list of joints.
Useful while swapping the skinning from one skeleton to another.
The skinning is swapped based on the matrix positions, so if joints are in new locations the mesh may move.
- replaceSkinJoints(obj, old_jnts, new_jnts)¶
Swaps the binding of a list of joints and replaces the bind to another list of joints. (untested)
Uses maya’s cmds.skinPercent(“skinCluster1”, tmw=[old, new]) to do the transfer
- replaceJointsMatrixSuffix(boundText='oldJnt', replaceText='newJnt', prefix=False, message=True)¶
Swaps the binding of a list of joints and replaces the bind to another list of joints from scene suffix/prefix.
- Parameters:
- Return success:
True if the transfer was successful
- Rtype success:
bool