XY Problem
The desired result and the question title IMO make this a bit of an XY Problem In that, as I see it, to get the result requires neither vertex indices, nor edit mode.
Firstly as mentioned (early) in @MartyFouts answer could call the bridge edge loops operator, while in mesh edit mode with all verts (edges) selected.
The verts have a creation order, using indices.
Showing vert indices, via overlay
As mentioned in RobinBetts answer to
How can I sort vertex positions sequentially indices in a closed area?
it is more than likely the case, after converting curve to mesh the vertices are in order. As shown in image 0 -> 17 on first spline, 18 -> 33 on second. To make use of this
import bmesh
import bpy
from bpy import context
r = 16
bpy.ops.curve.primitive_bezier_curve_add(location=(1.0, 0.0, 0.0), enter_editmode = 1, align = 'WORLD')
bpy.ops.curve.primitive_bezier_curve_add(location=(1.0, 1.0, 0.0), radius=1.0)
ob = context.object
ob.data.resolution_u = r
bpy.ops.curve.de_select_last( )
bpy.ops.object.editmode_toggle()
bpy.ops.object.convert(target='MESH')
# bmesh bit.
me = ob.data
bm = bmesh.new()
bm.from_mesh(me)
bm.verts.ensure_lookup_table()
# edges (0, 17), (1, 18), ... (i, i + r + 1)..
edges = [(i, i + r + 1) for i in range(r + 1)]
# faces (0, 17, 18, 1), ... walk around CCW order.
for e0, e1 in zip(edges, edges[1:]):
bm.faces.new(bm.verts[i] for i in e0 + tuple(reversed(e1)))
bm.to_mesh(me)
Without indices or toggling in out of edit mode.
As a "rule of thumb" I avoid edit mode and indices to create meshes if possible. Another way to look at this is via
Extrusion.
Can I extrude a path in x/y
Big fan of using bmesh instead of bpy.ops.mesh
to manipulate a mesh. No doubt a single bridge edge loops operator call is "easiest" in this instance, but as our destination becomes more complex, toggling modes, and setting selections to use operators (IMO) becomes tiresome (and slow if looping operator calls) quickly.
To produce same result, will add the first bezier curve as in question.
Rather than adding an offset second bezier curve and filling, will instead extrude all the edges of the original, to the location second.
Bmesh operators return a result in a dictionary. How to select extruded vertices in bmesh?
Test Script, Run in OBJECT mode.
Create first curve and convert, extrude all edges via bmesh op, then translate the extrusion created verts (all returned geometry of type bmesh.types.BMVert
) to the location of the second curve. (Image above also shows result of script below, in edit mode)
import bpy
import bmesh
from bmesh.types import BMVert
context = bpy.context
# first curve as in question.
r = 16
bpy.ops.curve.primitive_bezier_curve_add(
location=(1.0, 0.0, 0.0),
align = 'WORLD'
)
ob = context.object
ob.data.resolution_u = r
bpy.ops.object.convert(target='MESH')
# bmesh extrude'n'move
me = ob.data
bm = bmesh.new()
bm.from_mesh(me)
# extrude the edges
ret = bmesh.ops.extrude_edge_only(
bm,
edges=bm.edges,
)['geom']
bmesh.ops.translate(
bm,
verts=[e for e in ret if isinstance(e, BMVert)],
vec=(0, 1, 0),
)
bm.to_mesh(me)
me.update()
Related.
How can I create a wall(mesh) from 2 profiles and a path that connects them?
Lofting: can I copy a Shape-Keyed mesh for each frame of its animation?