3

I have a mesh object created by geometry nodes - it's basically a plane divided into smaller segments. In the spreadsheet, I can see the number of faces and vertices. But when trying to access this information from Python, it appears that Python only sees the base mesh (to which the geo nodes modifier is applied). That is - Python only sees 1 face, not N faces.

Is there a way for Python to access the output of the geometry nodes modifier?

G.H.
  • 331
  • 1
  • 8

1 Answers1

5

This code prints the number of faces before and after modifiers (original data vs evaluated data):

from bpy import context as C
dg = C.evaluated_depsgraph_get()
ev = C.object.evaluated_get(dg)
print("Faces:", len(C.object.data.polygons))
print("Evaluated Faces:", len(C.object.evaluated_get(dg).data.polygons))
Markus von Broady
  • 36,563
  • 3
  • 30
  • 99
  • A further question - How do I iterate over all vertices on an evaluated face/polygon? It doesn't appear to be the same as the mesh data before modifiers are applied. – G.H. Jan 31 '23 at 00:56
  • Nevermind - I figured it out. for Vert in mesh.data.polygons.vertices provides an index I can use to call on the coords in mesh.data.vertices... – G.H. Jan 31 '23 at 01:29