Maya Auto Node Clean Up

I have a master node that connects into many other nodes with various attribute flags that I use to trace what type each of the connected nodes is(a la the Bungie meta-node talk). I have a function that deletes all nodes on the output end of the master node, but I’m getting the result where Maya is also deleting the master node because it’s connected to all of the nodes I’m actually deleting. This is undesirable.

I have a connection going INTO my master node from another Maya node, so I’m not sure why the master node is getting cleaned up anyways since it’s still holding a connection to something else in the scene…

Questions:

  1. Is there any way to avoid Maya automatically cleaning up this node on deletion?
  2. I came across this article. Is there any way that I can alter this state of a standard Maya node via the API after it has been created? Creating a completely new node type through the API just for this case would be a bit of an overkill. OR, is there any default node in Maya that has this status set to True? I’m currently using the node of type ‘network’, but am not tied to that particular type for any reason.
  3. Is there any other workaround for this, short of something super hacky like creating some kind of dummy node that’s always connected to ensure the master node doesn’t get deleted?

Thanks!

guessing it is too much hackiness, but couldn’t you disconnect the attribute before deleting the node?

I had a similar thing with the Red9 MetaData api, which may be worth looking into as all the connection, attr management and object wrapping is already done for you.

What I ended up doing was having an internal flag / decorator on the node class that manages the lockNode state of the node, unlocking it to add / delete attrs etc. The decorator is dead simple, but all the code integration and calls are carefully wrapped in the red9 api itself.

lots of demos here: Red9

Seemed like the easiest way to manage the issue and has proved rock solid at work.

cheers

Mark

[QUOTE=tokejepsen;24760]guessing it is too much hackiness, but couldn’t you disconnect the attribute before deleting the node?[/QUOTE]

I actually already had a function that does just this thing. It was working for 95% of the cases, so I was convinced there was some Maya shadiness going on for that other 5%. After further hunting, I’ve actually found the issue though:

After disconnecting nodes from the master node, I was deleting them as I came across them. Problem being that some of these nodes had children which were also connected to the master node which were getting deleted along with the parent before their connections were broken. Changing the code to keep a master delete list and deleting it after ensuring all children connections are broken first fixed up the issue.

Thanks for the replies!