This below is my code that is trying to put empties over the verts on the selected mesh but for some reason every time I run the code blender just crashes. I am testing the code on the basic cube.

import bpy
from bpy import context
i = 0
c = 7
obj = context.active_object

while not i == c:
    v = obj.data.vertices[i]
    co_final = obj.matrix_world @ v.co
    obj_empty = bpy.data.objects.new("Point", None)
    obj_empty.location = co_final
    i + 1
  • 2
    $\begingroup$ It shouldn't crash; it loops forever. i + 1 should be i += 1. But it'd be better to use for v in obj.data.vertices: .... $\endgroup$ – scurest Jan 23 at 5:17
  • 2
    $\begingroup$ .... looping forever while adding an object will ultimately hang or crash blender. Can kill a script by pressing Ctrl-C over the system console. (IMO always have system console open when writing scripts). As above adds empties with global coords Can also make the object the empty's parent obj_empty.parent = obj and then set obj_empty.location = v.co to give empties coords matching the underlying verts. $\endgroup$ – batFINGER Jan 23 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.