MPxNode::setInternalValue -> element attribute update


#1

I have an array attribute (‘MFnAttritute::setArray(true)’, which is set to be internal (‘MFnAttribute::setInternal(true)’).
When I now change the value of one element, inside the ‘MPxNode::setInternalValue’, I get the old value of that element,
even though the channelBox shows the new value and also asking Maya with ‘getAttr( “myNode.myElemAttr” )’ gives me the
new value. I have to set the value twice so that inside the ‘MPxNode::serInternalValue’ I get the correct updated value.

So, what am I doing wrong?
Thanks for help!


#2

There´s one more problem with getting the right values from my array plugs, which were set to be ‘internal’…
I can save the data for the elements with a normal Maya save file.
When I have a look at the ‘.ma’ file the data are there.
But when I load the scene, the data are ignored and the array plugs have no elements.

So, either thats a horrific bug or I have ignored some fundamental code additions/changes.
Anyone?


#3

update for the audience:
I recently tested the default Maya attribute ‘overrideColor’ (short: ‘ovc’), which is also a ‘internal’ attribute.
And I found that also this attribute gives me the previous value inside the ‘MPxNode::setInternalValue’ method when I have set a new value.
So, when the previous value was ‘green’ (index 14) and II set the value to red (index 13), I get 14 as a result.

||
° °
>


#4

Hi. Did you ever find a solution to this? I stumbled across a similar issue - or maybe it’s the same problem. When loading a saved file my internal numeric attributes are not set. Working on the file all is fine (setInternal is called etc.). The ma looks good to. But when opening the file setInternal is never called. And querying the plug manually gives wrong results.

Thanks,
Nico


#5

Hi Nico,

That bug is still there. And its a pain in the §*$.

edit: and yes, you see the same effects I see…


#6

So it is a real bug? Not my inability? Because typed attributes work.

edit: And do you have a bug number?


#7

I think its a bug. Although I did not test for types attributes.
But I have not saved the bug number…


#8

So I think I found a workaround for me.

It seems the typed attributes work because they don’t have a default value, so whatever you enter into them will be saved to the .ma file. When the file is opened setAttr is run and setInternal called.
But other attribute types have a default value, and if the attribute on the node equals the default maya does not save it to the file.
By setting my defaults in attr.create to something absurd and then setting the defaults in the postConstructor I force Maya to always store my values in the .ma.
Now my setInternal is called on file open.

I also had to set attr.setAffectsAppearance(true); I guess because my shape has no outputs, just draws into the viewport.

This looks like a hack. But let’s see how far I get with it. I’m wildly stabbing in the dark here. There is probably a correct way to do this.


#9

Ha, I remember I also did that workaround (set the default value to a absurd value :slight_smile: )
However, the AD devs have to fix this for the next release…


#10

Just one more note:
this bug also affects default Maya attributes, which are set to internal.
When I try to change the override color of DAG nodes ( short: ‘ovc’, and yes, that attribute is also a internal attribute),
I get the color of the previous value…