Help porting code from 2.49a to 2.62

Compiling, libraries, modules, coding guidelines and porting

Moderators: jesterKing, stiv

Post Reply
Posts: 1
Joined: Thu May 31, 2012 8:46 pm
Location: NY, NY

Help porting code from 2.49a to 2.62

Post by adelie » Thu May 31, 2012 9:04 pm


I have a module that I wrote that converts mesh vertices into gcode, for CNC work. I'm having difficulty porting this to 2.62.

Code: Select all

from Blender import Mesh, Scene
import BPyMesh
import numpy as np

scn = Scene.GetCurrent()
ob = scn.getActiveObject()
me = BPyMesh.getMeshFromObject(ob) # gets a mesh from the object with modifiers applied, also so transform wont effect the original mesh data.
me.transform(ob.matrixWorld) # transforms the mesh by the loc/size/rot of the object

coordinates = []
for v in me.verts:

I've tried this but I need to get the global coords, not the local ones:

Code: Select all

import bpy

myobj =
coordinates = []
for v in me.vertices:

what is the equiv. to:
me = BPyMesh.getMeshFromObject(ob)

Thanks much.

Posts: 35
Joined: Wed Apr 18, 2012 10:04 am

World coordinates

Post by dom107 » Mon Jun 04, 2012 11:13 am


I'm a very recent Blender script learner... :D

From my knowledge:

# World coordinates:
world_v = * ob.matrix_world

as for the last question:

Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Post by CoDEmanX » Mon Jun 04, 2012 11:57 pm

you better port it to 2.63 (bmesh) if you plan to update Blender periodically...

with modifiers applied:

Code: Select all

import bpy

ob = bpy.context.object
me = ob.to_mesh(bpy.context.scene, True, 'PREVIEW') # or 'RENDER'


coordinates = [] 
for v in me.vertices: 
# to_mesh() creates a new mesh, should remove it if not needed afterwards
I'm sitting, waiting, wishing, building Blender in superstition...

Post Reply

Who is online

Users browsing this forum: Yahoo [Bot] and 0 guests