Script to delete empty group nodes from scene

Found a script on polycount forums (credits to Shawner) which deletes empty group nodes from your scene. Watch out when there are empty group nodes used (such as stretchy IK) though they will be fine if there are constraints attached to them.

import maya.cmds as cmds

transforms = cmds.ls(type=’transform’)

deleteList = []

for tran in transforms:

if cmds.nodeType(tran) == ‘transform’:

children = cmds.listRelatives(tran, c=True)

if children == None:

print ‘%s, has no childred’ %(tran)

deleteList.append(tran)

if len(deleteList) > 0:

cmds.delete(deleteList)

Leave a Reply

Your email address will not be published. Required fields are marked *