( "Failed to register command: %s\n" % kPluginCmdName ) Mplugin.registerCommand( kPluginCmdName, cmdCreator, syntaxCreator ) Mplugin = OpenMayaMPx.MFnPlugin(mobject, "Autodesk", "1.0", "Any") Syntax.addFlag(kRadiusFlag, kRadiusLongFlag, ) Syntax.addFlag(kPitchFlag, kPitchLongFlag, ) Return OpenMayaMPx.asMPxPtr( scriptedCommand() ) Set this to False to get that behaviour.ĬurveFn.create( controlVertices, knotSequences, deg,, 0, 0, nullObj )ĬurveFn.createWithEditPoints(controlVertices, 3,, False, False, False) A function to create curves by passing in the ep's # This plugin normally creates the curve by passing in the Radius = argData.flagArgumentDouble(kRadiusFlag, 0)ĬontrolVertices.append( OpenMaya.MPoint( radius * s(i), Pitch = argData.flagArgumentDouble(kPitchFlag, 0) As the plug-in loads, Maya calls the nodeInitializer() function to create the attributes of the node.Ĭlass scriptedCommand(OpenMayaMPx.MPxCommand):ĪrgData = OpenMaya.MArgDatabase(self.syntax(), args) The nodeInitializer() function is passed to registerNode() in the initializePlugin() function. ( "Failed to register node: %s" % kPluginNodeTypeName ) Mplugin.registerNode( kPluginNodeTypeName, sineNodeId, nodeCreator, nodeInitializer ) SineNode.attributeAffects( sineNode.input, sineNode.output ) SineNode.output = nAttr.create( "output", "out",, 0.0 )
SineNode.input = nAttr.create( "input", "in",, 0.0 ) Return OpenMayaMPx.asMPxPtr( sineNode() ) OutputHandle = dataBlock.outputValue( sineNode.output ) Python strings are passed and returned in place of the MString wrapper class.ĭataHandle = dataBlock.inputValue( sineNode.input ).Although Python is a typeless language, you must instantiate the correct type in order to pass it as a parameter of the class.MObjects can be created using node = OpenMaya.MObject().To instantiate a class, use the fn = OpenMaya.MFnFunctionSet() notation.The example above demonstrates the following: Print "Plug value %g" % translatePlug.asDouble()) Print "Plug name: %s" % translatePlug.name() TranslatePlug = nameToNodePlug( "translateX", perspNode ) Print "APItype string %s" % perspNode.apiTypeStr() Plug = OpenMaya.MPlug( nodeObject, attrObject ) # function that finds a plug given a node object and plug nameĭef nameToNodePlug( attrName, nodeObject ):ĭepNodeFn = OpenMaya.MFnDependencyNode( nodeObject )ĪttrObject = depNodeFn.attribute( attrName ) SelectionList = OpenMaya.MSelectionList() # function that returns a node object given a name