Get skincluster data with Maya ' s Python API

Source: Internet
Author: User
Tags for in range

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.