Script that selects all of a selected type of object in a hierachy

Was on riggingdojo – credits to Chad Moore! Selects all of a certain type of object in a hierachy, all joints, curves or constraints – found it useful for resizing joints

import maya.cmds as cmds

cmds.select(cmds.ls(dag=1, ap=1, sl=1, type=”joint”))

or

cmds.select(cmds.ls(dag=1, ap=1, sl=1, type=”nurbsCurve”))

or

cmds.select(cmds.ls(dag=1, ap=1, sl=1, type=”constraint”))

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)