I am having trouble understanding how to:
- iterate through the layers in a scene,
- select the contents of each layer,
- group all of the contents of the layer into one group
- rename the group based on the name of the first obj in the layer +_'grp'
I have some of the concepts down, I just don't seem to be iterating properly when I run this code. I am getting an error on line 5 saying that the 2nd for loop has a NoneType and can't iterate. I tried setting the layer to a value and trying to increment in the loop, but it doesn't seem to work
import pymel.core as pm
layerList = pm.ls(type="displayLayer")
layer = 0
for layer in layerList:
selection = pm.select(layer)
for each in selection:
cmds.select(each, r=True)
pm.group()
pm.rename(each+'_grp')
layer +=1