[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.
This commit is contained in:
Salvador E. Tropea 2023-04-11 10:02:58 -03:00
parent 2f73b3f743
commit 976e6af932
3 changed files with 6 additions and 5 deletions

View File

@ -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.

View File

@ -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()))

View File

@ -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()