Skip to content

Instantly share code, notes, and snippets.

@zeffii
Last active September 26, 2015 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/1162142 to your computer and use it in GitHub Desktop.
Save zeffii/1162142 to your computer and use it in GitHub Desktop.
insert empty at selected vertices of a mesh, mesh must be back in object mode
# must select 3 verts.
import bpy
#from mathutils import Vector, Quaternion
ob = bpy.context.object
# needs to be in object mode to check the status, i think?
# check if 3 verts selected.
selected_idx = [i.index for i in ob.data.vertices if i.select]
print(len(selected_idx))
print(selected_idx)
# get vertex locations
# ob.matrix_world = full matrix.
world_coordinates = []
for idx in selected_idx:
point = ob.data.vertices[idx].co # local
world_coord = ob.matrix_world * point
bpy.ops.object.add(type='EMPTY', location=world_coord, rotation=(0, 0, 0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment