MetaFusion/scripts/Reference/SGDeleteJointForLOD.py
2025-01-17 02:30:36 +08:00

29 lines
765 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/02/23
"""
import maya.cmds as cmds
def sg_delete_joint_for_lod(lod):
"""
删除指定LOD级别不需要的关节
参数:
lod (int): LOD级别
"""
# 获取所有关节和指定LOD级别的关节
joint_all = cmds.SGGetJoints(lod=0, type="string")
joint_lod = cmds.SGGetJoints(lod=lod, type="string")
# 找出需要删除的关节在所有关节中但不在指定LOD级别中的关节
joint_del = list(set(joint_all) - set(joint_lod))
# 删除不需要的关节
for joint in joint_del:
if cmds.objExists(joint):
cmds.delete(joint)