0
$\begingroup$

I want to write a function that prints the location of all of the vertices of an active object.

I have a Cube and I want to print out the location of the 8 vertices of the cube. I started doing this but I dont really know what I am doing.

def printVertices() :
       Cube = bpy.context.active_object
       lemesh = obj.data
       print(lesmesh.vertices[0].co.x)
$\endgroup$
1
  • 2
    $\begingroup$ Please don't ask the same question many times. If you are not getting answers, or the answers don’t help, then edit your original post with more information and detailing what you have tried that is not working. Read: What should I do if no one answers my question? $\endgroup$
    – susu
    Jan 3, 2021 at 18:49

1 Answer 1

1
$\begingroup$

Assuming your object is selected, the following code should work:

import bpy

for vert in bpy.context.active_object.data.vertices:
    print (vert.co)

I will also point out blender has an integrated terminal where you can type incomplete python statements (e.g bpy.context.active_object.data.) and press tab in order to print a display of the possible completions. This is very useful to quickly navigate over the properties of bpy objects and gain quick intuition on what you can and can't do.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .