 # Global coordinates

Hi,
how can I get the global coordinates with python ??

I use

``````for f in ob.faces:
for v in f.v:
``````

that to get coordinates, but these are LOCAL …

You need to multiply the local coordinate by the object’s matrix like this:

``````    sce = bpy.data.scenes.active
ob = Object.Get("My_object")
me = ob.getData(mesh=1)
Global_coordinates = {}
for v in me.verts:
Global_coordinates[v.index] = v.co * ob.mat
print Global_coordinates
print

``````

ob.mat is the same as ob.matrix and it’s the same as ob.matrixWorld Regards,

THX
how did you find that out ??

Is that why for exporting a cube with my script here: http://blenderartists.org/forum/showthread.php?t=169916

A default cube of size 1 centered on 0 gets for one of its faces >> 4 vertices:

GL11.glVertex3f(1.0f, 0.999999940395f, -1.0f);
GL11.glVertex3f(1.0f, -1.0f, -1.0f);
GL11.glVertex3f(-1.00000011921f, -0.999999821186f, -1.0f);
GL11.glVertex3f(-0.999999642372f, 1.00000035763f, -1.0f);

Im really confused why they are not all either +/-1 and not really weird like some of the above…

Double post

i had problems with that one too.
I would like to point the opposite, Global to Local:

``````
import Blender, bpy
from Blender.Mathutils import *

sce = bpy.data.scenes.active
ob = Object.Get("My_object")
me = ob.getData(mesh=1)
Global_co = [Vector([1,1,1]),Vector([2,2,2]),Vector([3,3,3])]

for v in me.verts:
v.co = ob.mat.rotationPart()*(Global_co[v.index]-ob2mat.translationPart())

``````

You ALWAYS need to consider a threshold to coordinates. It may be about 0.00001 or similar. That’s Blender imprecision…

Regards,