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 orig shape node name or None on fail
- checkValidOrigShapeList(meshList, deleteDeadShapes=False, displayMessage=False)¶
List version of the function checkValidOrigShape
- cleanDeadOrigShapes(objs, displayMessage=True)¶
- 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:
- 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.
- geoFromSkinCluster(skinCluster, transforms=True)¶
Returns the geometry from a skin cluster
- 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
- filterSkinnedJoints(jointList)¶
Returns all skinned joints from a joint list. Found by seeing connected skin clusters to joint.worldMatrix
- 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
- 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
- jointsFromSkinCluster(skinCluster)¶
Returns the joints from a skin cluster
- jointsFromSkinClusters(skinClusters)¶
Returns the joints from a skin cluster
- selJointsFromSelMeshes(message=True)¶
Selects joints from the selected mesh/es
- unlockAttrsOldSkinCluster(obj)¶
In newer versions of Maya does not unlock the skinCluster from old versions, and only works in mel
- Parameters:
obj (str) – A maya object name
- unbindSkinObjs(objList, message=True)¶
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
- renameSkinClusters(objs, suffix='skin', message=False)¶
Renames the skin clusters based off the given object names
- renameSelSkinClusters(suffix='skin', message=True)¶
Renames the skin clusters based off the selected object
- removeInfluence(influenceList, skinCluster)¶
Removes Influence Objects from a Skin Cluster, usually joints. Checks if influences are valid Returns object list of influences removed
- 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?
- setBindPoseSel(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?
- setBindPose(skinNodes, freeze=False)¶
Sets the bind pose for a skin cluster or skin clusters.
- Parameters:
- Return skinClusterList:
A list of skin cluster node names that were set to bind pose
- Rtype skinClusterList:
list(str)
- freezeJoints(joints)¶
Freezes the joint transforms and sets the jointOrient to zero.
- disableSkinCluster(skinCluster)¶
Disables a single skin cluster
(deprecated by setBindPose)
- Parameters:
skinCluster (str) – A single skin cluster name
- disableSkinClusterList(skinClusterList, displayMessage=True)¶
Disables a skin cluster list turning the node state to hasNoEffect (1)
(deprecated by setBindPose)
- 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)
(deprecated by setBindPose)
- 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.
- toggleAllSkinClusters(displayMessage=True)¶
Toggles all skin clusters in a scene (deprecated by setBindPose) 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
- transferSkinningDuplicates(suffix='_duplicate')¶
Automatically transfers skinning to a duplicate set usually named with a suffix “_duplicate”
Select skinned objects and then run the function.
- 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)
- createSkinTransferNetworkNode()¶
Creates the skin transfer network node if it doesn’t exist, returns the node name
- deleteSkinTransferNode()¶
Deletes the mocap network node if it exists
- saveTransferDataToScene(sourceDict, targetDict)¶
Sets the skin transfer data to the scene by saving it to a network node as string attributes.
- importTransferDataFromScene(message=True)¶
Returns the match and bake data from the scene, returns the source and target dictionaries
- Returns:
The source and target columns of the skin transfer data as dicts
- Return type:
sourceDict, targetDict
- replaceSkinMatrixJoint(boundJoint, replaceJoint)¶
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.
Bound joint must be verified as existing and being part of a skin cluster.
- replaceSkinJoint(boundJoint, replaceJoint, unbindSource=True, skipSkinClusters=())¶
Swap/replace the binding of a joint and replaces the bind to another joint.
Uses the lock weights method for doing the swap and is faster than the replaceSkinJointSlow method.
- replaceSkinJointSlow(boundJoint, replaceJoint, unbindSource=True)¶
Swaps the binding of a joint and replaces the bind to another joint.
Bound joint must be verified as existing and being part of a skin cluster.
- replaceSkinJointList(boundJoints, replaceJoints, moveWithJoints=False, unbindSource=True, skipSkinClusters=(), message=False)¶
Swaps the binding of a list of joints and replaces the bind to another list of joints.
Bound joints must be verified as existing and being part of a skin cluster.
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.
- Parameters:
boundJoints (list(str)) – A list of joints bound to a skin cluster
replaceJoints (list(str)) – A list of joints to be switched to connect to the skin cluster
moveWithJoints (bool) – If True will move the joints to the new joint positions
unbindSource (bool) – Unbind the source joints from the skin cluster
skipSkinClusters (list(str)) – A list of skin clusters to skip
message (bool) – Report the message to the user
- 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
- replaceJointsMatrixSel(message=True)¶
Swaps the binding of the first half of selected joints and replaces them with the binding of the second half.
- Parameters:
message (bool) – Report a message to the user?
- class ReplaceJointsWeights(sourceBoundJnts, targetJnts, skipSkinClusters=(), moveWithJoints=False, unbindSource=True, sourceNamespace='', targetNamespace='', sourcePrefix='', targetPrefix='', sourceSuffix='', targetSuffix='', autoLeftToRight=True, sourceLeftIdentifier='_L', sourceRightIdentifier='_R', sourceLRIsPrefix=False, sourceLRIsSuffix=False, sourceLRSeparatorOnBorder=False, targetLeftIdentifier='_L', targetRightIdentifier='_R', targetLRIsPrefix=False, targetLRIsSuffix=False, targetLRSeparatorOnBorder=False)¶
Bases:
objectClass for transfer/replace the skin weights multiple joints to another joint list.
This class is designed to be used by a UI with rename options.
- Naming Options:
namespace: The obj namespace, eg “characterX”. Colon is handled if included. prefix: Adds a prefix to the object name eg “prefix/_” for prefix_joint1 suffix: Adds a suffix to the object name eg “_suffix” for joint1_suffix
- The class can automatically generate the right side names based on the left side names:
autoLeftToRight: If True will automatically generate the right side names based on the left side names. leftIdentifier: The left side identifier rightIdentifier: The right side identifier LRIsPrefix: The identifier is always at the start of the name. LRIsSuffix: The identifier is always at the end of the name. LRSeparatorOnBorder: Underscores are on either side of the identifier eg “L” will be “_L” or “L/_”