export verticies after render

I’m looking for a way to export an objects vertices’ x & y coordinates as seen from a camera. Anyone know a script that would do this?

import BPyMesh
from Blender import *
[viewmtx = Window.GetViewMatrix](file:///cvs_blender/blender/source/blender/python/api2_2x/doc/BPY_API/Window-module.html#GetViewMatrix)()
scn = Scene.GetActive()
ob = scn.objects.active
me = BPyMesh.getMeshFromObject(ob)
me.transform([viewmtx](file:///cvs_blender/blender/source/blender/python/api2_2x/doc/BPY_API/Window-module.html#GetViewMatrix)) # probably should use [viewmtx](file:///cvs_blender/blender/source/blender/python/api2_2x/doc/BPY_API/Window-module.html#GetViewMatrix) * ob.matrixWorld but this will work
for v in me.verts: print v.co.x, v.co.y

thanks, but it stops around line 4 where it cant find the attribute “GetActive”. Am i doing something wrong?

Try making:
scn = Scene.GetActive()
ob = scn.objects.active

scn = Scene.GetCurrent()
ob = scn.getActiveObject()

Guessing it was for cvs version api.

sorry, Scene.GetCurrent(), I didnt test…

it works now but I’m getting the numbers as would be seen if the object were on a coordinate plane. i was looking for something that would give the coordinates of an object as if you rendered a picture at an angle and used the pixel x and pixel y as coordinates.

if i run the script on the default opening cube, it outputs;

1.0 0.999999940395
1.0 -1.0
-1.00000011921 -0.999999821186
-0.999999642372 1.00000035763
1.00000047684 0.999999463558
0.999999344349 -1.00000059605
-1.00000035763 -0.999999642372
-0.999999940395 1.0

shouldnt it be more sporadic? having no verticies overlapping?

underclocker: Verts have z value too. That explains the overlapping of x an y values.

i know that, but when you render a picture you end up with a 2d image, i am looking for the
coordinates of the verticies relative to a corner of that image, which would end up being an x and y value.

underclocker, may be worth looking at ao2’s vector exporter of sflender