I took the blendshape example in python openmaya form from chad vernons website. His c++ blendmesh example in the cgcircuit videos with almost identical code and connected the same way works without a problem. However, I want to use python for now.
It doesnt do anything when I create two spheres, move verts on one of them and then connect the deformer to the sphere like so: sculptedShape >>> abjBlend.blendMesh >>> outputShape.InMesh also, if I have a shape selected and run this command then it crashes maya every time. On the other hand, doing so with the c++ plugin doesn't. Why? cmds.deformer(type='abjBlend') http://www.chadvernon.com/blog/resources/maya-api-programming/deformers/ http://pastebin.com/pQahXh9T import maya.cmds as cmds import maya.OpenMayaMPx as OpenMayaMPx import maya.OpenMaya as OpenMaya import math class abjBlend(OpenMayaMPx.MPxNode): kPluginNodeId = OpenMaya.MTypeId(0x00004321) aOutput = OpenMaya.MObject() aBlendWeight = OpenMaya.MObject() aBlendMesh = OpenMaya.MObject() def __init__(self): OpenMayaMPx.MPxNode.__init__(self) def deform(self, data, itGeo, localToWorldMatrix, mIndex): envelope = OpenMayaMPx.cvar.MPxDeformerNode_envelope env = data.inputValue(envelope).asFloat() blendWeight = data.inputValue(self.aBlendWeight).asFloat() blendWeight *= env; oBlendMesh = data.inputValue(abjBlend.aBlendMesh).asMesh() if oBlendMesh.isNull(): print 'no blendMesh' return OpenMaya.MStatus.kSuccess fnBlendMesh = OpenMaya.MFnMesh(oBlendMesh) blendPoints = OpenMaya.MPointArray() fnBlendMesh.getPoints(blendPoints) while not itGeo.isDone(): pt = itGeo.position() w = self.weightValue(data, mIndex, itGeo.index()) pt = pt + (blendPoints[itGeo.index()] - pt) * blendWeight * w itGeo.setPosition(pt) itGeo.next() return OpenMaya.MStatus.kSuccess def creator(): return OpenMayaMPx.asMPxPtr(abjBlend()) def initialize(): mAttr = OpenMaya.MFnMatrixAttribute() nAttr = OpenMaya.MFnNumericAttribute() tAttr = OpenMaya.MFnTypedAttribute() outputGeom = OpenMayaMPx.cvar.MPxDeformerNode_outputGeom abjBlend.aBlendMesh = tAttr.create('blendMesh', 'mesh', OpenMaya.MFnData .kMesh) abjBlend.addAttribute(abjBlend.aBlendMesh) abjBlend.attributeAffects(abjBlend.aBlendMesh, outputGeom) abjBlend.aBlendWeight = nAttr.create('blendWeight', 'weight', OpenMaya. MFnNumericData.kFloat, 0.0) nAttr.setKeyable(True) nAttr.setMin(0.0) nAttr.setMax(1.0) abjBlend.addAttribute(abjBlend.aBlendWeight) abjBlend.attributeAffects(abjBlend.aBlendWeight, outputGeom) # Make deformer weights paintable cmds.makePaintable('abjBlend', 'weights', attrType='multiFloat',shapeMode ='deformer') def initializePlugin(obj): plugin = OpenMayaMPx.MFnPlugin(obj, 'Aleks Berg-Jones', '1.0', 'Any') plugin.registerNode('abjBlend', abjBlend.kPluginNodeId, creator,initialize , OpenMayaMPx.MPxNode.kDeformerNode) def uninitializePlugin(obj): plugin = OpenMayaMPx.MFnPlugin(obj) plugin.deregisterNode(abjBlend.kPluginNodeId) -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/d576d8d2-6884-41ae-8153-d42eec695ae6%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
