[API] Accessing children of compound element plug?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 02 February 2012   #1
[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?
Thanks.


MFnCompoundAttribute cmpAttr;
MFnNumericAttribute numAttr;
MFnUnitAttribute unitAttr;

// compound input array attribute
_caInputs = cmpAttr.create("inputs", "gi", &mstat);
cmpAttr.setArray(true);
cmpAttr.setIndexMatters(false);
cmpAttr.setDisconnectBehavior(MFnAttribute::kDelet  e);

// children of compound element plug
_nInTranslate = numAttr.createPoint("translate", "t", &mstat);
cmpAttr.addChild(_nInTranslate);
_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);
cmpAttr.addChild(_nInRotate);

...

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

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

MVector trans = h_curInput.child(_nInTranslate).asVector();
MAngle rz = h_curInput.child(_nInRotate).child(_nInRotateZ).as  Angle();
__________________
[ myRiggingBLOG ]
[ myAnimBLOG ]
[ myWebsite ]
"Life is animation and we are our own animators." -i
 
Old 02 February 2012   #2
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.
__________________
[ myRiggingBLOG ]
[ myAnimBLOG ]
[ myWebsite ]
"Life is animation and we are our own animators." -i
 
Old 02 February 2012   #3
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?

Originally Posted by theflash: 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.
 
Old 02 February 2012   #4
Found my mistake

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 );
__________________
[ myRiggingBLOG ]
[ myAnimBLOG ]
[ myWebsite ]
"Life is animation and we are our own animators." -i
 
Old 02 February 2012   #5
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 01:12 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.