# BMesh: Accessing edges of created mesh

Let’s say I created a bunch of these cones in my_bmesh object:

c = bmesh.ops.create_cone(my_bmesh, segments=8, diameter1=1, diameter2=1, cap_ends=True)


Is there a way to access a cone’s edges (preferably right after I create it) so I could connect it with other cones using bridge edge loops?

• As Develepper myself, dynamically created object generate a random name. if you want to access them in code, you will need to use a specific sequenceand name it with that sequence. like c.Name ='my_bmesh' + [int value used as increment and stored somewhere like global variable] – Eric Brochu Jul 21 '19 at 16:24
• I don't need to name the objects; i want to connect two subsequently created cones. The problem is, bmesh.ops.create_cone() returns only a dict of vertices (AFAIK). – blusher Jul 21 '19 at 16:33
• Each vertex of bmesh has its corresponding edges. – lemon Jul 21 '19 at 16:47
• And how can I get these edges? – blusher Jul 21 '19 at 17:03
• Maybe... read the doc a bit and enhance your question when you've tried something. See docs.blender.org/api/current/… and docs.blender.org/api/current/… – lemon Jul 21 '19 at 17:13

Slice based on pre op lengths

It is my experience that new geometry is always appended after using the bmesh create operators.

Hence can look at the length of bm.faces before, and use to slice after.

A more robust result could be achieved with sets of elements prior and after.

import bpy
import bmesh
ob = bpy.context.object
me = ob.data
bm = bmesh.new()
bm.from_mesh(me)

nv, ne, nf = (len(bm.verts), len(bm.edges), len(bm.faces))
ret = bmesh.ops.create_cone(bm,
segments=3,
diameter2=2,
depth=1,
cap_ends=True)

print(len(bm.verts[nv:]), "New Verts:", [g.index for g in bm.verts[nv:]])
# check if new verts slice and op return are the same
same_verts = not bool(set(bm.verts[nv:]) - set(ret['verts']))
print("Slice and op return same verts?", same_verts)
print(len(bm.edges[ne:]), "New Edges:", [g.index for g in bm.edges[ne:]])
print(len(bm.faces[nf:]), "New faces:", [g.index for g in bm.faces[nf:]])

''' Result

4 New Verts: [8, 9, 10, 11]
Slice and op return same verts? True
6 New Edges: [12, 13, 14, 15, 16, 17]
4 New faces: [6, 7, 8, 9]

'''


Solved it:

(prev_edges -> edges from previous cone)
c = bmesh.ops.create_cone(my_bmesh)
verts = list(c.values())[0]