Face not being created


(hairu) #1

When I try to create two triangle faces, only the first one face actually gets made. However, all 6 vertices are created. Why is my second face not being created?

create 2 triangles to represent the start spot

 mesh = Mesh.New()
 vlist = []
 vlist.append( mesh.addVert(( 1.0, 0.0, 0.0 )))     
 vlist.append( mesh.addVert(( -1.0, 0.0, 0.0 )))     
 vlist.append( mesh.addVert(( 0.0, 0.0, 1.0 )))
 mesh.addFace( vlist )         
 
 del vlist[:] # clear the list
 vlist.append( mesh.addVert(( 0.0, 1.0, 0.0 )))     
 vlist.append( mesh.addVert(( 0.0, 0.0, 1.0 )))
 vlist.append( mesh.addVert(( 0.0, -1.0, 0.0 )))     
 mesh.addFace( vlist )
 
 mesh.update()

(Schlops) #2

As theeth stated in this post http://www.blender.org/modules.php?op=modload&name=phpBB2&file=viewtopic&t=472: you need a new list for every new face. (Haven’t tried it yet)


(hairu) #3

Hmm, since you can’t code for an infinite number of faces, that way I suppose if you were to write an importer you’d have to wrap the create face code in it’s own function and declare the list locally so that a new one is created every function call.


(Schlops) #4

You can also use a list of lists. If you want to append a new face you just have to append an empty list to your list. The new face goes to listoflist[len(listoflist)-1].