custom node array attribute not saved properly

46 views
Skip to first unread message

casf01

unread,
Dec 6, 2017, 2:11:18 PM12/6/17
to Python Programming for Autodesk Maya

I have this node that store an array of 2 double

                nAttr = om.MFnNumericAttribute()
               myNode.points = nAttr.create("Points", "p", om.MFnNumericData.k2Double)
             nAttr.storable = True
          nAttr.readable = True
          nAttr.array        = True
              nAttr.writable = True
          myNode.addAttribute(myNode.points)


then when I do go in the node hit add a new item save my scene and re-open it, the array is empty but when I change the value to something else like (1.0, 0)and save it's fine and it my (1.0, 0 ) value is saved.

It seems like an item with a default value won't save itself :/

What can I do ?

Fred

unread,
Dec 6, 2017, 2:47:09 PM12/6/17
to python_in...@googlegroups.com
so far the only solution I found was to set the attribute to keyable and key the default value if needed but that doens't seems like the best solution

--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/tCrc-C9NpMk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/1cf446d5-f832-4232-bb5e-0d7c74f1ca45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Boon

unread,
Dec 6, 2017, 5:37:38 PM12/6/17
to Python Programming for Autodesk Maya
Have you tried doing it inside an MDGModifier? I haven't, but my guess would be that the DG is not being updated until you set a key.

Angelo Sta. Catalina

unread,
Dec 6, 2017, 6:50:37 PM12/6/17
to python_in...@googlegroups.com
The default behavior for an MPxNode is to only save when the value differs from the default value or if there is an incoming connection. You can read more about it in the MPxNode doc's. You can change the behavior by overwriting the method:
om.MPxNode.shouldSave()

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

casf01

unread,
Dec 7, 2017, 7:31:03 AM12/7/17
to Python Programming for Autodesk Maya
Thanks, overriding the shouldSave method fixed the issue :)




Reply all
Reply to author
Forward
0 new messages