Can my custom node survive to delete

When you use MDagModifier to delete the last shape under a transform, the transform is automatically deleted as well. That is the normal Maya behavior. It helps to keep the scene clear of orphaned transforms and is consistent with MDagModifier::createNode(), which will automatically create a parent if none is specified when creating the node.

However, you need to know that MDagModifier::reparentNode() would not delete empty parents when that happens. And the 'delete' command doesn't behave the same way since it uses the internal equivalent of MDGModifier to delete the node, which leaves the parent intact.

Donotdeleteme
Said that if you want to protect a node from being deleted automatically by Maya when such situation occurs you can do so by using the MPxNode::setExistWithoutInConnections() and MPxNode::setExistWithoutOutConnections() methods which will tell Maya to not delete your node if you lose all your upstream and/or downstream connections.

 

 


Comments

One response to “Can my custom node survive to delete”

  1. Thankyou, this was very usefull tip for what I’m doing currently.
    Perhaps you can give some tips on other problem I posted on area ? It related to custom shader nodes not appearing in hypershade:
    http://area.autodesk.com/forum/autodesk-maya/sdk/custom-nodes-in-hypershade—problem-with-graphing-network/
    thanks

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading