[Sub PCBs][Fixed] Using annotation method

- For some edeges and KiCad versions

Closes #496
This commit is contained in:
Salvador E. Tropea 2023-10-02 10:05:33 -03:00
parent 12151a7356
commit c216d4bfde
5 changed files with 77 additions and 11 deletions

View File

@ -65,6 +65,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- *Sheetfile* mismatch on KiCad 7 when testing from different directory
- Dependencies downloader:
- Problems when connection timed-out
- Sub PCB separation using annotation method for some edeges and KiCad
versions (#496)
## [1.6.3] - 2023-06-26

View File

@ -614,17 +614,23 @@ class GS(object):
def is_valid_pcb_shape(g):
return g.GetShape() != pcbnew.S_SEGMENT or g.GetLength() > 0
@staticmethod
def v2p(v):
if GS.ki7:
return pcbnew.wxPoint(v.x, v.y)
return v
@staticmethod
def get_start_point(g):
shape = g.GetShape()
if GS.ki6:
if shape == pcbnew.S_CIRCLE:
# Circle start is circle center
return g.GetStart()+pcbnew.wxPoint(g.GetRadius(), 0)
return g.GetStart()
return GS.v2p(g.GetStart())+pcbnew.wxPoint(g.GetRadius(), 0)
return GS.v2p(g.GetStart())
if shape in [pcbnew.S_ARC, pcbnew.S_CIRCLE]:
return g.GetArcStart()
return g.GetStart()
return GS.v2p(g.GetArcStart())
return GS.v2p(g.GetStart())
@staticmethod
def get_end_point(g):
@ -632,16 +638,16 @@ class GS(object):
if GS.ki6:
if shape == pcbnew.S_CIRCLE:
# This is closed start == end
return g.GetStart()+pcbnew.wxPoint(g.GetRadius(), 0)
return GS.v2p(g.GetStart())+pcbnew.wxPoint(g.GetRadius(), 0)
if shape == pcbnew.S_RECT:
# Also closed start == end
return g.GetStart()
return g.GetEnd()
return GS.v2p(g.GetStart())
return GS.v2p(g.GetEnd())
if shape == pcbnew.S_ARC:
return g.GetArcEnd()
return GS.v2p(g.GetArcEnd())
if shape == pcbnew.S_CIRCLE:
return g.GetArcStart()
return g.GetEnd()
return GS.v2p(g.GetArcStart())
return GS.v2p(g.GetEnd())
@staticmethod
def get_shape_bbox(s):
@ -743,3 +749,9 @@ class GS(object):
else:
logger.error(msg)
exit(level)
@staticmethod
def get_shape(shape):
if GS.ki6:
return shape.ShowShape()
return shape.ShowShape(shape.GetShape())

View File

@ -43,7 +43,7 @@ class Edge(object):
self.end = GS.get_end_point(shape)
self.r_end = round_point(self.end)
self.shape = shape
self.cls = shape.ShowShape()
self.cls = GS.get_shape(shape)
self.used = False
def get_other_end(self, point):

View File

@ -192,3 +192,16 @@ def test_pcbdraw_sub_pcb_bp(test_dir):
ctx.expect_out_file(fname_b+'connector.svg')
ctx.compare_image(fname_b+'connector.svg', height='100%', tol=10)
ctx.clean_up(keep_project=True)
def test_pcbdraw_sub_pcb_2(test_dir):
""" Test a multiboard example """
prj = 'multiboard'
ctx = context.TestContext(test_dir, prj, 'pcbdraw_sub_pcb_2', '')
ctx.run()
# Check all outputs are there
fname_b = prj+'-top_'
ctx.expect_out_file(fname_b+'battery.svg')
ctx.expect_out_file(fname_b+'charger.svg')
ctx.expect_out_file(fname_b+'connector.svg')
ctx.clean_up(keep_project=True)

View File

@ -0,0 +1,39 @@
# Example KiBot config file
kibot:
version: 1
global:
hide_excluded: true
pcb_finish: ENIG
solder_mask_color: blue
variants:
- name: 'default'
comment: 'Default variant'
type: ibom
sub_pcbs:
- name: charger
reference: B1
- name: battery
reference: B2
- name: connector
reference: B3
outputs:
- name: draw_charger
comment: "Draw PCB charger"
type: pcbdraw
options:
variant: default[charger]
- name: draw_battery
comment: "Draw PCB battery"
type: pcbdraw
options:
variant: default[battery]
- name: draw_connector
comment: "Draw PCB connector"
type: pcbdraw
options:
variant: default[connector]