Browse Source

选择面工具

ColorComparison
hesuicong 2 days ago
parent
commit
ad159acc6a
  1. 33
      utilities/select_face.py

33
utilities/select_face.py

@ -0,0 +1,33 @@ @@ -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}")
Loading…
Cancel
Save