Delete Node Set Upon Single Node Deletion

Hey Guys-

Just wondering if there is a way to make the deletion of one node cause a whole group of deletions. I have created a script that creates several nodes that interact as a "system", and want to be able to delete any of the nodes in that set and cause the rest to be deleted. So far the nodes are assigned to a set, but deleting just the set does not delete the whole group of nodes, just the set that they are in. I would probably make this action prompt you before it deleted the remaining nodes.... Any thoughts are welcome.

Thanks

Scott

I can't help you with this in mel, I just checked if the scriptJob can handle deletions as an event, but apparently it can't, at least in 6.0.1, and I can't think of anything else in mel.

But it is possible to create a new API command which uses the MNodeMessage::addNodeAboutToDeleteCallback(...) method to perform that task, so, if you really need to do that and nobody comes up with a solution in mel, you might figure out a way to get it done in c++.

Again I only think of that the "selection change"-event is occurring if you delete something.. but that could be heavy

I wouldn't rely on that. what if you call "delete myNode" to delete an unselected node, the selection list does not seem to be changing.

I needed to do exactly that, to delete a couple of nodes when a specific node got deleted. The use of MNodeMessage::addNodeAboutToDeleteCallback(...) allowed me to handle undo/redo like it should be handled, and also I spent quite some time searching for a mel solution without finding a proper one (but I'm new to mel so chances are big that I missed something).

Creating a command that set's up a callback for that that condition, checks to see to which set the node belongs to and enqueues all the those nodes for deletion doesn't seem to be a big issue if you've got the tools at hand.

Hell! You are right! Its only throwing the even if you had "myNode" selected... of course. Its working properly

BTW: We now have a real-time-level editor that hanldes deleted nodes exactly the way I described: If you have a node selected and delete it a scriptjob is called that runs a command that looks if the prevoius node is still available.. if not it tells the game engine to delete it in-game as well. Not so elegant but works well.

Actually script job can do this is just not apparent at first sight. Let us use of a trick.

CODE
{
  $cube =polyCube -w 1 -h 1;
  scriptJob -attributeDeleted ($cube[0]+".message") ("print \""+$cube[0]+" deleted!\"");
}

This really really acts only on deletion of the selected cube! Trick is the atribite must be deleted if the object is to be!

back to the problem let us asume the sets name is set1
CODE
scriptJob -attributeDeleted ("set1.message") ("undo;delete sets -q set1;");

Great