[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:
parent
2f73b3f743
commit
976e6af932
|
|
@ -206,6 +206,8 @@ def detect_kicad():
|
||||||
GS.ki6_only = GS.kicad_version_major == 6
|
GS.ki6_only = GS.kicad_version_major == 6
|
||||||
GS.ki7 = GS.kicad_version_major >= 7
|
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.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,
|
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))
|
GS.kicad_version_patch, GS.kicad_version, GS.kicad_version_n))
|
||||||
# Used to look for plug-ins.
|
# Used to look for plug-ins.
|
||||||
|
|
|
||||||
|
|
@ -317,7 +317,7 @@ class VariantOptions(BaseOptions):
|
||||||
if c and c.included and not c.fitted:
|
if c and c.included and not c.fitted:
|
||||||
# Meassure the component BBox (only graphics)
|
# Meassure the component BBox (only graphics)
|
||||||
for gi in m.GraphicalItems():
|
for gi in m.GraphicalItems():
|
||||||
if gi.GetClass() == 'MGRAPHIC':
|
if gi.GetClass() == GS.footprint_gr_type:
|
||||||
l_gi = gi.GetLayer()
|
l_gi = gi.GetLayer()
|
||||||
if l_gi == ffab:
|
if l_gi == ffab:
|
||||||
frect.Union(GS.get_rect_for(gi.GetBoundingBox()))
|
frect.Union(GS.get_rect_for(gi.GetBoundingBox()))
|
||||||
|
|
@ -667,7 +667,7 @@ class VariantOptions(BaseOptions):
|
||||||
bcrtyd = board.GetLayerID('B.CrtYd')
|
bcrtyd = board.GetLayerID('B.CrtYd')
|
||||||
bbox = Rect()
|
bbox = Rect()
|
||||||
for gi in m.GraphicalItems():
|
for gi in m.GraphicalItems():
|
||||||
if gi.GetClass() == 'MGRAPHIC':
|
if gi.GetClass() == GS.footprint_gr_type:
|
||||||
l_gi = gi.GetLayer()
|
l_gi = gi.GetLayer()
|
||||||
if l_gi == fcrtyd or l_gi == bcrtyd:
|
if l_gi == fcrtyd or l_gi == bcrtyd:
|
||||||
bbox.Union(GS.get_rect_for(gi.GetBoundingBox()))
|
bbox.Union(GS.get_rect_for(gi.GetBoundingBox()))
|
||||||
|
|
|
||||||
|
|
@ -448,9 +448,8 @@ class ReportOptions(BaseOptions):
|
||||||
def measure_pcb(self, board):
|
def measure_pcb(self, board):
|
||||||
edge_layer = board.GetLayerID('Edge.Cuts')
|
edge_layer = board.GetLayerID('Edge.Cuts')
|
||||||
x1 = y1 = x2 = y2 = None
|
x1 = y1 = x2 = y2 = None
|
||||||
draw_type = 'DRAWSEGMENT' if GS.ki5 else 'PCB_SHAPE'
|
|
||||||
for d in board.GetDrawings():
|
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)
|
bb = GS.get_shape_bbox(d)
|
||||||
start = bb.GetOrigin()
|
start = bb.GetOrigin()
|
||||||
end = bb.GetEnd()
|
end = bb.GetEnd()
|
||||||
|
|
@ -465,7 +464,7 @@ class ReportOptions(BaseOptions):
|
||||||
# This is a special case: the PCB edges are in a footprint
|
# This is a special case: the PCB edges are in a footprint
|
||||||
for m in GS.get_modules():
|
for m in GS.get_modules():
|
||||||
for gi in m.GraphicalItems():
|
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)
|
bb = GS.get_shape_bbox(gi)
|
||||||
start = bb.GetOrigin()
|
start = bb.GetOrigin()
|
||||||
end = bb.GetEnd()
|
end = bb.GetEnd()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue