Message 1 of 9
Writing a deformer with Python

Not applicable
11-20-2007
09:48 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to write a simple blendshape deformer with Python:
And this is my initialize function:
And I'm getting the following error:
I did a dir( OpenMayaMPx.MPxDeformerNode ) and I'm not seeing any of the built-in attributes listed for MPxDeformerNode. Are these missing from the Python libraries?
class simpleBlendShape( OpenMayaMPx.MPxDeformerNode ):
geomObject = OpenMaya.MObject()
def __init__( self ):
OpenMayaMPx.MPxDeformerNode.__init__( self )
def deform( self, data, itGeo, localToWorldMatrix, mIndex ):
envelope = data.inputValue( simpleBlendShape.envelope ).asFloat()
geoHandle = data.inputValue( simpleBlendShape.geomObject )
geoIter = OpenMaya.MItGeometry( geoHandle )
while ( ( not itGeo.isDone() ) and ( not geoIter.isDone() ) ):
pt = itGeo.position()
geomPt = geoIter.position()
weight = self.weightValue( data, mIndex, itGeo.index() )
w = weight * envelope
pt = ((geomPt - pt) * ww) + pt
iter.setPosition( pt )
return OpenMaya.MStatus.kSuccess
And this is my initialize function:
def initialize():
gAttr = OpenMaya.MFnGenericAttribute()
simpleBlendShape.geomObject = gAttr.create( "geometryObject", "gobj" )
gAttr.addDataAccept( OpenMaya.MFnData.kMesh )
gAttr.addDataAccept( OpenMaya.MFnData.kNurbsSurface )
gAttr.addDataAccept( OpenMaya.MFnData.kNurbsCurve )
simpleBlendShape.addAttribute( simpleBlendShape.geomObject )
simpleBlendShape.attributeAffects( simpleBlendShape.geomObject, simpleBlendShape.outputGeom )
OpenMaya.MGlobal.executeCommand( "makePaintable -attrType multiFloat -sm deformer simpleBlendShape weights" )
return OpenMaya.MStatus.kSuccess
And I'm getting the following error:
# simpleBlendShape.attributeAffects( simpleBlendShape.geomObject, simpleBlendShape.outputGeom )
# AttributeError: type object 'simpleBlendShape' has no attribute 'outputGeom' //
// Warning: Failed to call script creator function //
I did a dir( OpenMayaMPx.MPxDeformerNode ) and I'm not seeing any of the built-in attributes listed for MPxDeformerNode. Are these missing from the Python libraries?