Skip to content

Commit

Permalink
[ERC][Added] Units
Browse files Browse the repository at this point in the history
  • Loading branch information
set-soft committed Apr 5, 2024
1 parent 1a04468 commit 9987e5e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/source/configuration/sup_globals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@
- ``time_format`` :index:`: <pair: global options; time_format>` [string='%H-%M-%S'] Format used for the time we started the script. Uses the `strftime` format.
- ``time_reformat`` :index:`: <pair: global options; time_reformat>` [boolean=true] Tries to reformat the PCB/SCH date using the `date_format`.
This assumes you let KiCad fill this value and hence the time is in ISO format (YY-MM-DD).
- ``units`` :index:`: <pair: global options; units>` [string=''] [millimeters,inches,mils] Default units. Affects `position`, `bom` and `panelize` outputs.
Also KiCad 6 dimensions.
- ``units`` :index:`: <pair: global options; units>` [string=''] [millimeters,inches,mils] Default units. Affects `position`, `bom` and `panelize` outputs and
the `erc` and `drc` preflights. Also KiCad 6 dimensions.
- ``use_dir_for_preflights`` :index:`: <pair: global options; use_dir_for_preflights>` [boolean=true] Use the global `dir` as subdir for the preflights.
- ``use_os_env_for_expand`` :index:`: <pair: global options; use_os_env_for_expand>` [boolean=true] In addition to KiCad text variables also use the OS environment variables when expanding `${VARIABLE}`.
- ``variant`` :index:`: <pair: global options; variant>` [string=''] Default variant to apply to all outputs.
Expand Down
1 change: 1 addition & 0 deletions docs/source/configuration/sup_preflights.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Supported preflights
- ``format`` :index:`: <pair: preflight - erc; format>` [string|list(string)='HTML'][RPT,HTML,CSV,JSON] Format/s used for the report.
You can specify multiple formats.

- ``units`` :index:`: <pair: preflight - erc; units>` [string='millimeters'] [millimeters,inches,mils] Units used for the positions. Affected by global options.
- ``warnings_as_errors`` :index:`: <pair: preflight - erc; warnings_as_errors>` [boolean=false] ERC warnings are considered errors, they still reported as errors, but consider it an error.

- **erc_warnings**: :index:`: <pair: preflights; erc_warnings>` [boolean=false] **Deprecated**, use the `warnings_as_errors` option from `run_erc`.
Expand Down
4 changes: 2 additions & 2 deletions kibot/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ def __init__(self):
""" Tries to reformat the PCB/SCH date using the `date_format`.
This assumes you let KiCad fill this value and hence the time is in ISO format (YY-MM-DD) """
self.units = ''
""" [millimeters,inches,mils] Default units. Affects `position`, `bom` and `panelize` outputs.
Also KiCad 6 dimensions """
""" [millimeters,inches,mils] Default units. Affects `position`, `bom` and `panelize` outputs and
the `erc` and `drc` preflights. Also KiCad 6 dimensions """
self.use_dir_for_preflights = True
""" Use the global `dir` as subdir for the preflights """
self.variant = ''
Expand Down
6 changes: 5 additions & 1 deletion kibot/pre_erc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
GENERATOR_CSS, W_ERC, W_FILXRC)
from .log import get_logger
logger = get_logger(__name__)
UNITS_2_KICAD = {'millimeters': 'mm', 'inches': 'in', 'mils': 'mils'}


def warning(msg):
Expand Down Expand Up @@ -59,6 +60,8 @@ def __init__(self):
""" ERC warnings are considered errors, they still reported as errors, but consider it an error """
self.dont_stop = False
""" Continue even if we detect ERC errors """
self.units = 'millimeters'
""" [millimeters,inches,mils] Units used for the positions. Affected by global options """
super().__init__()
self.filters = FilterOptionsXRC
self.set_doc('filters', " [list(dict)] Used to manipulate the ERC violations. Avoid using the *filters* preflight")
Expand Down Expand Up @@ -373,7 +376,8 @@ def run(self):
output = outputs[0]
os.makedirs(os.path.dirname(output), exist_ok=True)
# Run the ERC from the CLI
cmd = ['kicad-cli', 'sch', 'erc', '-o', output, '--format', 'json', '--severity-all', GS.sch_file]
cmd = ['kicad-cli', 'sch', 'erc', '-o', output, '--format', 'json', '--severity-all',
'--units', UNITS_2_KICAD[self._units], GS.sch_file]
logger.info('- Running the ERC')
run_command(cmd)
# Read the result
Expand Down
1 change: 1 addition & 0 deletions tests/yaml_samples/erc_no_w2_k8.kibot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kibot:

global:
dir: 'def_dir'
units: mils

preflight:
erc:
Expand Down

0 comments on commit 9987e5e

Please sign in to comment.