Say you generate some random points using Geometry Nodes, how can you get all those point coordinates using the python api?

The only hint I have is that the point coords are located under Point Cloud in the Spreadsheet Editor.

Basically, I want to use those coordinates for scripting other stuff I can't do with Geometry Nodes yet.

enter image description here


1 Answer 1


This is a workaround and I hope there is (or will eventually be) an easier way to access point cloud data in the API.

enter image description here

In your GN tree add an Instance on Points node, plug in a Mesh Line set to a Count of 1 to get a single vertex at $(0, 0, 0)$.

enter image description here

In theory we should be able to access the vertices' geometry but for now the geometry is not "real". We need to realize the instances with a Realize Instances node.

enter image description here

Then, we need to access the evaluated mesh, after the GN modifier has been evaluated. For that we can use the context dependency graph.

import bpy
import numpy as np

depsgraph = bpy.context.evaluated_depsgraph_get()
obj = bpy.context.active_object.evaluated_get(depsgraph)

coords = np.zeros(len(obj.data.vertices) * 3, dtype=float)
obj.data.vertices.foreach_get("co", coords)

print(coords)  # This is a flattened array

coords = coords.reshape(len(obj.data.vertices), 3)

print(coords)  # This is a 3D array

Result :

enter image description here

  • 1
    $\begingroup$ i love workaround if they work!! Great job! $\endgroup$
    – Chris
    Jun 10, 2021 at 7:18
  • 1
    $\begingroup$ Yeah, hopefully they simplify this so vertex instancing isn't needed, but for now it works so thank you! $\endgroup$ Jun 10, 2021 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.