Hi, everyone.
I am trying to ceate a custom node with OpenMaya Python API.
The input structure look like this:
----iPCGsList[0]
---------------PCG[0]
-------------------.x
-------------------.y
-------------------.z
---------------PCG[1]
-------------------.x
-------------------.y
-------------------.z
---------------PCG[…]
----iPCGsList[…]
An error when I trying to get PCG[0] from iPCGsList[0].
This is how I define these attributes:
numeric_attr = om.MFnNumericAttribute()
cls.iPCG = numeric_attr.create('iPCG', 'iPCG',om.MFnNumericData.k3Double)
numeric_attr.setKeyable(True)
numeric_attr.setArray(True)
numeric_attr.setUsesArrayDataBuilder(True)
cls.addAttribute(cls.iPCG)
compound_attr = om.MFnCompoundAttribute()
cls.iPCGsList = compound_attr.create('iPCGsList', 'iPCGsList')
compound_attr.setKeyable(True)
compound_attr.setArray(True)
compound_attr.setUsesArrayDataBuilder(True)
compound_attr.addChild(cls.iPCG)
cls.addAttribute(cls.iPCGsList)
And when I try to read the value by the compute function:
def compute(self,plug,data: om.MDataBlock):
iPCGsList_handle = data.inputArrayValue(MBCmptCoreNode.iPCGsList)
iPCGsList_count = iPCGsList_handle.elementCount()
for i in range(iPCGsList_count):
iPCGsList_handle.jumpToArrayElement(i)
iPCG_handle = iPCGsList_handle.inputArrayValue() # where problem is
data.setClean(plug)
maya gives me an error saying:
(kInvalidParameter): Data is not an array
Does anyone know how to solve it?