MetaFusion/scripts/utils/RepairVertexOrder.py
2025-02-07 05:10:30 +08:00

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