Modifying DG During Callback

21 views
Skip to first unread message

Oliver Pedersen

unread,
Aug 25, 2021, 1:05:18 PMAug 25
to Python Programming for Autodesk Maya
I'm having issues modifying the DG during an attributeChanged callback. When I change the attribute through another connected attribute on my node, it crashes when the callbacks triggers deletion or creation of DAG nodes. However, when I set the attribute directly on my custom node, everything is working great.

I know this isn't the most detailed explanation but I cannot really post the code. I'm just wondering if there is any common pitfalls to modifying the DAG during a callback, as I'm a bit of noob still to the Open Maya API. I keep getting segfaults so I assume it might be related to garbage collection. Changing the deletes MEL command removal and deferring the eval until idle mitigates the issue a bit, but not completely crash free. Again, when I do it directly on my node, everything is happy, no crashes. Wondering why doing it through a connected attribute makes a difference

Oliver Pedersen

unread,
Aug 25, 2021, 2:08:04 PMAug 25
to Python Programming for Autodesk Maya
Ok so I got it working, but it may be one of the ugliest hacks of my career. Basically I made another dummy attribute that will also trigger a callback when fired. The problem only happens when the original callback was triggered through the OpenMaya.MNodeMessage.kAttributeEval event. So instead of triggering my desired function to run on eval, I just run setAttr on the dummy attribute I made, which will then trigger the callback with my desired function. I also evalDeferred this setAttr call on the dummy attribute. 

My additional question now is, why does this work when the original one didn't (i.e. it crashes when deleting nodes through callback on kAttributeEval but not on kAttributeSet)? I am still curious about my original question because I'm an OpenMaya noob, any insight very appreciated!
Reply all
Reply to author
Forward
0 new messages