How to export meshes that uses modifiers?

Hello,

I wanted to export mesh coordinates and I used modifier subsurf.

As far as I understand the modifier doesn’t changed the vertex
coordinates. Is there solution to export the mesh how i see it on
the screen.

Thanks for helping

Gerhard

See the obj exporter for an example
basic usage is…
mesh= Blender.Mesh.New()
mesh.getFromObject(object.name)

Heres a wrapper function agound getFromObject()


def getMeshFromObject(object, name=None, mesh=None):
	if mesh:
		mesh.verts = None # Clear the mesh
	else:
		if not name:
			mesh = Mesh.New()
		else:
			mesh = Mesh.New(name)
	
	
	type = object.getType()
	dataname = object.getData(1)
	
	try:
		mesh.getFromObject(object.name)
	except:
		return None
	
	if type == 'Mesh':
		tempMe = Mesh.Get( dataname )
		mesh.materials = tempMe.materials
		mesh.degr = tempMe.degr
		try: mesh.mode = tempMe.mode # Mesh module needs fixing.
		except: pass
		
	else:
		try:
			# Will only work for curves!!
			# Text- no material access in python interface.
			# Surf- no python interface
			# MBall- no material access in python interface.
			
			data = object.getData()
			materials = data.getMaterials()
			mesh.materials = materials
			print 'assigning materials for non mesh'
		except:
			print 'Cant assign materials to', type
	
	return mesh

or simply :
MESH=Blender.NMesh.GetRawFromObject(‘ObjectName’)

second round of:

NMesh vs Mesh

…hehehe :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue:

NMesh is dead, long live NMesh…

  • better that grasshopper here is taught the way of the Mesh.
    NMesh is water under the bridge… an embarising mistake we need not recall…

Povanim uses it? - Well it probably has embaresing code since its closed source :slight_smile:

This is a little pedantic but just say I was using
this to generate morph targets (or whatever)
from a mesh that is deformed by a skeleton.
I suppose for the gamer’s out there this is
the number one uuse for a hack like this.

Q: I need to call your magic getFromObject
each time I change the frame right?

Ie the vertices are copied as values
and not passed as references.

I guess the answer is obvious if u think about
it but I always like to be sure.

Then you just know I’m going to ask you
to put the answer in the doc don’t you.

That’s is your opinion but your are not the only script writer in this world .

Povanim uses it? - Well it probably has embaresing code since its closed source :slight_smile:

Less “embaresing” (supposed that you wanted to write “embarrassing”, i didn’t find any translation for “embaresing”)
than the intern yafray xml exporter :
http://jmsoler.free.fr/util/blenderfile/fr/povanim_yafraypovray01.htm
http://jmsoler.free.fr/util/blenderfile/fr/povanim_yafraypovray02.htm

Blender/Aqsis has this problem- theres no gaurentee verts will keep the same order or be the same number of verts- The Values are not wrapped, no.

JMS- Of course its my opinnion to stop using NMesh… people can take it or leave it. - keep your salt handy.