API and Offset BlendShape

240 views
Skip to first unread message

Rémi Deletrain

unread,
Feb 25, 2016, 9:01:29 AM2/25/16
to Python Programming for Autodesk Maya
Hi everyone,

I try to get offset points of blendshape with maya API.

whis pymel is very simple with this line:

----------------------------------------------------------------------------------------------------------------------------------------------------------

pmc.PyNode(blendshapeName).inputTarget[0].inputTargetGroup[0].inputTargetItem[6000].inputPointsTarget.get()

----------------------------------------------------------------------------------------------------------------------------------------------------------

whis API:

----------------------------------------------------------------------------------------------------------------------------------------------------------

#    For get MFnBlendShape
selectionList = OpenMaya.MSelectionList()
selectionList.add(blendShapeName)

bsObject = OpenMaya.MObject()
selectionList.getDependNode(0, bsObject)
bsDependencyNode = OpenMaya.MFnDependencyNode(blendShapeObject)

#    For get weights datas
attributeName = "inputTarget[0].inputTargetGroup[0].inputTargetItem[6000].inputPointsTarget"

selectionList = OpenMaya.MSelectionList()
wPlug = OpenMaya.MPlug()

selectionList.add(blendShapeName + "." + attributeName)
selectionList.getPlug(0, wPlug)

----------------------------------------------------------------------------------------------------------------------------------------------------------

But after is impossible to get value.
I have one solution whis getSetAttrCmds. but it requires to parse string.

there another solution?

Rémi Deletrain

unread,
Mar 3, 2016, 5:14:04 AM3/3/16
to Python Programming for Autodesk Maya
I found the solution !

----------------------------------------------------------------------------------------------------------------------------------------------------------

#    For get MFnBlendShape
selectionList = OpenMaya.MSelectionList()
selectionList.add(blendShapeName)

bsObject = OpenMaya.MObject()
selectionList.getDependNode(0, bsObject)
mfn_blendShape = OpenMayaAnim.MFnBlendShapeDeformer()

#    For get weights datas
attributeName = "inputTarget[0].inputTargetGroup[0].inputTargetItem[6000].inputPointsTarget"

selectionList = OpenMaya.MSelectionList()
wPlug = OpenMaya.MPlug()

selectionList.add(mfn_blendShape.name() + "." + attributeName)
selectionList.getPlug(0, wPlug)

wPlugObject = wPlug.asMObject()
pointsArrayData = OpenMaya.MFnPointArrayData()
pointArray = OpenMaya.MPointArray()
pointsArrayData.copyTo(pointArray)

----------------------------------------------------------------------------------------------------------------------------------------------------------
Reply all
Reply to author
Forward
0 new messages