Skip to content

Instantly share code, notes, and snippets.

@patwooky
Last active August 2, 2023 05:50
Show Gist options
  • Save patwooky/cbc27e107748ff9f19c062b28844d097 to your computer and use it in GitHub Desktop.
Save patwooky/cbc27e107748ff9f19c062b28844d097 to your computer and use it in GitHub Desktop.
Select all transform nodes that have no shape nodes under them
# Find Empty Groups V001_01
# Select all transform nodes that have no shape nodes under them
if not 'pm' in dir():
import pymel.core as pm
print ('imported pymel')
else:
print('pymel exists')
def getEmptyTransforms(sel=[]):
returnList = []
if not sel:
sel = pm.ls(type='transform')
print(f'sel is {sel}')
for thisXform in sel:
if not (pm.listRelatives(thisXform, ad=True, type='shape')):
returnList.append(thisXform)
print(f'{len(returnList)} empty transforms found')
print(f'{returnList}')
return returnList
emptyXforms = getEmptyTransforms(pm.ls(sl=True))
pm.select(emptyXforms, replace=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment