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! On Wednesday, August 25, 2021 at 10:05:18 AM UTC-7 Oliver Pedersen wrote: > 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 > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/0285ac3f-ddca-4649-a44b-961fad9d27d1n%40googlegroups.com.