shifting indices (?!)

Ok this one has me stumped…
I am creating a mesh by defining eight points rotated around around the x axis (for reasons I won’t get into I am manually doing the math for an affine transformation), imagine an octagon. I then move along the x axis and make another, then another, to create an eight sided cylinder, N segements long.
Works fine, I can see all my vertices drawn as mesh points in the 3d window. However… when I started trying to make the faces things got wonky.

I started by fishing out the indices of the mesh and packing them into a list, then iterating over the list to make faces… but CHECK THIS… every time I run my script the faces are drawn from different indices!! huh?
Curious what might be going on I started packing a list of the indicies of each octagon as I made them, to get something like this (just the first two):
[5, 7, 0, 1, 2, 3, 4, 6]
[9, 10, 12, 13, 15, 16, 17, 18]
ok fine…
but if I run my script again I get this:
[4, 6, 0, 1, 2, 3, 5, 7]
[9, 10, 12, 13, 15, 16, 17, 18]
What the hey??? My indices are moving!!
Not to mention, some are missing…
Can anyone explain this?

And here’s the other rub: when I iterate through the indices of the mesh with
for i in mesh.verts: v.index
I get this [11, 14, 5, 7, 0, 1, 2, 3, 4, 6, 8, 9, 10, 12, 13, 15, 16, 17]
(which goes with the the first two lists above), but, no surprise, when I run it again I get this [11, 14, 4, 6, 0, 1, 2, 3, 5, 7, 8, 9, 10, 12, 13, 15, 16, 17]!
And even if I just work with the list of returned indices I can’t make sense of it’s order… because to my thinking the first face would be [4,9,10,6]… so I must be missing somethig. (BTW wherethe hell did index 11 go?! and why am I getting an 18?.. when it’s an N-1 array?!)

The whole thing smells of a -1 problem… but for the life of me I can’t figure it out.
Any ideas anyone?

vert.index is updated when you call mesh.update() [or so the docs imply]

so it could easily be wrong

vert.index is updated when you call mesh.update() [or so the docs imply]

I’m not implicitly calling mesh.update()… but that’s not to say that it isn’t being called by another funtion… however it still leaves open the question why does a query of v.index give a differnet list on each run?
Curiouser and curiouser…

BTW which docs are you looking at?

Thanks z3r0 d, mesh.update() did the trick!

For anyone else who might benefit, here’s what I’m doing:

  • creating a mesh
  • then updating*
  • then creating a list of the indices of the mesh
  • then appending faces from the list of indices
  • what I was missing before was updating. When when I didn’t it yeilded some very strange index lists ala [12, 13, 2560, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Which obviously didn’t work for appending faces