Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been scouring the Blender Python API docs for a way to get access to the mesh data that is displayed in the view-port. (with modifiers applied - WYSIWYG)

For reference, this was possible with the 2.4x API's Mesh.getFromObject method.

share|improve this question
up vote 10 down vote accepted

The option to apply modifiers is common for exporters included with Blender, so you can check how they do it.

Typically you can use the Object.to_mesh function, which returns a new mesh. You can manipulate it without distructively editing the user's data.

import bpy

# --- setup variables ---
context = bpy.context
scene = context.scene

# assume we have an object with geometry, nurbs, metaball, curves... _not_ a lamp
obj = context.object

# --- get a mesh from the object ---
apply_modifiers = True
settings = 'PREVIEW'
mesh = obj.to_mesh(scene, apply_modifiers, settings)

# ... do something with the mesh ...

It's important to remove the mesh, unless you have explicitly assigned it to an object. Otherwise it will be stored in Blender until the file is saved and loaded again.

# optionally remove it
share|improve this answer
Usually the research goes easily, finding an equivalent process in Blender 2.5+, from Blender 2.4. But sometimes these methods are moved to different classes, and that adds much time, and sometimes really impairs my progress by relying upon the community (not that it's a bad thing, after doing my homework). Thank you for your help! – Tom Pace Feb 20 '14 at 6:31
I did not need to calculate the tessfaces, so I set the extra parameter calc_tessface=False and my tests pass. Awesome. – Tom Pace Feb 20 '14 at 6:45
@Tom Pace, only if you want to use legacy access to face data (tris/quads, no ngons) -… – ideasman42 Feb 20 '14 at 8:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.