Skip to content

Instantly share code, notes, and snippets.

@MarilynKeller
Last active February 26, 2024 15:40
Show Gist options
  • Save MarilynKeller/be96aaac53f843ee822dbcfb6774b1b1 to your computer and use it in GitHub Desktop.
Save MarilynKeller/be96aaac53f843ee822dbcfb6774b1b1 to your computer and use it in GitHub Desktop.
Blender python script to export the selected vertices as a list of indices.
"""Blender python script to export the selected vertices as an index list."""
import bpy
import pickle
# Fetch the selected object and list all the selected vertices indices
bpy.ops.object.mode_set(mode = 'OBJECT')
obj = bpy.context.object
bpy.ops.object.mode_set(mode = 'EDIT')
verts_ind = [i.index for i in obj.data.vertices if i.select]
print(verts_ind)
# Save this list as a pickle
out_file = 'verts_indices.pkl'
pickle.dump(verts_ind,open(out_file, 'wb'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment