The hook is the object of last modifier.
When a modifier is added it is going to be the last one on the modifiers stack. Since the operator has added both the modifier and the empty and assigned it to the object property of the modifier, then
new_mod = obj.modifiers[-1]
new_mod.object.name = "Foo"
The whole process of adding hooks can be achieved without using the operator as demonstrated here, or any operator had the empties not been added with one
How can I animate a vertex translation of a triangular mesh?
and the "opposite" ie parenting empties to verts so they follow verts
Blender python to hook vertex and empty
Have used foreach_set to deselect all edges and faces and each vert. Basically for a 3 vertex object
me.vertices.foreach_set("select", [True, False, False])
is equivalent to
me.vertices[0].select = True
me.vertices[1].select = False
me.vertices[2].select = False
Test Script.
import bpy
obj = bpy.context.object
me = obj.data
deselect all faces and edges
me.polygons.foreach_set("select", (False,) * len(me.polygons))
me.edges.foreach_set("select", (False,) * len(me.edges))
n = len(me.vertices)
for i in range(n):
bpy.ops.object.mode_set(mode='OBJECT')
me.vertices.foreach_set("select", [i == j for j in range(n)])
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.object.hook_add_newob()
obj.modifiers[-1].object.name = f"Hook_{i}"
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.data.objects.new(...)) to avoid performance issues related to blender operators. – batFINGER Apr 12 '21 at 11:24