Snap to Empty, Code Conversion into 2.8

Dear reader,

question from a Blender Newby.

i like to measure distances between “Empty Plane Axis”, but these have no center vertex to snap to.
now i found this code in a topic here but it does not work

the Topic was from 2013, so i suppose the script is pre Blender 2.8.

could anyone help to convert this script into a 2.8 script


import bpy
sce = bpy.context.scene
sel = bpy.context.selected_objects
verts = [o.location for o in sel if o.type=='EMPTY']
mes = bpy.data.meshes.new('Empties')
mes.from_pydata(verts, [], [])
ref = bpy.data.objects.new('Empties', mes)
sce.objects.link(ref)

No clue as to what this script does, LOL. Looks like it adds a vert at empty location.

import bpy

sel = bpy.context.selected_objects
col = bpy.context.collection
verts = [o.location for o in sel if o.type=='EMPTY']
mes = bpy.data.meshes.new('Empties')
mes.from_pydata(verts, [], [])
ref = bpy.data.objects.new('Empties', mes)
col.objects.link(ref)
2 Likes

yes indeed, it should add a vertex into an empty, this way i can snap the measure tool…

awesome… thank you…