bm.faces.ensure_lookup_table() not working

Hi

I have been trying to update an old script that uses bmesh, but I have been running into a problem that I can’t seem to find any help online for.

when I run the following code:

for i in range (1,(x)):
bm.verts.ensure_lookup_table()
bm.verts.new((i,0,0))
bm.verts.new((i,y,0))
bm.faces.ensure_lookup_table()
bm.faces.new((bm.verts[4 +i], bm.verts[5 + i]))

I get the following error:

outdated index table, run ensure_lookup_table first()

the error only applies to faces, it works fine for vertices. I have tried isolating the issue, running it outside the for loop, still the same error. I even copied other people’s code, but it still won’t work. Am I missing something? Was something updated again?

I doubt anyone will see this, but in case you are wondering I fixed this by calling bm.verts.ensure_lookup_table() after each vertex was called and not calling bm.faces.ensure_lookup_faces. Dumb mistake. Looks like I need to spend more time with the manual and really learn how internal python works.

You only need to call ensure_lookup_table() right before you use indices, like verts[123]. When you create the faces, you use vertex indices, and need to call bm.verts.ensure_lookup_table() once before you do that. Iterating over the verts does not require a lookup table.

I read your post, thank you for the clarrification