[Sub-PCB][Added] KiCad 5 workaround

- The GetBoundingBox member returns values with 1 IU of error (1 fm)
- So now we use at least 2 fm of tolerance
This commit is contained in:
Salvador E. Tropea 2023-01-02 10:42:19 -03:00
parent 16cb739ae4
commit cfee399110
4 changed files with 11 additions and 4 deletions

View File

@ -2,7 +2,7 @@
![KiBot Logo](https://raw.githubusercontent.com/INTI-CMNB/KiBot/master/docs/images/kibot_740x400_logo.png)
[![Python application](https://img.shields.io/github/actions/workflow/status/INTI-CMNB/KiBot/pythonapp.yml?branch=subpcb&style=plastic)](https://github.com/INTI-CMNB/KiBot/actions)
[![Python application](https://img.shields.io/github/actions/workflow/status/INTI-CMNB/KiBot/pythonapp.yml?branch=dev&style=plastic)](https://github.com/INTI-CMNB/KiBot/actions)
[![Coverage Status](https://img.shields.io/coveralls/github/INTI-CMNB/KiBot?style=plastic)](https://coveralls.io/github/INTI-CMNB/KiBot?branch=master)
[![PyPI version](https://img.shields.io/pypi/v/kibot?style=plastic)](https://pypi.org/project/kibot/)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg?style=plastic)](https://www.paypal.com/donate/?hosted_button_id=K2T86GDTTMRPL)
@ -1072,6 +1072,7 @@ Note that the **_kibom_...** filters uses a field named `Config`, but you can cu
- `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.
- `tolerance`: [number|string] Used to enlarge the selected rectangle to include elements outside the board.
KiCad 5: To avoid rounding issues this value is set to 0.000002 mm when 0 is specified.
- `tool`: [string='internal'] [internal,kikit] Tool used to extract the sub-PCB..
- *top_left_x*: Alias for tlx.
- *top_left_y*: Alias for tly.
@ -1125,6 +1126,7 @@ Note that the **_kibom_...** filters uses a field named `Config`, but you can cu
- `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.
- `tolerance`: [number|string] Used to enlarge the selected rectangle to include elements outside the board.
KiCad 5: To avoid rounding issues this value is set to 0.000002 mm when 0 is specified.
- `tool`: [string='internal'] [internal,kikit] Tool used to extract the sub-PCB..
- *top_left_x*: Alias for tlx.
- *top_left_y*: Alias for tly.
@ -1180,6 +1182,7 @@ Note that the **_kibom_...** filters uses a field named `Config`, but you can cu
- `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.
- `tolerance`: [number|string] Used to enlarge the selected rectangle to include elements outside the board.
KiCad 5: To avoid rounding issues this value is set to 0.000002 mm when 0 is specified.
- `tool`: [string='internal'] [internal,kikit] Tool used to extract the sub-PCB..
- *top_left_x*: Alias for tlx.
- *top_left_y*: Alias for tly.

View File

@ -103,7 +103,8 @@ class SubPCBOptions(PanelOptions):
self.tool = 'internal'
""" [internal,kikit] Tool used to extract the sub-PCB. """
self.tolerance = 0
""" [number|string] Used to enlarge the selected rectangle to include elements outside the board """
""" [number|string] Used to enlarge the selected rectangle to include elements outside the board.
KiCad 5: To avoid rounding issues this value is set to 0.000002 mm when 0 is specified """
self.strip_annotation = False
""" Remove the annotation footprint. Note that KiKit will remove all annotations,
but the internal implementation just the one indicated by `ref`.
@ -125,6 +126,9 @@ class SubPCBOptions(PanelOptions):
raise KiPlotConfigurationError('No reference or rectangle specified for {} sub-PCB'.format(self.name))
self.add_units(('tlx', 'tly', 'brx', 'bry', 'tolerance'), self.units, convert=True)
self.board_rect = GS.create_eda_rect(self._tlx, self._tly, self._brx, self._bry)
if not self._tolerance and GS.ki5:
# KiCad 5 workaround: rounding issues generate 1 fm of error. So we change to 2 fm tolerance.
self._tolerance = 2
self.board_rect.Inflate(int(self._tolerance))
def get_separate_source(self):

View File

@ -29,7 +29,7 @@ variants:
tly: 52
brx: 146
bry: 88
tolerance: 1
# tolerance: 1
outputs:
- name: 'pcb_charger'

View File

@ -27,7 +27,7 @@ variants:
tly: 52
brx: 146
bry: 88
tolerance: 1
# tolerance: 1
outputs:
- name: draw_charger