summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2023-10-23 12:12:42 +0200
committerjaseg <git@jaseg.de>2023-10-23 12:12:42 +0200
commitcac262ce37357f224ea0253018be74cb61ef7ef8 (patch)
treeb68c2228d24a9e5903bf9c82d9bd65757bf64c3c
parent8582b6a9724112efc19f5561fec74023d6d35552 (diff)
downloadkimesh-cac262ce37357f224ea0253018be74cb61ef7ef8.tar.gz
kimesh-cac262ce37357f224ea0253018be74cb61ef7ef8.tar.bz2
kimesh-cac262ce37357f224ea0253018be74cb61ef7ef8.zip
Improve error handling, fix error on windows
-rw-r--r--mesh_dialog.py37
1 files changed, 24 insertions, 13 deletions
diff --git a/mesh_dialog.py b/mesh_dialog.py
index 4c60bec..9812bba 100644
--- a/mesh_dialog.py
+++ b/mesh_dialog.py
@@ -190,7 +190,7 @@ class MeshPluginMainDialog(mesh_plugin_dialog.MainDialog):
mesh_zones.append(drawing.GetPolyShape())
if not mesh_zones:
- return wx.MessageDialog(self, "Error: Could not find any mesh zones on the outline pattern layer.").ShowModal()
+ return wx.MessageDialog(self, "Error: Could not find any mesh zones on the outline pattern layer.").ShowModal()
keepouts = []
for zone in self.board.Zones():
@@ -203,14 +203,24 @@ class MeshPluginMainDialog(mesh_plugin_dialog.MainDialog):
board_outlines = list(self.poly_set_to_shapely(outlines))
board_mask = shapely.ops.unary_union(board_outlines)
board_mask = board_mask.buffer(-settings.edge_clearance)
+ print('board outline bounds:', board_mask.bounds)
+ if board_mask.is_empty:
+ return wx.MessageDialog(self, "Error: Could not find the board outline, or board edge clearance is set too high.").ShowModal()
zone_outlines = [ outline for zone in mesh_zones for outline in self.poly_set_to_shapely(zone) ]
zone_mask = shapely.ops.unary_union(zone_outlines)
- mask = zone_mask.intersection(board_mask)
+ if zone_mask.is_empty:
+ mask = board_mask
+ else:
+ mask = zone_mask.intersection(board_mask)
+ print('Mesh mask bounds:', zone_mask.bounds)
keepout_outlines = [ outline for zone in keepouts for outline in self.poly_set_to_shapely(zone) ]
keepout_mask = shapely.ops.unary_union(keepout_outlines)
- mask = shapely.difference(mask, keepout_mask)
+ if not keepout_mask.is_empty:
+ mask = shapely.difference(mask, keepout_mask)
+ print('keepout mask bounds:', keepout_mask.bounds)
+ print('resulting mask bounds:', mask.bounds)
try:
def warn(msg):
@@ -261,6 +271,7 @@ class MeshPluginMainDialog(mesh_plugin_dialog.MainDialog):
width_per_trace = trace_width + space_width
grid_cell_width = width_per_trace * num_traces * 2
+ print(f'mesh cell size is {grid_cell_width}')
x0, y0 = anchor_pads[len(anchor_pads)//2].GetPosition()
x0, y0 = pcbnew.ToMM(x0), pcbnew.ToMM(y0)
@@ -598,7 +609,6 @@ def virihex(val, max=1.0, alpha=1.0):
@contextmanager
def DebugOutput(filename):
- filename = path.join('/tmp', filename)
with open(filename, 'w') as f:
wrapper = DebugOutputWrapper(f)
yield wrapper
@@ -680,15 +690,16 @@ class DebugOutputWrapper:
'xmlns:xlink': 'http://www.w3.org/1999/xlink'
}
- self.f.write(textwrap.dedent(r'''
- <?xml version="1.0" encoding="utf-8" ?>
- <svg {attrs:s}>
- {data}
- </svg>
- ''').format(
- attrs = ' '.join(['{key:s}="{val:s}"'.format(key = key, val = props[key]) for key in props]),
- data = '\n'.join(self.gen_svg(obj, *style) for obj, style in self.objs)
- ).strip())
+ if self.f is not None:
+ self.f.write(textwrap.dedent(r'''
+ <?xml version="1.0" encoding="utf-8" ?>
+ <svg {attrs:s}>
+ {data}
+ </svg>
+ ''').format(
+ attrs = ' '.join(['{key:s}="{val:s}"'.format(key = key, val = props[key]) for key in props]),
+ data = '\n'.join(self.gen_svg(obj, *style) for obj, style in self.objs)
+ ).strip())
def show_dialog(board):
dialog = MeshPluginMainDialog(board)