question about python Mesh thingy

Could somehow show me how I can print out a list of faces of a object in blender?

And how to create a mesh with python.

Greets,
Timothy

blender.nl had a few good informations about low level mesh in python. i downloaded them all.also as far i remember the french-blender site also had a few good tutorials in it(i am not sure the site is right! :frowning: )about it.i downloaded them too.unfortunately i forgot the URL.sorry :frowning: .

I don’t know what it is you want to print out (vertex locations? normals?)
so here is a simple mesh creation example:


# creates a simple triangle in top view

from Blender import NMesh, Window

# create a new mesh
newmesh = NMesh.GetRaw()

# create the three vertices of a triangle
v1 = NMesh.Vert(0, 0, 0)
v2 = NMesh.Vert(1, 0, 0)
v3 = NMesh.Vert(0, 1, 0)

# add them to the mesh.verts list
newmesh.verts.append(v1)
newmesh.verts.append(v2)
newmesh.verts.append(v3)

# create the face data for the triangle
face = NMesh.Face()

# append the newly created vertices to this face
# FROM THE MESH.VERTS LIST, NOT THE VERTICES DIRECTLY!
face.v.append(newmesh.verts[0])
face.v.append(newmesh.verts[1])
face.v.append(newmesh.verts[2])

# add the face to the mesh.faces data
newmesh.faces.append(face)

# return it to blender
NMesh.PutRaw(newmesh, "TRI_MESH")

# refresh all windows to make it visible
# including the edit button window
Window.RedrawAll()

HeyHo!

The second half (“Function Plotter”) of callis & strubis excellent python-tut should enlighten you ;): http://www.blenderbuch.de/tutor/python3/Python3_Eng.html
Especially the “Basic Knowledge: Face Definition” Part

Hey,

Thanks guys,… this was about what I needed to know.

Hopefully it will be enough for me to test my subsurf algorithm (yeah yeah I know blender already has subsurf,… but I thought it would still be fun to code it).

Anyways,… I figured out how to access the faces and vertexes of a mesh. And your example is quite clear on how to add a mesh Eeshlo, thanx.

I’ll take a look at that python tute from strubi aswell.

anyways,… Thanks again, and cya laters

Greetings,
Timothy Kanters

hey kib,
i’ll tell you what would be cool, as an improvement on blender’s implementation of subsurfs. if you could control subsurf strength the way some packages can, to make hard edges and creases. maybe you could use the colour of the vertices to make it interactive.

eg-> intensity of colour (using only shades of grey) to determine strength of subsurf, like nurbs wieght option.

what do ya think? too much work?

BEAT

not possible with the current python API,

materials are assigned per face,…

the only thing asigned per vertex are asfar as I know the armature weight groups,… if I had access to these I could quite easily write a edge (or vertex) weight setting

You can however retrieve vertex color, which is vertex based.

Martin

You can however retrieve vertex color, which is vertex based.

Every vertex of a face has a color:

face.col[0].r, face.col[0].g, face.col[0].b
face.col[1].r, …
face.col[2].r, …
or/and
face.col[3].r, …

… and in this case, colors are face based.

http://jmsoler.free.fr/didacticiel/blender/tutor/english/python_script01.htm

jm