[API] Accessing children of compound element plug?


I have created an input attribute which is a compound plug with set as array. Each element of that compound plug contains two compound plugs (translate, rotate). I have trouble getting the input values for these plugs in compute, i.e. I always get zeros in everything. Can anyone have a look at the code I am using below to indicate what might be wrong? or any other ideas to think about?

MFnCompoundAttribute cmpAttr;
MFnNumericAttribute numAttr;
MFnUnitAttribute unitAttr;

// compound input array attribute
_caInputs = cmpAttr.create("inputs", "gi", &mstat);

// children of compound element plug
_nInTranslate = numAttr.createPoint("translate", "t", &mstat);
_nInRotateX = unitAttr.create("rotateX", "rx", MFnUnitAttribute::kAngle);
_nInRotateY = unitAttr.create("rotateY", "ry", MFnUnitAttribute::kAngle);
_nInRotateZ = unitAttr.create("rotateZ", "rz", MFnUnitAttribute::kAngle);
_nInRotate = numAttr.create("rotate", "r", _nInRotateX, _nInRotateY, _nInRotateZ, &mstat);


// ---- in compute -----

MArrayDataHandle  h_inputs = data.inputArrayValue(_caInputs, &mstat);
h_curInput = h_inputs.inputValue();

MVector trans = h_curInput.child(_nInTranslate).asVector();
MAngle rz = h_curInput.child(_nInRotate).child(_nInRotateZ).asAngle();


Some more information:

I am able to read individual float element in the compound array element. However if I create a translate attribute with (tx,ty,tz) and read them from data block then I always get zeros in them.

I also notice that if I disconnect translate attribute to my node, that one compute call does give me correct values in data block. But not when I connect back.

I have no clue whatsoever as to what could be wrong. I tried finding anything obvious in it too, but I don’t see it.


Since you said if you disconnect you will get the correct values in datablock, I’ll assume you are not doing something wrong in compute(). What do you connect your translate attribute to? If you do a getAttr on that attribute what value do you get?

And did you get your rotation values correctly?


Hi whisperwing, I had all the connections made correctly and compute was just setting the dirtied plugs clean without calculation for test.

I found my mistake. I had connectionMade method declared in my class which did not call it’s parent class method and hence never got data into the block. This is what I should have done at the end of connectionMade.

return MPxNode::connectionMade( plug, otherPlug, asSrc );


This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.