Feedback

What's your question?

By: Asked

attribute not saved with scene - Maya API

I have created and attribute on a deformer node, just to store an array of doubles, these doubles are set by a command inside the plugin itself, and the attribute is never connected to any other node, it´s just supposed to store these values. The problem is that when I save the scene, close maya and open it again, the values are gone... here´s the code:

In the deformer initialize method:

MFnTypedAttribute tAttr;

myAttr = tAttr.create("testAttribute", "tAtt", MFnData::kDoubleArray, MObject::kNullObj, &status);

tAttr.setHidden(true);

tAttr.setStorable(true);

status = addAttribute(myAttr);

In the function where I set the values:

MDoubleArray myArray(100, 0.0);

MFnDoubleArrayData myArrayData;

MObject myArrayObj = myArrayData.create(myArray);

MPlug myPlug( thisMObject(), myAttr );

myPlug.setValue(myArrayObj );

In the deform method where I retrieve the values:

MDataHandle myDataHandle = block.inputValue(myAttr );

MFnDoubleArrayData myData(myDataHandle .data());

MDoubleArray myArray = myData.array(&status);

Everything works fine while maya is open, but when I save the scene, close and reopen maya, the array is gone...

Thanks for any help!

Add comment viewed 219 times Latest activity 11 months ago

or Cancel

2 answers

  • 0

julian [ Admin ]

It works for me. The only thing I did that's not in your code is:

 attributeAffects(myAttr, outputGeom );

The values are there in the maya ascii file

createNode wakeDeformer -n "wakeDeformer1";
    setAttr ".tAtt" -type "doubleArray" 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ;

getAttr works:

getAttr "wakeDeformer1.tAtt"
// Result: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 // 

EDIT In fact it works without the attributeAffects() call

NN comments
juke3d
-

Thanks for the reply! Yes, I can see the values on the .ma file as well, but the problem is that when I try to open this file, the deformer node does not have these values in it… so storing is not the problem, but reading it back… I’m running maya 2011, if that matters… any ideas?

julian
-

Do you get a result if you do getAttr MEL cmd?

In deform(), you could try getting the values with MPlug::getValue() instead of through the dataHandle.

I’m using maya 2011 too, on a mac. I’ll try your code here if you like.

or Cancel
  • 0

juke3d

Thanks for the reply! Yes, I can see the values on the .ma file as well, but the problem is that when I try to open this file, the deformer node does not have these values in it... so storing is not the problem, but reading it back... I'm running maya 2011, if that matters... any ideas?

or Cancel