Skip to content

Instantly share code, notes, and snippets.

@gregtemp
Last active August 29, 2015 14:02
Show Gist options
  • Save gregtemp/0a02eded74cd615f55e8 to your computer and use it in GitHub Desktop.
Save gregtemp/0a02eded74cd615f55e8 to your computer and use it in GitHub Desktop.
Level of detail for Crow Group (test) - Maya Python Pymel
import pymel.core.runtime as pm
import maya.cmds as cmds
# Needs a series of crow models with progressively smaller level of detail
# Check if there is already a LevelOfDetail group (for testing reasons)
lodList = list()
lodList = cmds.ls('lodGroup*')
if len(lodList) > 0:
cmds.select('lodGroup1')
# If there is then ungroup them
pm.LevelOfDetailUngroup()
else:
print('no group to ungroup')
# Take the user's selection
crowList = list()
crowList = cmds.ls(selection=True)
if len(crowList) > 0:
# Rename the objects in the selection to "Crow"
for i in range(0,len(crowList)):
cmds.rename(crowList[i], 'Crow')
cmds.move( 0,0,0, 'Crow*', a=True)
else:
print('no crows to rename')
crowList = cmds.ls('Crow*')
# Select all the "Crows"
cmds.select(crowList)
# Make a LevelOfDetail Group
pm.LevelOfDetailGroup()
# Set level of detail to 20, 40, and 60
for i in range (0, 3):
st = 'lodGroup1.threshold[%i]' %(i)
cmds.setAttr(st, ((i+1)*20))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment