I am creating a array plug array and stuck at adding elements to the
array plug ("'sub' elements to each 'parent' element).


                #When an gradient element is created, create a cooresponding 
weight
index
                if plug.isElement() and plug.array() == 
averageWeightsNode.gradient:
                        weightBuilder = weightHandle.builder( )
                        weightElement = weightBuilder.addElementArray( 
plug.logicalIndex
() )
                        weightHandle.set(weightBuilder)

The code adds the new array element correctly but I can't seem to add
elements to the new added array. I tried to use before and after the
addElementArray, including after the 'set' which did not work.:

                        weightBuilder.setGrowSize(10)
                        weightBuilder.growArray(10)

I tried to create another builder which crashed Maya every time.

                       weightElementBuilder = weightElement.builder()

Which was mention at:
http://groups.google.com/group/python_inside_maya/browse_thread/thread/a55f2d3cbc92e902/5085c6781162243e?hl=en&lnk=gst&q=MArrayDataBuilder#5085c6781162243e

"Unfortunately this won't actually work because there is currently a
bug in the Python interface for MArrayDataBuilder such that the code
... will crash as soon as you try to retrieve the handle's builder. "

I tried after the weightHandle was set and got the following error:

weightHandle.jumpToElement( plug.logicalIndex() )
weightElementBuilder = weightHandle.outputArrayValue()

#     weightElementBuilder = weightHandle.outputArrayValue()
# RuntimeError: (kInvalidParameter): Data is not an array #

Also tried:
weightElementBuilder = weightElement.outputArrayValue()

#     weightElementBuilder = weightElement.outputArrayValue()
# RuntimeError: (kFailure): Object does not exist #

Both the array and its array are set:
        cAttr.setArray(1)
        cAttr.setReadable(1)
        cAttr.setUsesArrayDataBuilder(1)



Thanks for any insight on getting an array plug array to added "sub"
elements correcty.




On a side note I found a strang bug when adding attributes
a...Node.gradient_FloatValue = nAttr.create( "gradient_FloatValue",
"gv", OpenMaya.MFnNumericData.kFloat, 0.0 )

Will automatically add the first element Gradient[0], now if I change
the line to gradient_floatValue it will not add the Gradient[0], when
its created. Well maybe its because the attribute name is the same as
the MObject? If I change gradient_FloatValue to gradient_FloatValues,
it will create the Gradient[0] again. If I keep it at
"gradient_FloatValue" and change the order when the attributes are
added as children to gradient, it will not add Gradient[0].

Not a true issue, I can deal with the attribute being named
gradient_floatValue since it does not compromise the plug-in.


-brian
www.meljunky.com
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

Reply via email to