In order to solve an other question of mine, I'd like to know how to adapt this script (contributed by @zeffii) in order to show (in edit mode) the indices of vertices for a lattice.
The N-panel with the bpy.app.debug = True trick seems to work only for meshes.
I would be curious to know if the rationale for assigning an index to a lattice vertex is more simple than for a mesh one.
EDIT
Regarding this last question, assigning an index to a lattice vertex seems to be simple. In the source code of blender, one can find the following:
int BKE_lattice_index_from_uvw(Lattice *lt,
const int u, const int v, const int w)
{
const int totu = lt->pntsu;
const int totv = lt->pntsv;
return (w * (totu * totv) + (v * totu) + u);
}
void BKE_lattice_index_to_uvw(Lattice *lt, const int index,
int *r_u, int *r_v, int *r_w)
{
const int totu = lt->pntsu;
const int totv = lt->pntsv;
*r_u = (index % totu);
*r_v = (index / totu) % totv;
*r_w = (index / (totu * totv));
}
So it is possible to define some handy functions in Python:
import bpy
def lattice_index_from_uvw(lat, u, v, w):
totu = lat.points_u
totv = lat.points_v
return w * (totu * totv) + (v * totu) + u
def lattice_index_to_uvw(lat, index):
totu = lat.points_u
totv = lat.points_v
return (index % totu, (index // totu) % totv, (index // (totu * totv)))
lat = bpy.data.lattices['Lattice']
for w in range(lat.points_w):
for v in range(lat.points_v):
for u in range(lat.points_u):
print('u = ' + str(u) + ', v = ' + str(v) + ', w = ' + str(w) + ', index:' + str(lattice_index_from_uvw(lat, u, v, w)))
for i in range(len(lat.points)):
u, v, w = lattice_index_to_uvw(lat, i)
print('u = ' + str(u) + ', v = ' + str(v) + ', w = ' + str(w) + ', index:' + str(i))