Get lattice points' positions at specific frame when animated by another object (through hook modifiers)

Hi,
I am currently developing an exporter for FFDs (Lattice).
I currently have support for FFDs animated through shape keys but now I have encountered a lattice whose points are driven by another object, rather than being animated itself, e.g. the lattice points’ positions are being driven by hooks (through the hook modifier). These hooks are defined as empty-objects, one for every point in the lattice that should be animated. And the empty-objects are animated by an Armature.
With this setup, how can I get the position of a specific lattice point at a specific frame in python?

Any comment that can get me in the right direction is greatly appreciated!
Thanks

Currently I have found that I’m able to get the target object of a hook modifier through
lattice.modifiers[n].object. Within the object I have also seen that the local and world matrices update with the animation. However I’m not sure how I would know which empty object affects which lattice point. I suppose the empty object’s position and the lattice point are supposed to be at the exact same position, but is that a guarantee? I have been trying to multiply a hook’s position with its world matrix, but it doesn’t match the position I get when de-parenting it from the armature

I have succeeded in finding a way with the help of Frederik’s answer (here: https://blender.stackexchange.com/questions/110629/get-lattice-points-positions-at-specific-frame-when-animated-by-another-object), but it is not very clean. It only works when animating with hooks, the hook strength needs to be 1.0 and the starting position of the hook needs to match that of the lattice point that it should control.

I get all hook modifiers on the lattice (lattice.modifiers[i].type == 'HOOK') and save their position (hookModifier.center) and compare that to each point’s position (point.co) in the lattice to know what hookModifier is affecting which point. I’m using math.isclose for each of x, y and z here.

I get the position of the hook for each frame by doing the following:

bpy.context.scene.frame_set(frame)
pos = lattice.matrix_world.inverted() * hook.matrix_world.to_translation()

As I’m exporting the lattice points in local space (and the object’s world position, rotation and scale) I have to multiply the hook’s world position with the inverse world matrix of the lattice to get it into the lattice local space.

Note that bpy.context.frame_set() is a heavy operation so only use it when necessary.

If any of you have any suggestions on optimizing my solution, please present them.