Looks like you’ve just uncovered a bug in maya. I say this because if I
comment out the “del mdg_mod” line:
import pymel.core as pmimport maya.OpenMaya as OpenMaya
handles_to_delete = []for i in xrange(5):
new_nodes = pm.polyCube()
for new_node in new_nodes:
handles_to_delete.append(new_node.__apihandle__())
old_undo_state = pm.undoInfo(q=1, state=1)
pm.undoInfo(state=0)try:
mdg_mod = OpenMaya.MDGModifier()
for moh_node in handles_to_delete:
if moh_node.isValid() is False:
continue
mdg_mod.deleteNode(moh_node.object())
mdg_mod.doIt()
# del mdg_modfinally:
pm.undoInfo(state=old_undo_state)
…then it no longer crashes… however, the viewport still displays the
now-deleted cube(s), even though they don’t exist in the outliner / scene /
etc. Clearly a bug - the viewport is still keeping around references to
deleted objects somehow. (Tested with 2018.1, don’t have a copy of 2018.2
yet.)
Not much to do other than submit a bug report to autodesk about it.
Also - if possible, please try to include independently-executable code
samples when you’re looking for help troubleshooting. It makes it much more
likely you’ll get help… frequently, if I see something like “self.a_roots”
in a code snippet, I won’t even bother trying to troubleshoot.
- Paul
On Thu, Jan 4, 2018 at 1:51 AM Rémi Deletrain <[email protected]>
wrote:
Hi all,
>
> I trying too to delete a node. But I have a crash on doIt of MDGModifier
> From what I read here, the reason would come from the management of
> pointers...
>
> But I don't know how to fix that or convert to exception.
> My process create many nodes. When I want to delete root of one of them
> maya have brutal crash
>
> Here is my code:
> # Delete node
> mdg_mod = OpenMaya.MDGModifier()
> for moh_node in self.a_roots:
> if moh_node.isValid() is False:
> continue
> mdg_mod.deleteNode(moh_node.object())
> mdg_mod.doIt()
> del mdg_mod
>
> I Use MObjectHandle and my node is valid and alive. I have a same problem
> on removeAttribute of MFnDependencyNode.
> I try to set undo to false. When undo is false delete node works as long
> as outliner is not opened. When I open outliner maya crash...
>
> You have any solution ?
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/1e10760b-b977-4d7f-a088-3132d46d6b0c%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/1e10760b-b977-4d7f-a088-3132d46d6b0c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAAssL7bLvrgQzNCKNtvZV3mE50p0SQaZXoerUjo_YaNinui%3DdA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.