This code is to be run in blender 2.9 It explain how to get or convert local coordinates of a vertex to global coordinates.
#############################################################
# imports :
import bpy
from mathutils import Vector
#############################################################
Add a Cube and Get the initial local coordinates of vertex id 0,
Get the initial Cube matrix_world,
Calculate the initial vertex id 0 Global Coordinates :
bpy.ops.mesh.primitive_cube_add()
Cube = bpy.context.object
Mw = Cube.matrix_world
Vert0_Lco = Cube.data.vertices[0].co
Vert0_Gco = Mw @ Vert0_Lco
print (f"Vert 0 initial Local coordinates :\n{Vert0_Lco}") # should be (-1, -1, -1)
print (f"Cube initial Matrix world :\n{Mw}") # should be the identity Matrix
print (f"Vert 0 initial Global coordinates :\n{Vert0_Gco}") # should be (-1, -1, -1) also
#############################################################
Make a translation vector :
Translate the cube,
Get the final Cube matrix_world,
Calculate the final vertex id 0 Global Coordinates :
Trans_Vector = Vector((1,3,5))
'''Now If you want the Cube matrix_world to be updated after the translation transform dont use<<< Cube.location = Trans_Vector >>>, instead use :'''
Mw.translation += Trans_Vector
print (f"Vert 0 final Local coordinates :\n{Vert0_Lco}")#Should be the same ( (-1, -1, -1) dont change after transform)
print (f"Cube final Matrix world :\n{Mw}") # should change to :
'''
Matrix(((1, 0, 0, 1 )
(0, 1, 0, 3 )
(0, 0, 1, 5 )
(0, 0, 0, 1 )))
'''
print (f"Vert 0 final Global coordinates :\n{Vert0_Gco}") # should change to (0, 2, 4)
myObj.data.transform(Matrix.Translation((1, 3, 5)))to translate all local coordinates by (1, 3, 5) – batFINGER Jan 17 '20 at 05:03