From ad159acc6ace7637e1658e71d7b1eed03b0b7995 Mon Sep 17 00:00:00 2001 From: hesuicong Date: Thu, 26 Feb 2026 10:34:12 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=89=E6=8B=A9=E9=9D=A2=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utilities/select_face.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 utilities/select_face.py diff --git a/utilities/select_face.py b/utilities/select_face.py new file mode 100644 index 0000000..5cdb502 --- /dev/null +++ b/utilities/select_face.py @@ -0,0 +1,33 @@ +import bpy +import os + +mesh = bpy.context.active_object.data + +selected_faces = [polygon.index for polygon in mesh.polygons if polygon.select] + +output_lines = ["详细信息:"] + +for face_idx in selected_faces[:10]: # 只显示前10个 + face = mesh.polygons[face_idx] + output_lines.append(f" 面 {face_idx}: 顶点数={len(face.vertices)}, ={face.area:.4f}") + +text_name = f"selected_faces_report" + +# 删除已存在的同名文本数据块 +if text_name in bpy.data.texts: + bpy.data.texts.remove(bpy.data.texts[text_name]) + +text_block = bpy.data.texts.new(text_name) +for line in output_lines: + text_block.write(line + "\n") + +save_dir = "/home/algo/Documents/openMVS/data/446442/out.446442" +os.makedirs(save_dir, exist_ok=True) + +file_path = os.path.join(save_dir, "_test_faces.txt") + +with open(file_path, 'w') as f: + for face_index in selected_faces: + f.write(f"{face_index}\n") + +print(f"面片索引已保存到: {file_path}")