35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import maya.cmds as cmds
|
|
|
|
from Core import GetMeshes
|
|
|
|
def AutomaticGrouping():
|
|
# 遍历LOD级别
|
|
for i in range(8):
|
|
lodMesh = GetMeshes(lod=i)
|
|
group = "head_lod{}_grp".format(i)
|
|
if not cmds.objExists(group):
|
|
cmds.group(em=True, name=group)
|
|
for j in range(len(lodMesh)):
|
|
if lodMesh[j] >= 50:
|
|
continue
|
|
mesh = GetMeshes(m=lodMesh[j])
|
|
if cmds.objExists(mesh):
|
|
try:
|
|
cmds.parent(mesh, group)
|
|
except:
|
|
pass
|
|
|
|
bodyGrps = ["body_lod0_grp", "body_lod1_grp", "body_lod2_grp", "body_lod3_grp"]
|
|
for i in range(4):
|
|
bodyIndex = 50 + i
|
|
mesh = GetMeshes(m=bodyIndex)
|
|
if not cmds.objExists(bodyGrps[i]):
|
|
cmds.group(em=True, name=bodyGrps[i])
|
|
if cmds.objExists(mesh):
|
|
try:
|
|
cmds.parent(mesh, bodyGrps[i])
|
|
except:
|
|
pass |