I realize the plug-in I pulled it from didn't really do anything but print out some results. Was created for testing purpose and I only made the compute run once (Think I converted it from C++). Your right it would try to create the plugs each time. I keep coming to the same conclusion of some form of boolean or comparing the element count unless one the the methods in the MPxNode can help.
-brian
www.meljunky.com
---------- Original Message --------
Subject: Re: [Maya-Python] api: creating default array elements
From: Chad Dombrova <[email protected]>
Date: Mon, April 26, 2010 9:06 pm
To: [email protected]
On the next call to compute won't that overwrite whatever values the user inputs for those elements? i was hoping to setup some defaults just on creation. i could hack together something with a boolean variable that tracks whether i've setup the defaults and check it on every call to compute, but that just seems pretty heavy handed.-chadOn Apr 26, 2010, at 6:27 PM, <[email protected]> wrote:I had this in my compute function when I added default elements:thisNode = self.thisMObject()
wPlug = OpenMaya.MPlug( thisNode, weightListNode.aWeights )
#Write into aWeightList
for i in range(3):
wPlug.selectAncestorLogicalIndex( i, weightListNode.aWeightsList )
wHandle = wPlug.constructHandle(dataBlock)
arrayHandle = OpenMaya.MArrayDataHandle( wHandle )
arrayBuilder = arrayHandle.builder()
for j in range( 5 ):
handle = arrayBuilder.addElement( j )
value = i+j
handle.setFloat(value)
arrayHandle.set(arrayBuilder)
wPlug.setMDataHandle(wHandle)
wPlug.destructHandle(wHandle)Don't have time to strip it down to its bare minimum or why I nested the loops.Hope that gets you going,-brian-------- Original Message --------
Subject: [Maya-Python] api: creating default array elements
From: Chad Dombrova <[email protected]>
Date: Mon, April 26, 2010 4:37 pm
To: Maya Python Group <[email protected]>
hi,i'm writing a custom node that has an input array attribute. when an instance of this node is created i would like to populate the array with several default values. within the context of an MPxNode where is the best place to do this and how? calling getAttr myNode.myAttr[0] after creation will add the element, but this seems pretty hacky to me and maya's nodes don't resort to this. for example, the following code shows how a fluidShape's incandescence has 3 elements after a createNode call:s = createNode('fluidShape')print getAttr(s + '.incandescence', size=1)thanks,chad--
http://groups.google.com/group/python_inside_maya--
http://groups.google.com/group/python_inside_maya
--
http://groups.google.com/group/python_inside_maya
http://groups.google.com/group/python_inside_maya
