MPxNode derived Nodes get deleted on saving the scene


#1

Hi there,

I have some of my user defined nodes in the nodegraph editor and when I save the scene,
some get deleted (not visible in the outliner window anymore, so not just removed from the node editor).

Both the destructor of the node and the callback

MDGMessage::addNodeRemovedCallback

get called. I use the callback to get notified when a node is deleted in the node editor, cause the destructor is only called on save/open/new scene.

My nodes are not connected to any maya nodes and I couldn’t make out the pattern, which get deleted.

Some are connected with each other, some have no connections (I know that does not make sense, its testwise).

So I need to understand, when Maya does delete nodes, cause deleting them on save is really unintended.

Sounds like scene cleanup to me, so do I need to connect to some maya node to avoid deletion?

Anybody ideas?

Best ,
Kai


#2

That’s not typical behavior of MPxNode which suggests to me that there’s something in your MPxNode’s implementation or the surrounding code that is causing it to be deleted on save.

Deleting on open and new scene should be expected though as Maya will clear the scene before opening a new one.

Do you have setExistWithoutInConnections or setExistWithoutOutConnections virtuals overridden?

I don’t believe scene cleanup gets run automatically as part of the save unless you have it set to do so as a custom step.

Perhaps the best thing to do is to try to isolate the problem. Rename your prefs folder to start with clean default preferences and load only the plug-in and see if it still reproduces. If it does, then we can say it’s limited to the plug-in. If not, then it’s something to do with your environment that’s causing the issue or another script/plug-in. etc.


#3

Thanks Keilun,

was a simple mistake on my side.

I did not use setExistWithoutInConnections and setExistWithoutOutConnections, so Maya could not know, that the nodes should not be deleted.

Now it works! :slight_smile:

Best,
Kai