Is there a way to delete unknown noeds from within Maya using Pyhton
#Something like... for item in unknownNodes: if node.exists: delete node print unknownNodes # []
Solved! Go to Solution.
Is there a way to delete unknown noeds from within Maya using Pyhton
#Something like... for item in unknownNodes: if node.exists: delete node print unknownNodes # []
Solved! Go to Solution.
Solved by rajasekaransurjen. Go to Solution.
import maya.cmds as cmds cmds.delete(cmds.ls(type="unknown"))
import maya.cmds as cmds cmds.delete(cmds.ls(type="unknown"))
import maya.cmds as cmds
unknownNodes=cmds.ls(type = "unknown")
for item in unknownNodes:
if cmds.objExists(item):
print item
cmds.delete(item)
import maya.cmds as cmds
unknownNodes=cmds.ls(type = "unknown")
for item in unknownNodes:
if cmds.objExists(item):
print item
cmds.delete(item)
Thanks, rajasekaransurjen, your code handles ALMOST all the unknown nodes.
It looks like there's another type, "unknownDag" that Maya also uses (eg for Mental Ray nodes if the plugin isn't loaded). I updated your code to include that type, and to unlock nodes before deleting them since Maya will refuse to delete any locked nodes:
import maya.cmds as cmds unknownNodes=cmds.ls(type = "unknown") unknownNodes+=cmds.ls(type = "unknownDag") for item in unknownNodes: if cmds.objExists(item): print item
cmds.lockNode(item, lock=False) cmds.delete(item)
A recent Autodesk post also discusses a few more ways to remove unknown nodes, for example by using the Optimize Scene Size command: https://knowledge.autodesk.com/support/maya/troubleshooting/caas/sfdcarticles/sfdcarticles/Unable-to...
Thanks, rajasekaransurjen, your code handles ALMOST all the unknown nodes.
It looks like there's another type, "unknownDag" that Maya also uses (eg for Mental Ray nodes if the plugin isn't loaded). I updated your code to include that type, and to unlock nodes before deleting them since Maya will refuse to delete any locked nodes:
import maya.cmds as cmds unknownNodes=cmds.ls(type = "unknown") unknownNodes+=cmds.ls(type = "unknownDag") for item in unknownNodes: if cmds.objExists(item): print item
cmds.lockNode(item, lock=False) cmds.delete(item)
A recent Autodesk post also discusses a few more ways to remove unknown nodes, for example by using the Optimize Scene Size command: https://knowledge.autodesk.com/support/maya/troubleshooting/caas/sfdcarticles/sfdcarticles/Unable-to...
Can't find what you're looking for? Ask the community or share your knowledge.