[sub-PCB] Now you can choose between internal implementation and KiKit

This commit is contained in:
Salvador E. Tropea 2022-12-28 08:48:50 -03:00
parent ae035a4c0e
commit 081932f8bb
4 changed files with 90 additions and 14 deletions

View File

@ -1050,6 +1050,7 @@ Note that the **_kibom_...** filters uses a field named `Config`, but you can cu
- *ref*: Alias for reference.
- **`reference`**: [string=''] Use it for the annotations method.
This is the reference for the `kikit:Board` footprint used to identify the sub-PCB.
Note that you can use any footprint as long as its position is inside the PCB outline.
When empty the sub-PCB is specified using a rectangle.
- *bottom_right_x*: Alias for brx.
- *bottom_right_y*: Alias for bry.
@ -1059,6 +1060,7 @@ Note that the **_kibom_...** filters uses a field named `Config`, but you can cu
When empty we use the parent `file_id` plus the `name` of the sub-PCB.
- `tlx`: [number|string] The X position of the top left corner for the rectangle that contains the sub-PCB.
- `tly`: [number|string] The Y position of the top left corner for the rectangle that contains the sub-PCB.
- `tool`: [string='internal'] [internal,kikit] Tool used to extract the sub-PCB..
- *top_left_x*: Alias for tlx.
- *top_left_y*: Alias for tly.
- `units`: [string='mm'] [millimeters,inches,mils,mm,cm,dm,m,mil,inch,in] Units used when omitted.
@ -1095,6 +1097,7 @@ Note that the **_kibom_...** filters uses a field named `Config`, but you can cu
- *ref*: Alias for reference.
- **`reference`**: [string=''] Use it for the annotations method.
This is the reference for the `kikit:Board` footprint used to identify the sub-PCB.
Note that you can use any footprint as long as its position is inside the PCB outline.
When empty the sub-PCB is specified using a rectangle.
- *bottom_right_x*: Alias for brx.
- *bottom_right_y*: Alias for bry.
@ -1104,6 +1107,7 @@ Note that the **_kibom_...** filters uses a field named `Config`, but you can cu
When empty we use the parent `file_id` plus the `name` of the sub-PCB.
- `tlx`: [number|string] The X position of the top left corner for the rectangle that contains the sub-PCB.
- `tly`: [number|string] The Y position of the top left corner for the rectangle that contains the sub-PCB.
- `tool`: [string='internal'] [internal,kikit] Tool used to extract the sub-PCB..
- *top_left_x*: Alias for tlx.
- *top_left_y*: Alias for tly.
- `units`: [string='mm'] [millimeters,inches,mils,mm,cm,dm,m,mil,inch,in] Units used when omitted.
@ -1142,6 +1146,7 @@ Note that the **_kibom_...** filters uses a field named `Config`, but you can cu
- *ref*: Alias for reference.
- **`reference`**: [string=''] Use it for the annotations method.
This is the reference for the `kikit:Board` footprint used to identify the sub-PCB.
Note that you can use any footprint as long as its position is inside the PCB outline.
When empty the sub-PCB is specified using a rectangle.
- *bottom_right_x*: Alias for brx.
- *bottom_right_y*: Alias for bry.
@ -1151,6 +1156,7 @@ Note that the **_kibom_...** filters uses a field named `Config`, but you can cu
When empty we use the parent `file_id` plus the `name` of the sub-PCB.
- `tlx`: [number|string] The X position of the top left corner for the rectangle that contains the sub-PCB.
- `tly`: [number|string] The Y position of the top left corner for the rectangle that contains the sub-PCB.
- `tool`: [string='internal'] [internal,kikit] Tool used to extract the sub-PCB..
- *top_left_x*: Alias for tlx.
- *top_left_y*: Alias for tly.
- `units`: [string='mm'] [millimeters,inches,mils,mm,cm,dm,m,mil,inch,in] Units used when omitted.

View File

@ -70,6 +70,7 @@ class SubPCBOptions(PanelOptions):
self.reference = ''
""" *Use it for the annotations method.
This is the reference for the `kikit:Board` footprint used to identify the sub-PCB.
Note that you can use any footprint as long as its position is inside the PCB outline.
When empty the sub-PCB is specified using a rectangle """
self.ref = None
""" {reference} """
@ -94,6 +95,8 @@ class SubPCBOptions(PanelOptions):
self.file_id = ''
""" Text to use as the replacement for %v expansion.
When empty we use the parent `file_id` plus the `name` of the sub-PCB """
self.tool = 'internal'
""" [internal,kikit] Tool used to extract the sub-PCB. """
def is_zero(self, val):
return isinstance(val, (int, float)) and val == 0
@ -255,13 +258,15 @@ class SubPCBOptions(PanelOptions):
def apply(self, comps_hash):
self._excl_by_sub_pcb = set()
if self.reference:
# Get the rectangle containing the board edge pointed by the reference
self.board_rect = self.search_reference_rect(self.reference)
# Using a rectangle
self.remove_outside(comps_hash)
# Using KiKit:
# self.separate_board(comps_hash)
if self.tool == 'internal':
if self.reference:
# Get the rectangle containing the board edge pointed by the reference
self.board_rect = self.search_reference_rect(self.reference)
# Using a rectangle
self.remove_outside(comps_hash)
else:
# Using KiKit:
self.separate_board(comps_hash)
def unload_board(self, comps_hash):
# Undo the sub-PCB: just reload the PCB
@ -273,9 +278,11 @@ class SubPCBOptions(PanelOptions):
GS.board.Add(o)
def revert(self, comps_hash):
self.restore_removed()
# Using KiKit:
# self.unload_board(comps_hash)
if self.tool == 'internal':
self.restore_removed()
else:
# Using KiKit:
self.unload_board(comps_hash)
# Restore excluded components
logger.debug('Restoring components outside the sub-PCB')
for c in self._excl_by_sub_pcb:

View File

@ -0,0 +1,63 @@
# 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: A
ref: B1
tool: kikit
- name: B
ref: B2
tool: kikit
- name: C
ref: B3
tool: kikit
outputs:
- name: 'pcb_A'
comment: "PCB A"
type: pcb_variant
options:
variant: default[A]
title: 'Hello %V'
- name: 'pcb_B'
comment: "PCB B"
type: pcb_variant
options:
variant: default[B]
title: 'Hello %V'
- name: 'pcb_C'
comment: "PCB C"
type: pcb_variant
options:
variant: default[C]
title: 'Hello %V'
- name: draw_A
comment: 'Draw PCB A'
type: pcbdraw
options:
variant: default[A]
- name: draw_B
comment: 'Draw PCB B'
type: pcbdraw
options:
variant: default[B]
- name: draw_C
comment: 'Draw PCB C'
type: pcbdraw
options:
variant: default[C]

View File

@ -13,10 +13,7 @@ variants:
type: ibom
sub_pcbs:
- name: A
tlx: 89
tly: 89
brx: 111
bry: 111
ref: B1
- name: B
ref: B2
- name: C
@ -45,16 +42,19 @@ outputs:
title: 'Hello %V'
- name: draw_A
comment: 'Draw PCB A'
type: pcbdraw
options:
variant: default[A]
- name: draw_B
comment: 'Draw PCB B'
type: pcbdraw
options:
variant: default[B]
- name: draw_C
comment: 'Draw PCB C'
type: pcbdraw
options:
variant: default[C]