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

43 lines
1.2 KiB
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/03/23
"""
import maya.cmds as cmds
def sg_repair_vertex_order():
"""
修复所有网格的顶点顺序
遍历前54个网格将其顶点顺序与参考模型对齐
"""
# 遍历所有网格
for i in range(54):
# 获取目标模型
target = cmds.SGGetMeshes(m=i)
if cmds.objExists(target):
# 清除历史记录
cmds.select(target, replace=True)
cmds.DeleteAllHistory()
# 获取源模型并重命名
source = cmds.SGGetMeshes(cm=i)
source_buffer = f"{source}_buffer"
source_buffer = source_buffer[1:] # 移除第一个字符
source_buffer = cmds.rename(source, source_buffer)
# 应用顶点顺序
cmds.SGSetMeshes(tvo=source_buffer, value=target)
# 删除临时模型
cmds.delete(source_buffer)
print("Repair Vertex Order Repair Completed...")
# 如果直接运行此脚本
if __name__ == '__main__':
sg_repair_vertex_order()