[Bf-python] Mesh.Face() constructor
Ken Hughes
khughes at pacific.edu
Thu Mar 2 06:31:16 CET 2006
Chris Want wrote:
> Hi Ken,
>
> It was me alright!
>
> Basically all I'm trying to do is update a piece of code
> (a bridge between the python API of the VTK library)
> that got broken when the NMesh API stopped allowing edges
> as faces with 2 vertices. Since I am updating, I thought
> it would be best to move to the Mesh module at this time.
>
> I know that if I have a mesh, I can add a face with
> something like:
>
> me.faces.extend(me.verts[i], \
> me.verts[i+1]), \
> me.verts[i+2])
>
> But I want to assign vertex colors to the face too
> ... what is the best way to access this face towards this
> end? Do I need to get a handle to the face directly after adding
> it using something like f= me.faces[-1] (I think that's how
> you get the last item in a list), or is there a better way?
> This was the reason I was looking for come kind of constructor
> for a face.
Yes, once you've created the face you can access it with me.faces[-1],
although as Cam points out you have to be sure it really added the face
before you do this (if the face already exists in the mesh, or has
duplicate vertices, it is ignored).
> One thing that would be good is if the examples in the
> docs were updated to show a situation where you are
> creating a mesh and verts and faces from scratch, not
> just accessing data in a pre-existing mesh.
The examples are there, but they are shown with the .extend() methods.
I think I discussed this with Toni once before; maybe we need some
examples on the wiki (hey, maybe in the Manual under the Python section)
which show how to do things. I wouldn't mind writing some stuff for
that, or maybe Cam already has some simple examples lying around.
Ken
More information about the Bf-python
mailing list