Help on getting global coordinates of a vertice.

Hi pythonheads,

I’m trying to get the global coordinates of a vertice.

This is probably very easy to do, but I don’t understand matrices. My guess is that I should multiply the vertex coordinate with the object matrix. Is this right? And how do I multiply that matrix with coordinates? Is there a function in Mathutils?

Have fun,

Wybren

Yes! I got it… It always helps posting your question. Some way or the other it makes you think about the problem, and a few minutes after you get the solution. It was indeed multiplying the object matrix with the vector of the vertex coordinates. That rotates. And afterwards add the object location to the vertex location.

Solved!

if you simply need to transform a whole mesh use mesh.transform(matrix) its literely about 100 times faster then doing it manually in python

Thanks for the tip cambo, but it’s just to get the coordinate of one point. It’s part of a bigger picture, but it’s for centering the cursor to the lower left point in the mesh, together with jmsoler’s script that centers at cursor position.

It seem that your are making this :
http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_imitshortkey.htm

Last part,
enter edit mode,
select a vertice ,
use the script ,
see the result …

Hi jms,

I just posted my reply to your other thread when I saw this. Very useful, thank you!