首页 > 解决方案 > 如何从搅拌机 API 2.79 中的网格中获取面列表

问题描述

我正在尝试在搅拌机中创建一些代码,我可以让它打印我选择的网格的顶点和面的完整列表。然后,我计划使用此列表在我想用作附加组件的另一个程序中绘制相同的网格。我可以让搅拌机返回控制台中的顶点列表,但我对这些面孔没有运气。我刚刚开始学习搅拌机 API,因此将不胜感激。

我已经看过一些较早的论坛来解决这个问题,但它们都使用了一个 mesh.faces 函数,搅拌机说它不再存在。我有一种感觉,经过一些更新,blender 已经将它移到了一个新的类函数中,但是,我不知道它在哪里。

## This first part works like a charm, and it prints out the vertices perfectly.
obj = bpy.context.active_object
v = obj.data.vertices[0]
coords = [(obj.matrix_world * v.co) for v in obj.data.vertices]

plain_coords = [vert.to_tuple() for vert in coords]
print(plain_coords)

## This is the part I need help on. No matter what I try it keeps saying there is no attribute 
f = obj.faces
print(f)

在底部,我试图将 f 设置为 obj 中的面列表,但它一直说 obj 没有属性 faces。

标签: pythonblender

解决方案


推荐阅读