Skip to content

Commit

Permalink
Fix error when creating board edge edges that already exists (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
30350n committed Sep 24, 2023
1 parent 192f1ee commit 41d3890
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions pcb2blender_importer/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,14 +729,26 @@ def improve_board_mesh(context, obj):
bm = bmesh.new()
bm.from_mesh(obj.data)

# TODO: these layers should be created with numpy, not bmesh

board_edge = bm.faces.layers.int.new(LAYER_BOARD_EDGE)
through_holes = bm.faces.layers.int.new(LAYER_THROUGH_HOLES)

board_edge_verts = set()
for face in bm.faces:
if abs(face.normal.z) < 1e-3 and face.calc_area() > 1e-10:
face[board_edge] = 1
board_edge_verts = board_edge_verts.union(face.verts)
if face.calc_area() > 1e-10:
if abs(face.normal.z) > 1e-3:
continue
else:
lastsign = np.sign(face.verts[0].co.z)
for vert in face.verts[1:]:
if lastsign != (lastsign := np.sign(vert.co.z)):
break
else:
continue

face[board_edge] = 1
board_edge_verts = board_edge_verts.union(face.verts)

midpoint = len(bm.verts) // 2
bm.verts.ensure_lookup_table()
Expand Down

0 comments on commit 41d3890

Please sign in to comment.