r/blenderpython • u/bwerf • Mar 22 '15
Python access to vertices, polygons, topology etc
I'm working on a school project about mesh decimation and thought that blender would be a good place to test things - and make illustrations of course. Can I access vertices, polygons and topology directly from python, or do I have to make something more low level to try these things out?
3
Upvotes
View all comments
Show parent comment
2
u/bwerf Mar 22 '15 edited Mar 22 '15
Nice! Any hint on how I would go about doing that? Everything vertices etc in bpy.types.Mesh seems to be read only, so I assume that's not the way to go? Or should I create a new mesh with Mesh.from_pydata(vertices, edges, faces)? That seems like a very inefficient way of doing it.
Also, only way I found of getting access to the Mesh is through object.to_mesh() which creates a copy of the mesh. This also seems very inefficient, so I'm starting to suspect that I'm on the completely wrong track here.
EDIT: Maybe bpy.ops.mesh is a better way to go? Everything here seems to be dictated by selection though and I can't really see how I can select anything by index.
I solved the object.to_mesh() duplication problem by doing mesh = bpy.data.meshes[object.name] instead.