How do I Export an Object's Vertex Positions?

print (bpy.context.object.data.attributes[‘My_Attribute’].data,print())

<bpy_collection[4], FloatAttribute.data> None

print (bpy.context.object.data.attributes[‘My_newpos’].data,print())

<bpy_collection[4], FloatVectorAttribute.data> None

print (bpy.context.object.data.attributes[‘Attribute’].data,print())

<bpy_collection[4], FloatColorAttribute.data> None

Did this work for you? Because even after I cleared out the smartquotes it errored, and we have two working solutions above – I’m looking to mark this solved.

it returns this, not the actual data.

<bpy_collection[8], FloatVectorAttribute.data> None

bpy.data.meshes[‘Cube.003’].attributes.values()
will tell me what attributes are on the object

[bpy.data.meshes[‘Cube.003’].attributes[‘fa’], bpy.data.meshes[‘Cube.003’].attributes[‘va’]]

but how do I get to the values within??

1 Like

Next time, do print(dir(method)) to output all of the methods, classes, functions, etc of an API element. help() & type() are also there for accessibly outputs.

Here’s how to get values of all attributes.

import bpy

o = bpy.data.objects["Suzanne"]

for a in o.data.attributes:
    print(a.data)

Or:

for a in o.data.attributes:
    for d in a.data:
        print(d)

This will list per-vertex in this case, because it’s geometry… and that can slow Blender down though.

1 Like

Thanks, but Im after these values…

thats just showing me what I know already, how do I get to access the values shown in the circle?

Sorry my python is not great…

1 Like
import bpy
o = bpy.data.objects["Suzanne"]
for a in o.data.attributes:
    for d in a.data:
        print(d.value)

Don’t take this the wrong way, but why aren’t you checking these things yourself using the methods I described? It’s easy enough to check on your own, I think.

Ah, it outputting to the system console, I didn’t have it open, Thankyou.

and no, its not easy, not when you dont have a clue.

Thankyou…

Quick edit, ok, so its returning floats and ints but no vec3 or vec4.

1 Like

This is because you’ve chosen vertex as your requested data type… if you want a different type you need to state that by changing your data type when you create your mesh attribute. Note: You can also click on the arrow icon below the plus & minus attribute icons to convert existing attributes to other data types.

If you choose a different data type, type Vector for instance you’ll need to change d.value to d.vector.

2 Likes

Thankyou.

Thats it!

1 Like

Okay! There are three good solutions in this topic, I’m linking 'em here before marking Solved:

My semi-original question 'bout exporting an object’s vertex positions got two solutions that both worked in different directions, RPaladin’s script outputting it to the Blender Console and Iceythe’s script exporting to .csv file.

AlphaChannel’s question 'bout getting other info visible in the Geometry Nodes “spreadsheet” solved with another of RPaladin’s scripts.

Thanks people, much appreciated!

1 Like