I am new to the maya API and I am trying to write a node in python.
I am having difficulty getting the child attribute values of an array of compounds.
In my search for the answer, I looked at the weightListNode at autodesk.com and I found a section where they read from an array of compounds:
// Read from aWeightList and print out result using the more
// efficient jumpToArrayElement() call
arrayHandle = block.[url=http://download.autodesk.com/us/maya/2011help/API/class_m_data_block.html#fc1f2a1ddd222b3758e0a089e81fc9ee]inputArrayValue[/url](aWeightsList, &status);
McheckErr(status, "arrayHandle construction for aWeightsList failed\n");
count = arrayHandle.[url=http://download.autodesk.com/us/maya/2011help/API/class_m_array_data_handle.html#3fec25cf54d47cd4844c6d6fb349f0fc]elementCount[/url]();
for( i = 0; i < count; i++) {
arrayHandle.[url=http://download.autodesk.com/us/maya/2011help/API/class_m_array_data_handle.html#d224f4d7f93374798bc0ba18285cdd49]jumpToArrayElement[/url](i);
[url=http://download.autodesk.com/us/maya/2011help/API/class_m_data_handle.html]MDataHandle[/url] eHandle = arrayHandle.[url=http://download.autodesk.com/us/maya/2011help/API/class_m_array_data_handle.html#c0cc76c246b33e8de4f33d29ff6fcf9f]inputValue[/url](&status).[url=http://download.autodesk.com/us/maya/2011help/API/class_m_data_handle.html#a2d98cbea3236417991eed3d1960e7c6]child[/url](aWeights);
McheckErr(status, "handle evaluation failed\n");
[url=http://download.autodesk.com/us/maya/2011help/API/class_m_array_data_handle.html]MArrayDataHandle[/url] eArrayHandle(eHandle, &status);
McheckErr(status, "arrayHandle construction for aWeights failed\n");
unsigned eCount = eArrayHandle.elementCount();
for( j = 0; j < eCount; j++) {
eArrayHandle.jumpToArrayElement(j);
float weight = eArrayHandle.inputValue(&status).asFloat();
McheckErr(status, "weight evaluation error\n");
fprintf(stderr, "weightList[%d][%d] = %g\n",i,j,weight);
}
}
return status;
I am interested in specifically this line:
[url=http://download.autodesk.com/us/maya/2011help/API/class_m_data_handle.html]MDataHandle[/url] eHandle = arrayHandle.[url=http://download.autodesk.com/us/maya/2011help/API/class_m_array_data_handle.html#c0cc76c246b33e8de4f33d29ff6fcf9f]inputValue[/url](&status).[url=http://download.autodesk.com/us/maya/2011help/API/class_m_data_handle.html#a2d98cbea3236417991eed3d1960e7c6]child[/url](aWeights);
When I try to do something similar in python:
eHandle = conditionCompound.inputValue.child(checkTerm)
[
I get an error:
'builtin_function_or_method' object has no attribute 'child'
in my compute function i get the compound array attribute data handle like so:
try:
conditionCompound\_dataHandle = dataBlock.inputArrayValue( mcbNode.conditionCompound )
except:
sys.stderr.write( "Failed to get MDataHandle condition output" )
raise
in the initializer, it looks like this:
cbNode.conditionCompound = cAttr.create( "conditionCompound", "cc")
cAttr.addChild(mcbNode.condition)
cAttr.addChild(mcbNode.logic)
cAttr.addChild(mcbNode.checkTerm)
cAttr.addChild(mcbNode.cRange)
cAttr.setArray(True)
I just want to get the values of the attributes (IE. checkTerm) so I can use them in the compute function. I do not need to output an array. Any help would be much appreciated.