PDA

View Full Version : Output Connection Wont Update !


mfiorilli
08-11-2009, 10:36 PM
Hi there,

I've been searching for 24 hours now and still can't make this working :/
Here's my problem:

I have this simple attribute:


outContraction = numericAttr.create("contractionOutput", "cu", MFnNumericData::kFloat, 1, &status);
MCheckStatus(status,"ERROR create contractionOutput");
numericAttr.setStorable(true);
numericAttr.setConnectable(true);
numericAttr.setArray(true); // Set this to be an array!
numericAttr.setUsesArrayDataBuilder(true); // Set this to be true also!
//numericAttr.setHidden(true);
status = addAttribute (outContraction);
//status = attributeAffects( outContraction, outputGeom ); (I've been playing with attributeAffects inside and out. It won't help !)



In the compute function, I'm filling in the number of items in array and modifying them.

FILL:




MArrayDataHandle outContractionArrayData = data.outputArrayValue( outContraction, &status );
MArrayDataBuilder outContractionArrayBuilder = outContractionArrayData.builder();

for (int i=0;i<restMPointVertexArray.length();i++){ // restMPointVertexArray.length() = number of vertex in the mesh
MDataHandle outContraction = outContractionArrayBuilder.addElement(i);
}
outContractionArrayData.set( outContractionArrayBuilder );


MODIFY: (simply adds 9 everywhere ! )
This code is in a loop that iterate over all vertex where i = current vertex



MArrayDataHandle outContractionArrayData = data.outputArrayValue ( outContraction, &status );
outContractionArrayData.jumpToElement ( i );
MDataHandle contractionOutput = outContractionArrayData.outputValue (&status);
contractionOutput.setFloat( 9 );

contractionWeightData.set( contractionWeightBuilder );


I can clearly see the data being updated in the attribute editor but if I connect this data to something else in maya, the connection will NEVER update ! I'll have to disconnect and reconnect it again to see it update :(

All the attributes change to 9 but the connection wont update. If I change them by hand, the connection will update.

Thank you !

mfg
08-12-2009, 12:45 AM
hi,
i had a similar problem, my output wouldnt update on moving the cv's of a input curve

so i changed my code like this. after diffining the size of the array like this ///MArrayDataBuilder outContractionArrayBuilder ( outContraction, 10, &status );/// it suddenly worked.

i am very new to api myself so hopefully someone else has better info, but i would give it a try.

this was my thread: http://forums.cgsociety.org/showthread.php?f=89&t=789691


MArrayDataHandle outContractionArrayData = data.outputArrayValue( outContraction, &status );
MArrayDataBuilder outContractionArrayBuilder ( outContraction, 10, &status );

for (int i=0;i<10;i++)
{
MDataHandle outContractionHandle = outContractionArrayBuilder.addElement(i);

outContractionHandle.set(i);
}

outContractionArrayData.set( outContractionArrayBuilder );
outContractionArrayData.setAllClean();

mfiorilli
08-12-2009, 03:19 AM
Thanks for the quick reply mfg.

Unfortunately enough, I already read all your thread and tried your method but it's giving me the exact same result. Are you working with maya 2009 API?

mfg
08-12-2009, 03:34 AM
i am working with 2008,

but i can hardly call it working :) reading and researching for 4h to get 5 lines of code to work... its getting better from day to day though.

hope someone can help you out, so i can also learn from this problem you are having.

mfiorilli
08-12-2009, 04:03 AM
I just tried really using the same code as you (same attributes, same kind of data) and it still won't update. What I'm doing is connecting the output value to the .translateX of a locator. the locator will only refresh if I disconnect/ reconnect the attribute :(( Maybe maya doesn't understand that the whole node should be dirtied...

P.S.: For me it's 28 hours for 0 lines of code :/ maya's api is really playing on my nerves

mfiorilli
08-12-2009, 07:20 AM
The only way I found for updating (beside disconnect/reconnect) is calling dgdirty in mel. is there a way to call it from inside the api?

EDIT: According to " http://ewertb.soundlinker.com/api " : << The 'dgdirty' command. I haven't found an API equivalent for "dgdirty -all". >>

CGTalk Moderation
08-12-2009, 07:20 AM
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.