Go to: Synopsis. Return value. Keywords. Related. Flags. Python examples.
skeletonEmbed([mergedMesh=boolean], [segmentationMethod=uint], [segmentationResolution=uint])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
skeletonEmbed is undoable, queryable, and NOT editable.
This command is used to embed a skeleton inside meshes.None
In query mode, return type is based on queried flag.
Long name (short name) | Argument types | Properties | ||
---|---|---|---|---|
mergedMesh(mm)
|
boolean
|
|||
|
||||
segmentationMethod(sm)
|
uint
|
|||
|
||||
segmentationResolution(sr)
|
uint
|
|||
|
Flag can appear in Create mode of command | Flag can appear in Edit mode of command |
Flag can appear in Query mode of command | Flag can have multiple arguments, passed either as a tuple or a list. |
import maya.cmds as cmds # First select the shape, not the transform. cmds.select( 'characterShape' , r=True ) # Embed skeleton using default parameter. cmds.skeletonEmbed( ) # Result: u'{ [...] (A JSON dictionary with the description of the embedding. }' # # For debugging: get the merged mesh that will be used cmds.skeletonEmbed( query=True , mergedMesh=True ) # Result: u'{ [...] (A JSON dictionary with the description of the merged mesh. }' # # Embed skeleton using polygon soup and 512 resolution. cmds.skeletonEmbed( segmentationMethod=3 , segmentationResolution=512 ) # This method creates a few joints to see the embedding. import json def createJointsFromEmbedding( embeddingString ): embedding = json.loads( embeddingString ) for name , position in embedding[ 'joints' ].iteritems( ): joint = cmds.createNode( 'joint' , name=name ) cmds.xform( joint , worldSpace=True , translation=position ) result = cmds.skeletonEmbed( ) createJointsFromEmbedding( result ) # This method creates a mesh from the merged mesh to see it. import json import maya.OpenMaya as OpenMaya def createMeshFromDescription( meshString ): mesh = json.loads( meshString ) meshPoints = mesh[ 'points' ] meshFaces = mesh[ 'faces' ] factor = 1.0 / mesh[ 'conversionFactor' ] # Vertices vertexArray = OpenMaya.MFloatPointArray() for i in range( 0 , len( meshPoints ) , 3 ): vertex = OpenMaya.MFloatPoint( meshPoints[ i ] * factor , meshPoints[ i + 1 ] * factor , meshPoints[ i + 2 ] * factor ) vertexArray.append( vertex ) numVertices = vertexArray.length() # Faces polygonCounts = OpenMaya.MIntArray() polygonConnects = OpenMaya.MIntArray() for face in meshFaces: for i in face: polygonConnects.append( i ) polygonCounts.append( len( face ) ) numPolygons = polygonCounts.length() fnMesh = OpenMaya.MFnMesh() newMesh = fnMesh.create( numVertices , numPolygons , vertexArray , polygonCounts , polygonConnects ) fnMesh.updateSurface() # Assign new mesh to default shading group nodeName = fnMesh.name() cmds.sets( nodeName , e=True , fe='initialShadingGroup' ) return nodeName result = cmds.skeletonEmbed( query=True , mergedMesh=True ) createMeshFromDescription( result )