Hello,
My biggest weakness with maya api so far has been working with and connecting compound Array Attributes.
I currently have a simple node that takes an input weightList built after the weightListNode devkit example. Then apply the weights To a weightList based on a correspondence table.(I am copying weights from a cluster to another object with more control points)
I got this to work, but ran into a update issue. Like a weightedDeformer my input and output weighList are arrays. So I can attach more than one cluster to the node.
(example: driverCluster1.weightList[0] -> myNode.inWeightList[0] myNode.outWeightList[0] -> drivenCluster1.weightList[0] then driverCluster2.weightList[0] -> myNode.inWeightList[1] myNode.outWeightList[1] -> drivenCluster2.weightList[0])
It seems to only update when the last inputCluster in the array is transformed, in this case driverCluster2. The weight only gets transferred for driverCluster1 when either I move driverCluster2 or If I modify the weights for driverCluster1.
Any Ideas what I might be doing wrong?
Here are the guts to my compute function(ignore the for loop seems to be an issue with using < symbol in code mode):
if ( plug == aWeightsList or (plug.isChild() and plug.parent() == aWeightsList))
{
MObject thisNode = thisMObject();
MPlug wPlug(thisNode, aWeights);
unsigned i, j, k;
// Read from aInWeightList
MArrayDataHandle arrayHandle = block.inputArrayValue(aInWeightsList, &status);
McheckErr(status, "arrayHandle construction for aWeightsList failed\n");
MArrayDataHandle outArrayHandle = block.outputArrayValue(aWeightsList, &status);
McheckErr(status, "outArrayHandle construction for aWeightsList failed\n");
int count = arrayHandle.elementCount();
MArrayDataBuilder wghtListBuilder = outArrayHandle.builder();
McheckErr(status, "multiCurve::compute creating builder");
for( i = 0; i < count; i++)
{
arrayHandle.jumpToArrayElement(i);
MDataHandle eHandle = arrayHandle.inputValue(&status).child(aInWeights);
McheckErr(status, "handle evaluation failed\n");
MArrayDataHandle eArrayHandle(eHandle, &status);
McheckErr(status, "arrayHandle construction for aInWeights failed\n");
unsigned eCount = eArrayHandle.elementCount();
status = wPlug.selectAncestorLogicalIndex( i, aWeightsList );
MDataHandle wHandle = wPlug.constructHandle(block);
MArrayDataHandle wArrayHandle(wHandle, &status);
McheckErr(status, "wArrayHandle construction failed\n");
MArrayDataBuilder wArrayBuilder = wArrayHandle.builder(&status);
McheckErr(status, "wArrayBuilder accessing/construction failed\n");
for( j = 0; j < eCount; j++)
{
eArrayHandle.jumpToArrayElement(j);
float weight = eArrayHandle.inputValue(&status).asFloat();
McheckErr(status, "weight evaluation error\n");
//#########################################
//Replaced correspondence table with simple setting of outWeights as if there is a one to one correspondence
MDataHandle wghtHandle= wArrayBuilder.addElement(j);
wghtHandle.set(weight);
}
status = wArrayHandle.set(wArrayBuilder);
McheckErr(status, "set arrayBuilder failed\n");
wPlug.setValue(wHandle);
wPlug.destructHandle(wHandle);
}
}else {
return MS::kUnknownParameter;
}