Global coordinates

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 =
    ob = Object.Get("My_object")
    me = ob.getData(mesh=1)
    Global_coordinates = {}
    for v in me.verts:
        Global_coordinates[v.index] = * ob.mat
    print Global_coordinates

ob.mat is the same as ob.matrix and it’s the same as ob.matrixWorld:wink:


how did you find that out ??

Is that why for exporting a cube with my script here:

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

Thanks for the answer
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 =
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: = 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…