0

good evening. I am developing a little program with Python, and I need the coordinates of every vertex in a project written somewhere, since making it manual would take a lot of time. Since blender (as far as I know) it was written in Python, I suppose that this information must be stored in some place. However, I was unable to find it. i tried looking in the code but is impossible to understand.someone knows where this information might be?

  • 1
    Blender is written in C/C++/Python, and as a user you can access a lot of the engine with Python, a.k.a. import bpy. That aside, what you mean with "every vertex in a project written somewhere" and how would you actually do that manually (this would give hints what you are trying to achieve). Maybe this direction is helpful https://blender.stackexchange.com/questions/1311/how-can-i-get-vertex-positions-from-a-mesh – taiyo Dec 01 '23 at 19:36
  • 1
    Maybe have a look to Blender Python documentation? Or please provide a more accurate question. – lemon Dec 01 '23 at 19:36

1 Answers1

1

The "data" of an object can be accessed from Python in several ways, but the most direct way to access the vertices coordinates of the active object is with:
bpy.context.active_object.data.vertices[0].co[0]
This gives you the X coordinate of the first vertex

To print all the coordinates of every vertex the active object:

for v in bpy.context.active_object.data.vertices:
   print(v.co[:])

To print every coordinate of every vertex in all meshes in your scene:

 for obj in bpy.context.scene.objects:
    if obj.type == 'MESH':
       for v in obj.data.vertices:
          print(v.co[:])

To read the output from the print statement you will need to either run this line by line in Blenders console, or start Blender from a terminal and run it from the text editor... Of course if you run it from the text editor you'll need import bpy at the top

Psyonic
  • 2,319
  • 8
  • 13