C4D crashes when removing node via MSG_MENUPREPARE
-
What am I doing wrong? Need to remove the node under certain circumstances via MSG_MENUPREPARE but it crashes the C4D.
Is it possible to somehow bypass this behavior? Is this a bug?import c4d import os class OBug_Check(c4d.plugins.ObjectData): def Message(self, node, type, data): if type == c4d.MSG_MENUPREPARE: node.Remove() return True if __name__ == "__main__": c4d.plugins.RegisterObjectPlugin(id=1000003, str="Bug Check", g=OBug_Check, description="OBug_Check", info=c4d.OBJECT_GENERATOR, icon=None)
-
Hi @merkvilson ,
try to add check for main thread scope:def Message(self, node, type, data): if c4d.threading.GeIsMainThread() and type == c4d.MSG_MENUPREPARE: node.Remove()
-
Hi @merkvilson I would say what you are trying to do is not well supported and MSG_MENUPREPARE was never designed for the current node to be removed.
The correct way to do so, is to return
False
within your NodeData.Init method, this way the object is not created and therefor you do not have to remove it.Cheers,
Maxime.