From 976e6af9329cd68840a5ef1e0d46e2f3f5fa8435 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Tue, 11 Apr 2023 10:02:58 -0300 Subject: [PATCH] [KiCad 8] Adapated to the new class reported by footprint drawings - Now that all drawings are PCB_SHAPE, the GetClass doesn't report MGRAPHIC anymore. --- kibot/__main__.py | 2 ++ kibot/out_base.py | 4 ++-- kibot/out_report.py | 5 ++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/kibot/__main__.py b/kibot/__main__.py index df19ef29..81738b8c 100644 --- a/kibot/__main__.py +++ b/kibot/__main__.py @@ -206,6 +206,8 @@ def detect_kicad(): GS.ki6_only = GS.kicad_version_major == 6 GS.ki7 = GS.kicad_version_major >= 7 GS.ki8 = (GS.kicad_version_major == 7 and GS.kicad_version_minor >= 99) or GS.kicad_version_major >= 8 + GS.footprint_gr_type = 'MGRAPHIC' if not GS.ki8 else 'PCB_SHAPE' + GS.board_gr_type = 'DRAWSEGMENT' if GS.ki5 else 'PCB_SHAPE' logger.debug('Detected KiCad v{}.{}.{} ({} {})'.format(GS.kicad_version_major, GS.kicad_version_minor, GS.kicad_version_patch, GS.kicad_version, GS.kicad_version_n)) # Used to look for plug-ins. diff --git a/kibot/out_base.py b/kibot/out_base.py index 84d02919..470e8066 100644 --- a/kibot/out_base.py +++ b/kibot/out_base.py @@ -317,7 +317,7 @@ class VariantOptions(BaseOptions): if c and c.included and not c.fitted: # Meassure the component BBox (only graphics) for gi in m.GraphicalItems(): - if gi.GetClass() == 'MGRAPHIC': + if gi.GetClass() == GS.footprint_gr_type: l_gi = gi.GetLayer() if l_gi == ffab: frect.Union(GS.get_rect_for(gi.GetBoundingBox())) @@ -667,7 +667,7 @@ class VariantOptions(BaseOptions): bcrtyd = board.GetLayerID('B.CrtYd') bbox = Rect() for gi in m.GraphicalItems(): - if gi.GetClass() == 'MGRAPHIC': + if gi.GetClass() == GS.footprint_gr_type: l_gi = gi.GetLayer() if l_gi == fcrtyd or l_gi == bcrtyd: bbox.Union(GS.get_rect_for(gi.GetBoundingBox())) diff --git a/kibot/out_report.py b/kibot/out_report.py index 53b4094e..84a0e702 100644 --- a/kibot/out_report.py +++ b/kibot/out_report.py @@ -448,9 +448,8 @@ class ReportOptions(BaseOptions): def measure_pcb(self, board): edge_layer = board.GetLayerID('Edge.Cuts') x1 = y1 = x2 = y2 = None - draw_type = 'DRAWSEGMENT' if GS.ki5 else 'PCB_SHAPE' for d in board.GetDrawings(): - if d.GetClass() == draw_type and d.GetLayer() == edge_layer: + if d.GetClass() == GS.board_gr_type and d.GetLayer() == edge_layer: bb = GS.get_shape_bbox(d) start = bb.GetOrigin() end = bb.GetEnd() @@ -465,7 +464,7 @@ class ReportOptions(BaseOptions): # This is a special case: the PCB edges are in a footprint for m in GS.get_modules(): for gi in m.GraphicalItems(): - if gi.GetClass() == 'MGRAPHIC' and gi.GetLayer() == edge_layer: + if gi.GetClass() == GS.footprint_gr_type and gi.GetLayer() == edge_layer: bb = GS.get_shape_bbox(gi) start = bb.GetOrigin() end = bb.GetEnd()