You need to call this piece of code at each frame (in ocpPreStep/opcPostStep or clbkPreStep/clbkPostStep). In OMX it's more complicated, but same concept, I do a loop on all vessels of the simulation, I simplified here below for you, removing all OMX specificities:
OBJHANDLE handle...