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.
Following this example https://docs.blender.org/api/master/bmesh.ops.html?highlight=bmesh%20ops%20bridge_loops#bmesh.ops.bridge_loops The operator example does delete ret whole time. so that's why I also did it
– cexoso Dec 29 '19 at 11:58deltheretvariable, because they're assigning it another value in the next line and want to avoid confusion. By using del they are saying that whatever was in this variable is no longer used, although the same variable name shows up shortly after. You can read it here: using del can be useful to show intent. - I know in the case of del foo that the intent is to remove the variable from scope. It's not clear that foo = None is doing that. – Leander Dec 29 '19 at 12:09the list that I get back is different
[<BMEdge(0x000001650DE89220), index=3, verts=(0x000001657B5F0130/4, 0x000001657B5F00F8/3)>]
{<BMEdge(0x000001650F812690), index=9, verts=(0x000001657B5F01D8/7, 0x000001657B5F01A0/6)>}
See the second list I got using your code It closes with } instead of with ] Any idea how to fix this ?
– cexoso Dec 29 '19 at 12:15