[maya][python] delete unused nodes?

What’s the python equivalent of hypersahde edit>delete unused nodes?


This is a UI Command. You can have a look at “hyperShadePanel.mel” to see what going on exactly.
Otherwise you can just wrap the MEL command into Python

mel.eval('hyperShadePanelMenuCommand("hyperShadePanel1", "deleteUnusedNodes");')
1 Like


// mel


import maya.mel as mel


i’ve had to write to my own Delete Unused Nodes because there are some kinds of nodes that can slip through the cracks.

For example, if you end up with a construction history chain that does not feed into a shape node, e.g. polyCube > bevel > polyProjectUV, those “orphaned” construction history nodes will not be removed by Clean Scene, Delete Un-used Nodes, or any of Maya’s other various tools for keeping your files clean.

1 Like

This is from years ago, but might you have that Delete Unused Nodes tool you made yourself? Interested ins how it works to know what to delete.