I'm assuming, that bm
is a bmesh
object. Obviously, the bmesh object will hold all verts, edges and faces that you add to it with any operation.
You should improve the following
- Don't
del ret
. It should be put in a global scope where ret is accessible later anyways. If it goes out of scope python will delete it automatically. You're using a dynamic interpreter language, so you can use its features. Even just not pointing to the return variable bmesh.ops.create_circle(bm, ... )
will delete the pointer.
- Your code won't compile. Always post working code snippets (mwe) in question. You'll be saving everyone a lot of time. (A) Others won't have to rewrite your code and (B) your problem may be in the code you didn't post.
- Read the documentation. The method
bmesh.ops.create_circle
actually return a dictionary with the newly created vertices.
From the api:
Returns
verts
: output verts
type list of (bmesh.types.BMVert
)
Return type
dict with string keys
With the returned dict we can point to the verts. (Obviously, now that we're using the returned object ret
don't delete it.)
verts = ret['verts']
Each vertex stores the linked edges.
verts[0].link_edges
The updated snippet could look like this.
import bmesh
bm = bmesh.new()
ret = bmesh.ops.create_circle(
bm,
cap_ends=False,
radius=(10),
segments=5,
)
verts = ret['verts']
edges = set()
for vert in verts:
for edge in vert.link_edges:
edges.add(edge)
edges = list(edges)
So, what's going on at the end? Why are we creating a set()
and then converting it to a list?
Each vertex of the circle, will have two link_edges
. However, the connected vertices will share an edge. This means, that if we just add all of the linked edges into a big list, each edge will show up twice. That's why, I use a python set. In a set each element is unique. Adding items to a set with the add()
method will not do anything if the element (the next edge) is already present in the set.