Skip to content

Commit

Permalink
[Sub PCBs][Fixed] Using annotation method
Browse files Browse the repository at this point in the history
- For some edeges and KiCad versions

Closes #496
  • Loading branch information
set-soft committed Oct 2, 2023
1 parent 12151a7 commit c216d4b
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 22 additions & 10 deletions kibot/gs.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,34 +614,40 @@ def svg_round(val):
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):
shape = g.GetShape()
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):
Expand Down Expand Up @@ -743,3 +749,9 @@ def exit_with_error(msg, level):
else:
logger.error(msg)
exit(level)

@staticmethod
def get_shape(shape):
if GS.ki6:
return shape.ShowShape()
return shape.ShowShape(shape.GetShape())
2 changes: 1 addition & 1 deletion kibot/var_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, shape):
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):
Expand Down
13 changes: 13 additions & 0 deletions tests/test_plot/test_pcbdraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
39 changes: 39 additions & 0 deletions tests/yaml_samples/pcbdraw_sub_pcb_2.kibot.yaml
Original file line number Diff line number Diff line change
@@ -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]

0 comments on commit c216d4b

Please sign in to comment.