PDA

View Full Version : Python API connect attributes Help


NPuetz
04-07-2008, 12:34 AM
Hello, I'm new to the Maya API and im stuck trying to figure out how to connect time1.outTime into one of my custom nodes attributes. Im currently using MFnDependencyNode's findPlug function to make a "pointer" to that nodes Attribute (.input) and than evaluating MEL's connectAttr to make the connection. Im doin something wrong and i can't quite figure it out:D. This piece of code is currently in my initializer function where all my attributes are being created...should it not be outside this function? Something Syntactical??? Should I approach this differently??? Any help or advice would be much appreciated!! Thanks in advance!!

----------------------------------------------------------------------------------
class nmpSineWave(OpenMayaMPx.MPxNode):
# establish INPUT and OUTPUT var's
INPUT = OpenMaya.MObject()
OUTPUT = OpenMaya.MObject()

def __init__(self):
OpenMayaMPx.MPxNode.__init__(self)

def compute(self, plug, dataBlock):
blah blah blah.....


def nodeInit():
# Create Input Attribute
floatAttrInput = OpenMaya.MFnNumericAttribute()
nmpSineWave.INPUT = floatAttrInput.create("input","in",OpenMaya.MFnNumericData.kFloat,0.0)
# Create Output Attribute
floatAttrOutput = OpenMaya.MFnNumericAttribute()
nmpSineWave.OUTPUT = floatAttrOutput.create("output","out",OpenMaya.MFnNumericData.kFloat,0.0)

# Connect time into INPUT
timeConnect = OpenMaya.MFnDependencyNode( nmpSineWave() )
inputPlug = timeConnect.findPlug( "input" )
cmd = "connectAttr 'time1.outTime' %s" % ( inputPlug.name() )
OpenMaya.MGlobal.executeCommand(cmd)

CGTalk Moderation
04-07-2008, 12:34 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.