When is a mesh not a mesh?

This concerns Blender 2.37 and Python 2.35. It seems that I can get mesh data in two different ways:


mesh1 = Blender.NMesh.GetRawFromObject(objName)
mesh2 = Blender.Object.Get(objName).getData();

For most purposes, these seem identical. However:


faces = mesh1.getSelectedFaces()

Doesn’t seem to work. But


faces = mesh2.getSelectedFaces()

…does work.

Am I missing something basic here? I’m pretty new at this :-?

–SomePlexon

In Mesh1 you are getting the Object.

In Mesh2 you are getting the Mesh.

Thing is… go to your object, select it… then check the button’s window…

It should say in 2 spots ME: Nameofthemesh and OB: Nameoftheobject

The thing is that the name of the object and the name of the mesh don’t have to be the same… and that could lead to errors. so what I do:


#to get the current selected object.
MyObject = Object.GetSelected()[0].getName()

#to get the name of the mesh that's attached to that object
MyMesh = Object.GetSelected()[0].getData(1)

#to get the data from that mesh
me = NMesh.GetRaw(MyMesh)

(it’s a good idea to put all that in a try: statement as well cause the selected object may not even be a mesh and that would create errors)

After this you can get to face data through me.faces, so to get uv data from face nr one that’d be me.faces[0].uv and the normal data would be me.faces[0].no

In this code, mesh1 gets the “modified” mesh (by subsurf /armature /lattice /RVK /curve deform and taper /softBodies) like in the fixfromarmature.py script

The mesh2 gets the current state of the mesh as if you were in edit mode without subsurface faces .

For mesh1 to be correct, you’d use GetRaw with the name of the mesh.
Like jms said, GetRawFromObject returns the deformed version (from the display list), this doesn’t have much of the data that a normal mesh has.

Martin