Skip to content

Commit 02723e0

Browse files
committed
Fixed issue with remove_doubles
1 parent 2921a19 commit 02723e0

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

SymmetricCircle.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,30 +159,29 @@ def execute(self, context):
159159
# bmesh.ops.create_circle(bm, cap_ends=False, radius=self.radius, segments=self.segments)['verts'] # returning list of BMVert
160160

161161
# see: https://stackoverflow.com/questions/42879081/how-to-generate-a-set-of-co-ordinates-for-a-circle-in-python-using-the-circle-fo/42879185
162-
162+
circle_verts = []
163163
x,y,z = (0, 0, 0,) # Center of circle
164164
step_size = 2 * math.pi / self.segments
165165

166166
# Creating vertices:
167167
t = 0
168168
while t < 2 * math.pi:
169-
# circle_verts.append()
170-
bm.verts.new((self.radius * math.sin(t) + x, self.radius * math.cos(t) + y, z))
169+
circle_verts.append(bm.verts.new((self.radius * math.sin(t) + x, self.radius * math.cos(t) + y, z)))
171170
t += step_size
172171

173-
bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0000001)
174-
172+
bmesh.ops.remove_doubles(bm, verts=circle_verts, dist=0.0000001)
173+
circle_verts = [v for v in circle_verts if v.is_valid] # cleaning the list from <BMVert dead at ..>
175174
bm.verts.ensure_lookup_table() # You need add it when your add/remove elements in your mesh
176175
bm.verts.index_update()
177176

178177
# Creating edges and selecting vertices and edges:
179-
bm.verts[0].select = True
178+
circle_verts[0].select = True
180179

181-
for i in range(1, len(bm.verts)):
182-
bm.edges.new([bm.verts[i], bm.verts[i-1]])
183-
bm.verts[i].select = True
180+
for i in range(1, len(circle_verts)):
181+
bm.edges.new([circle_verts[i], circle_verts[i-1]])
182+
circle_verts[i].select = True
184183

185-
bm.edges.new([bm.verts[0], bm.verts[-1]]) # Creating closed edge between first and last vertices
184+
bm.edges.new([circle_verts[0], circle_verts[-1]]) # Creating closed edge between first and last vertices
186185
bm.edges.ensure_lookup_table() # You need add it when your add/remove elements in your mesh
187186
bm.select_flush_mode() # will ensure the associated edges and faces will be selected also.
188187

@@ -194,7 +193,8 @@ def execute(self, context):
194193
elif context.mode == 'EDIT_MESH':
195194
bmesh.update_edit_mesh(blender_mesh, False) # from bmesh to edit mesh (current edited mesh, copy of source mesh)
196195

197-
bm.free
196+
# bm.clear()
197+
# bm.free()
198198

199199
return {'FINISHED'} # Lets Blender know the operator finished successfully
200200

__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
bl_info = {
2222
"name": "Symmetric Primitives",
2323
"author": "Multiple Authors",
24-
"version": (0, 5, 0),
24+
"version": (0, 5, 1),
2525
"blender": (2, 80, 0),
2626
"location": "View3D > Add > Mesh",
2727
"description": "Creating symmetric primitives",

0 commit comments

Comments
 (0)