The code below demonstrates, via Maya ' s Python API, how to retrieve:
–mobject from a mesh, and its skincluster
–mfnskincluster for the skincluster on that mesh
, haven influences in that skin cluster and their names
, Haven influence weights for every vert on that mesh
enjoy!
## Don ' t mind the short names, I had a habit of using MC, OM, OMA for Maya ' s modulesI Mport Maya. Openmaya as Omimport maya. Openmayaanim as Oma
Next, we'll get the Mobject & Mdagpath for our mesh ' s ShapeNode
# The shape node for some mesh ' PSphereShape1 ' == om. Mobject () meshdagpath = om. Mdagpath () msel.getdependnode (0, Meshmobject) msel.getdagpath (0, Meshdagpath)
Next, an mdagpatharray of the influences and the influence count.
Also, the node names for those influences, for convenience.
# Influences & influence Countinfluences== skinfn.influenceobjects (influences)# Get node names for influences for in range (Infcount)]
Finally, get all of the weight data, organized as a dictionary of dictionaries.
The first level would use vert indices for keys, the next would be a dict of influence name:weight.
Weightdata = {}#Ordered by Vertiter 0-numvertsVertiter =om. Mitgeometry (Meshmobject) while notVertiter.isdone (): Vertinfcount=om. Mscriptutil () vertinfcountptr=vertinfcount.asuintptr () om. Mscriptutil.setuint (vertinfcountptr, 0) weights=om. Mdoublearray () skinfn.getweights (Meshdagpath, Vertiter.currentitem (), weigh TS, vertinfcountptr)#Create A dictionary for each vert index in the mesh #All influences'll is returned for each vert and may have 0 influenceWeightdata[vertiter.index ()] =dict (Zip (influencenames, weights)) Vertiter.next ()
Get skincluster data with Maya ' s Python API