From 13d004ac073f4976c3ff1043f917e23f8fe06f10 Mon Sep 17 00:00:00 2001 From: Seth K <44306652+sethkaz@users.noreply.github.com> Date: Wed, 19 Jul 2023 16:36:12 -0700 Subject: [PATCH 01/18] Add github actions readme with first pass info. --- docs/GITHUB-ACTIONS-README.md | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 docs/GITHUB-ACTIONS-README.md diff --git a/docs/GITHUB-ACTIONS-README.md b/docs/GITHUB-ACTIONS-README.md new file mode 100644 index 00000000..0ec7a146 --- /dev/null +++ b/docs/GITHUB-ACTIONS-README.md @@ -0,0 +1,72 @@ +# Guide for using KiBot with Github Actions. + +This is a guide for getting started using KiBOT with Github Actions + +## Basics + +[Github Actions](https://github.com/actions) is a CI system that runs on Github. It uses [YAML files](https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html) to define what actions it will take. Unfortunately, some of those actions are a bit cryptic. This guide will try to shed light on those cyptic portions. + + + +### Basic github file + +Must be located at `{repo root}/.github/workflows/{meaningful_name}.yml +```yaml +name: KiBot_GitHub_Actions # Can be any name +on: [push, pull_request] # github triggers for running this. +jobs: # List of jobs to be run. Can be used to better organize steps. + KiBot-Generation: # Can be any name + runs-on: ubuntu-latest # Don't change + container: ghcr.io/inti-cmnb/kicad7_auto:latest # Don't Change, except if needing older version of KiCAD. + + steps: + - name: Checkout repo + uses: actions/checkout@v3 # Github built-in repo checkout step. + + # Start of the KiBot steps + - name: Run KiBot + run: | + kibot -e "project_name.kicad_sch" +``` + + +### Basic KiBOT file +This file will match the syntax and keywords described in the [readme](../README.md). +```yaml +kibot: + version: 1 + +preflight: + run_erc: true + run_drc: true + check_zone_fills: true + +outputs: + - name: 'Print Schema as PDF' + comment: "Print schematic (PDF)" + type: pdf_sch_print + dir: schematics + options: + output: '%p-Schematic.%x' +``` + +## Github-specific details + +The `uses: actions/checkout` refers to a specific repo, [Github Actions](https://github.com/actions). + +## KiBot Specific details + + + +## Caveats, Gotchyas, and Pitfalls + +1. KiBot requires a `*.kibot.yaml` file name scheme. While most places use `*.yml` and `*.yaml` interchangeably, it is specific here. This is especially odd since github uses `*.yml` and kibot uses `*.yaml` + +## Different ways of doing things + +This section will try to describe some different options for doing things within KiBot and Github, and hope to explain pros and cons. + +TODO: Fill this out. +TODO: (Topic) github artifacts vs exports commited. +TODO: (Topic) When to run KiBOT?? ERC/DRC only vs full outputs. + From 3a3637a699f9b3eb099184639c479b4e920a778e Mon Sep 17 00:00:00 2001 From: Seth K <44306652+sethkaz@users.noreply.github.com> Date: Wed, 19 Jul 2023 16:42:10 -0700 Subject: [PATCH 02/18] Add optional step for github yaml --- docs/GITHUB-ACTIONS-README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/GITHUB-ACTIONS-README.md b/docs/GITHUB-ACTIONS-README.md index 0ec7a146..364c3130 100644 --- a/docs/GITHUB-ACTIONS-README.md +++ b/docs/GITHUB-ACTIONS-README.md @@ -27,6 +27,11 @@ jobs: # List of jobs to be run. Can be used to better organize steps. - name: Run KiBot run: | kibot -e "project_name.kicad_sch" + + # Post KiBot steps (Optional). + - name: Optionally do other things + run: | + ECHO Run bash commands to do things like commiting the files or adding them as artifacts ``` From 5045b4c57d5d3717ba3b73840507f8c990a462da Mon Sep 17 00:00:00 2001 From: Seth K <44306652+sethkaz@users.noreply.github.com> Date: Fri, 21 Jul 2023 16:45:22 -0700 Subject: [PATCH 03/18] Update github-actions-readme for clarity. --- docs/GITHUB-ACTIONS-README.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/docs/GITHUB-ACTIONS-README.md b/docs/GITHUB-ACTIONS-README.md index 364c3130..93f0069e 100644 --- a/docs/GITHUB-ACTIONS-README.md +++ b/docs/GITHUB-ACTIONS-README.md @@ -1,21 +1,19 @@ # Guide for using KiBot with Github Actions. -This is a guide for getting started using KiBOT with Github Actions +This is a guide for getting started using KiBOT with Github Actions. ## Basics -[Github Actions](https://github.com/actions) is a CI system that runs on Github. It uses [YAML files](https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html) to define what actions it will take. Unfortunately, some of those actions are a bit cryptic. This guide will try to shed light on those cyptic portions. - - +[Github Actions](https://github.com/actions) is a CI system that runs on Github. It uses [YAML files](https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html) to define what actions it will take. Unfortunately, some of the links between YAML lines and their associated actions are a bit cryptic. This guide will try to shed light on those cyptic portions. ### Basic github file Must be located at `{repo root}/.github/workflows/{meaningful_name}.yml ```yaml -name: KiBot_GitHub_Actions # Can be any name -on: [push, pull_request] # github triggers for running this. +name: KiBot_GitHub_Actions # This is a name. It can be anything you want. +on: [push, pull_request] # github triggers for running this. In this example it will run when anything is pushed to github or a pull request is created. jobs: # List of jobs to be run. Can be used to better organize steps. - KiBot-Generation: # Can be any name + KiBot-Generation: # This is a name. It can be anything you want. runs-on: ubuntu-latest # Don't change container: ghcr.io/inti-cmnb/kicad7_auto:latest # Don't Change, except if needing older version of KiCAD. @@ -35,7 +33,7 @@ jobs: # List of jobs to be run. Can be used to better organize steps. ``` -### Basic KiBOT file +### Basic KiBot file This file will match the syntax and keywords described in the [readme](../README.md). ```yaml kibot: @@ -65,7 +63,7 @@ The `uses: actions/checkout` refers to a specific repo, [Github Actions](https:/ ## Caveats, Gotchyas, and Pitfalls -1. KiBot requires a `*.kibot.yaml` file name scheme. While most places use `*.yml` and `*.yaml` interchangeably, it is specific here. This is especially odd since github uses `*.yml` and kibot uses `*.yaml` +1. KiBot requires a `{meaningful_name}.kibot.yaml` file name scheme. While most places use `*.yml` and `*.yaml` interchangeably, it is specific here that `*.kibot.yml` won't work. This is especially odd since github uses `*.yml` and kibot uses `*.yaml`. ## Different ways of doing things @@ -74,4 +72,3 @@ This section will try to describe some different options for doing things within TODO: Fill this out. TODO: (Topic) github artifacts vs exports commited. TODO: (Topic) When to run KiBOT?? ERC/DRC only vs full outputs. - From 4745baccc483c413a610004619c354f2ceae5c1a Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Thu, 14 Dec 2023 08:06:31 -0300 Subject: [PATCH 04/18] [ERC][KiCad 7][Fixed] Problems when creating a report without ext - Workaround for KiCad 7 explicitly creating a different file Fixes #529 --- CHANGELOG.md | 3 +++ kibot/pre_run_erc.py | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ee6cace..7a779171 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -119,6 +119,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 temporal, generating problems with the plot outputs, like pcb_print - Project options not preserved, i.e. set_text_variables failing - Bottom QRs should be mirrored in the Y axis +- ERC: + - Problems creating report files without extension (KiCad 7 odd behavior) + (#529) ## [1.6.3] - 2023-06-26 diff --git a/kibot/pre_run_erc.py b/kibot/pre_run_erc.py index 032da240..7e8b83b7 100644 --- a/kibot/pre_run_erc.py +++ b/kibot/pre_run_erc.py @@ -11,7 +11,9 @@ Dependencies: version: 2.2.1 """ import os +from shutil import move from sys import exit +from tempfile import NamedTemporaryFile from .macros import macros, pre_class # noqa: F401 from .gs import GS from .optionable import Optionable @@ -52,8 +54,12 @@ class Run_ERC(BasePreFlight): # noqa: F821 # But here we need data from it. output = self.get_targets()[0] os.makedirs(os.path.dirname(output), exist_ok=True) - logger.debug('ERC report: '+output) - cmd = [command, 'run_erc', '-o', output, '-g', str(GS.global_erc_grid)] + # Workaround for KiCad 7 odd behavior: it forces a file extension + # Note: One thing is adding the extension before you enter a name, other is add something you removed on purpose + with NamedTemporaryFile(mode='w', delete=False, suffix='.rpt', prefix='erc_report') as f: + tmp_name = f.name + logger.debug('ERC report: '+tmp_name) + cmd = [command, 'run_erc', '-o', tmp_name, '-g', str(GS.global_erc_grid)] if BasePreFlight.get_option('erc_warnings'): # noqa: F821 cmd.append('-w') if GS.filter_file: @@ -63,6 +69,10 @@ class Run_ERC(BasePreFlight): # noqa: F821 cmd = self.add_extra_options(cmd) logger.info('- Running the ERC') ret = self.exec_with_retry(cmd) + try: + move(tmp_name, output) + except FileNotFoundError: + pass if ret: if ret > 127: ret = -(256-ret) From 6c336371bd889ac920ef682cf756c6f130ca714a Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Mon, 18 Dec 2023 10:36:51 -0300 Subject: [PATCH 05/18] [Diff][Fixed] Problems with `current` mode - didn't apply global variants - didn't honor KiCad native DNP flags, they need a filter --- CHANGELOG.md | 6 +++--- docs/samples/generic_plot.kibot.yaml | 8 ++++++++ docs/source/configuration/outputs/diff.rst | 7 +++++++ kibot/out_diff.py | 21 ++++++++++++++------- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a779171..81c64cb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -119,9 +119,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 temporal, generating problems with the plot outputs, like pcb_print - Project options not preserved, i.e. set_text_variables failing - Bottom QRs should be mirrored in the Y axis -- ERC: - - Problems creating report files without extension (KiCad 7 odd behavior) - (#529) +- Diff + - `current`: didn't apply global variants + - `current`: didn't honor KiCad native DNP flags, they need a filter ## [1.6.3] - 2023-06-26 diff --git a/docs/samples/generic_plot.kibot.yaml b/docs/samples/generic_plot.kibot.yaml index d3af46f2..d5d7054a 100644 --- a/docs/samples/generic_plot.kibot.yaml +++ b/docs/samples/generic_plot.kibot.yaml @@ -762,6 +762,9 @@ outputs: # The `stats` mode is used to meassure the amount of difference. In this mode all # changes are red, but you can abort if the difference is bigger than certain threshold diff_mode: 'red_green' + # [string|list(string)='_none'] Name of the filter to mark components as not fitted. + # A short-cut to use for simple cases where a variant is an overkill + dnf_filter: '_none' # [boolean=false] When `old_type` and/or `new_type` are `git` KiBot will checkout the indicated point. # Before doing it KiBot will stash any change. Under some circumstances git could fail # to do a checkout, even after stashing, this option can workaround the problem. @@ -803,6 +806,9 @@ outputs: output: '%f-%i%I%v.%x' # [boolean=true] Compare the PCB, otherwise compare the schematic pcb: true + # [string|list(string)='_none'] Name of the filter to transform fields before applying other filters. + # A short-cut to use for simple cases where a variant is an overkill + pre_transform: '_none' # [number=0] [0,1000000] Error threshold for the `stats` mode, 0 is no error. When specified a # difference bigger than the indicated value will make the diff fail. # KiBot will return error level 29 and the diff generation will be aborted @@ -810,6 +816,8 @@ outputs: # [boolean=false] When creating the link name of an output file related to a variant use the variant # `file_id` instead of its name use_file_id: false + # [string=''] Board variant to apply + variant: '' layers: all # Datasheets downloader: - name: 'download_datasheets_example' diff --git a/docs/source/configuration/outputs/diff.rst b/docs/source/configuration/outputs/diff.rst index 5fb3ca1a..578db8c5 100644 --- a/docs/source/configuration/outputs/diff.rst +++ b/docs/source/configuration/outputs/diff.rst @@ -49,6 +49,9 @@ Parameters: - ``diff_mode`` :index:`: ` [string='red_green'] [red_green,stats] In the `red_green` mode added stuff is green and red when removed. The `stats` mode is used to meassure the amount of difference. In this mode all changes are red, but you can abort if the difference is bigger than certain threshold. + - ``dnf_filter`` :index:`: ` [string|list(string)='_none'] Name of the filter to mark components as not fitted. + A short-cut to use for simple cases where a variant is an overkill. + - ``force_checkout`` :index:`: ` [boolean=false] When `old_type` and/or `new_type` are `git` KiBot will checkout the indicated point. Before doing it KiBot will stash any change. Under some circumstances git could fail to do a checkout, even after stashing, this option can workaround the problem. @@ -79,11 +82,15 @@ Parameters: Note that when no differeces are found we get a page saying *No diff*. - ``only_first_sch_page`` :index:`: ` [boolean=false] Compare only the main schematic page (root page). - ``pcb`` :index:`: ` [boolean=true] Compare the PCB, otherwise compare the schematic. + - ``pre_transform`` :index:`: ` [string|list(string)='_none'] Name of the filter to transform fields before applying other filters. + A short-cut to use for simple cases where a variant is an overkill. + - ``threshold`` :index:`: ` [number=0] [0,1000000] Error threshold for the `stats` mode, 0 is no error. When specified a difference bigger than the indicated value will make the diff fail. KiBot will return error level 29 and the diff generation will be aborted. - ``use_file_id`` :index:`: ` [boolean=false] When creating the link name of an output file related to a variant use the variant `file_id` instead of its name. + - ``variant`` :index:`: ` [string=''] Board variant to apply. - **type** :index:`: ` [string=''] Type of output. - ``category`` :index:`: ` [string|list(string)=''] The category for this output. If not specified an internally defined category is used. diff --git a/kibot/out_diff.py b/kibot/out_diff.py index d2a1ac07..f444ec4e 100644 --- a/kibot/out_diff.py +++ b/kibot/out_diff.py @@ -31,7 +31,6 @@ from .gs import GS from .kiplot import load_any_sch, run_command, config_output, get_output_dir, run_output from .layer import Layer from .misc import DIFF_TOO_BIG, FAILED_EXECUTE -from .optionable import BaseOptions from .out_base import VariantOptions from .registrable import RegOutput from .macros import macros, document, output_class # noqa: F401 @@ -41,7 +40,7 @@ logger = log.get_logger() STASH_MSG = 'KiBot_Changes_Entry' -class DiffOptions(BaseOptions): +class DiffOptions(VariantOptions): def __init__(self): with document: self.output = GS.def_global_output @@ -458,12 +457,20 @@ class DiffOptions(BaseOptions): def cache_current(self): """ The file as we interpreted it """ if self.pcb: - fname, dir_name = VariantOptions.save_tmp_dir_board('diff') + fname, dir_name = self.save_tmp_dir_board('diff') + self.dirs_to_remove.append(dir_name) else: - dir_name = mkdtemp() - fname = GS.sch.save_variant(dir_name) - GS.copy_project_sch(dir_name) - self.dirs_to_remove.append(dir_name) + if self._comps: + # We have a variant/filter applied + dir_name = mkdtemp() + fname = GS.sch.save_variant(dir_name) + GS.copy_project_sch(dir_name) + self.dirs_to_remove.append(dir_name) + else: + # Just use the current file + # Note: The KiCad 7 DNP field needs some filter to be honored + dir_name = GS.sch_dir + fname = os.path.basename(GS.sch_file) res = self.cache_file(os.path.join(dir_name, fname)) self.git_hash = 'Current' return res From e72bbd08a302984aa421c554c3721b9315718a7a Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Mon, 18 Dec 2023 18:45:12 -0300 Subject: [PATCH 06/18] [Blender Export] Removed the "experimental" warning --- kibot/out_blender_export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kibot/out_blender_export.py b/kibot/out_blender_export.py index 21e40f4d..7f54d057 100644 --- a/kibot/out_blender_export.py +++ b/kibot/out_blender_export.py @@ -664,7 +664,7 @@ class Blender_ExportOptions(BaseOptions): @output_class class Blender_Export(Base3D): - """ Blender Export **Experimental** + """ Blender Export Exports the PCB in various 3D file formats. Also renders the PCB with high-quality. Needs KiCad 6 or newer. From 53aa79c29b2b4d2efea59ff5e11db02ca940350c Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Mon, 18 Dec 2023 18:46:05 -0300 Subject: [PATCH 07/18] [PCB Print] Avoid warnings about SHEETPATH - Not used for PCBs - KiCad defines it as empty See #532 --- kibot/out_pcb_print.py | 1 + 1 file changed, 1 insertion(+) diff --git a/kibot/out_pcb_print.py b/kibot/out_pcb_print.py index 460fb5f8..215039b8 100644 --- a/kibot/out_pcb_print.py +++ b/kibot/out_pcb_print.py @@ -489,6 +489,7 @@ class PCB_PrintOptions(VariantOptions): vars['TITLE'] = tb.GetTitle() vars['FILENAME'] = GS.pcb_basename+'.kicad_pcb' vars['SHEETNAME'] = p.sheet + vars['SHEETPATH'] = '' # Only relevant for an schematic layer = '' for la in p.layers: if len(layer): From 8194760ff663a82332c1624ba8d16daf0bd5bb73 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Mon, 18 Dec 2023 18:47:34 -0300 Subject: [PATCH 08/18] [PCB Print] Removed redundant code --- kibot/out_pcb_print.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/kibot/out_pcb_print.py b/kibot/out_pcb_print.py index 215039b8..429a757f 100644 --- a/kibot/out_pcb_print.py +++ b/kibot/out_pcb_print.py @@ -1090,14 +1090,6 @@ class PCB_PrintOptions(VariantOptions): edge_layer.color = layer_id2color[edge_id] else: edge_layer.color = "#000000" - # Make visible only the layers we need - # This is very important when scaling, otherwise the results are controlled by the .kicad_prl (See #407) - if not self.individual_page_scaling: - vis_layers = LSET() - for p in self.pages: - for la in p.layers: - vis_layers.addLayer(la._id) - GS.board.SetVisibleLayers(vis_layers) # Generate the output, page by page pages = [] for n, p in enumerate(self.pages): From 0972914f08afe0a2a64a9cd11d41f022fd20a09a Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Mon, 18 Dec 2023 18:48:03 -0300 Subject: [PATCH 09/18] [PCB Print][Fixed] Missing edge cuts in the list of visible layers - When forced - This is needed and helps to avoid hitting a bug in KiCad Fixes #532 --- kibot/out_pcb_print.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kibot/out_pcb_print.py b/kibot/out_pcb_print.py index 429a757f..caff6c54 100644 --- a/kibot/out_pcb_print.py +++ b/kibot/out_pcb_print.py @@ -1099,6 +1099,8 @@ class PCB_PrintOptions(VariantOptions): vis_layers = LSET() for la in p.layers: vis_layers.addLayer(la._id) + if self.force_edge_cuts: + vis_layers.addLayer(edge_id) GS.board.SetVisibleLayers(vis_layers) # Use a dir for each page, avoid overwriting files, just for debug purposes page_str = "%02d" % (n+1) From bf5e37bc13eeab7a51cac79a51a79f313b213e2d Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Mon, 18 Dec 2023 19:03:09 -0300 Subject: [PATCH 10/18] [PCB Print][Fixed] Regression issue - Reverts 8194760 - Adds 0972914f to the removed code --- CHANGELOG.md | 2 ++ kibot/out_pcb_print.py | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81c64cb9..dee86f39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -122,6 +122,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Diff - `current`: didn't apply global variants - `current`: didn't honor KiCad native DNP flags, they need a filter +- PCB Print: + - Issues when forcing the board edge and using scaling (#532) ## [1.6.3] - 2023-06-26 diff --git a/kibot/out_pcb_print.py b/kibot/out_pcb_print.py index caff6c54..824d5061 100644 --- a/kibot/out_pcb_print.py +++ b/kibot/out_pcb_print.py @@ -1090,6 +1090,17 @@ class PCB_PrintOptions(VariantOptions): edge_layer.color = layer_id2color[edge_id] else: edge_layer.color = "#000000" + # Make visible only the layers we need + # This is very important when scaling, otherwise the results are controlled by the .kicad_prl (See #407) + if not self.individual_page_scaling: + # Make all the layers in all the pages visible + vis_layers = LSET() + for p in self.pages: + for la in p.layers: + vis_layers.addLayer(la._id) + if self.force_edge_cuts: + vis_layers.addLayer(edge_id) + GS.board.SetVisibleLayers(vis_layers) # Generate the output, page by page pages = [] for n, p in enumerate(self.pages): From c49c5095233d57f6ca618fdb5fcae286628d0330 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Mon, 18 Dec 2023 19:07:29 -0300 Subject: [PATCH 11/18] [Worksheet] Avoid warnings for v20220228 - Seems to be fully supported - We added plenty of undocumented stuff on 2022/04/15 - They still undocumented today See #532 --- kibot/kicad/worksheet.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kibot/kicad/worksheet.py b/kibot/kicad/worksheet.py index 5dae2f3d..e494e100 100644 --- a/kibot/kicad/worksheet.py +++ b/kibot/kicad/worksheet.py @@ -50,8 +50,9 @@ from .. import log logger = log.get_logger() setup = None -# The version of "kicad_wks" used for all tests -SUP_VERSION = 20210606 +# The version of "kicad_wks" used for all tests is 20210606 +# 20220228 seems to be fully supported +SUP_VERSION = 20220228 # Hash to convert KiCad 5 "%X" markers to KiCad 6 "${XXX}" text variables KI5_2_KI6 = {'K': 'KICAD_VERSION', 'S': '#', 'N': '##', 'C0': 'COMMENT1', 'C1': 'COMMENT2', 'C2': 'COMMENT3', 'C3': 'COMMENT4', 'C4': 'COMMENT5', 'C5': 'COMMENT6', 'C6': 'COMMENT7', 'C7': 'COMMENT8', From d341db0e7860eaf998ebe06c33fe936619b0a3e6 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Mon, 18 Dec 2023 20:53:53 -0300 Subject: [PATCH 12/18] [DOCs] Blender export no longer experimental --- docs/samples/generic_plot.kibot.yaml | 2 +- docs/source/configuration/outputs/blender_export.rst | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/samples/generic_plot.kibot.yaml b/docs/samples/generic_plot.kibot.yaml index d5d7054a..9df2a97a 100644 --- a/docs/samples/generic_plot.kibot.yaml +++ b/docs/samples/generic_plot.kibot.yaml @@ -95,7 +95,7 @@ preflight: update_xml: true outputs: - # Blender Export **Experimental**: + # Blender Export: # Also renders the PCB with high-quality. # Needs KiCad 6 or newer. # This output is complex to setup and needs very big dependencies. diff --git a/docs/source/configuration/outputs/blender_export.rst b/docs/source/configuration/outputs/blender_export.rst index c38fbe12..2e99ec5b 100644 --- a/docs/source/configuration/outputs/blender_export.rst +++ b/docs/source/configuration/outputs/blender_export.rst @@ -1,10 +1,10 @@ .. Automatically generated by KiBot, please don't edit this file .. index:: - pair: Blender Export **Experimental**; blender_export + pair: Blender Export; blender_export -Blender Export **Experimental** -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Blender Export +~~~~~~~~~~~~~~ Exports the PCB in various 3D file formats. Also renders the PCB with high-quality. |br| From b432a64709f4728ebb8091332f358748766d55d3 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Mon, 18 Dec 2023 20:54:26 -0300 Subject: [PATCH 13/18] [Fabrication Templates] Move files to the archive - Is the most common case, so now we move (instead of copy) - Can be configured using _KIBOT_COMPRESS_MOVE - Left the JLCPCB BoM and Position outside, they must be uploaded separately Closes #537 --- CHANGELOG.md | 8 +++++++- docs/source/configuration/imports.rst | 1 + kibot/resources/config_templates/Elecrow.kibot.yaml | 2 ++ kibot/resources/config_templates/FusionPCB.kibot.yaml | 2 ++ kibot/resources/config_templates/JLCPCB.kibot.yaml | 6 ++---- kibot/resources/config_templates/P-Ban.kibot.yaml | 2 ++ kibot/resources/config_templates/PCBWay.kibot.yaml | 2 ++ 7 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dee86f39..2fc88908 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,8 +26,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 3DRender_bottom_straight: to generate simple and quick 3D renders. - _KIBOT_POS_DNF_FILTER option to JLCPCB. It now excludes components added by KiKit to create panels and can be customized. - - _KIBOT_PLOT_FOOTPRINT_REFS and _KIBOT_PLOT_FOOTPRINT_VALUES to + - _KIBOT_PLOT_FOOTPRINT_REFS and _KIBOT_PLOT_FOOTPRINT_VALUES to manufacturer templates. (#523) + - _KIBOT_COMPRESS_MOVE to move gerber and drill files to the compressed + output, enabled by default. (#537) - Filters: - New `_rot_footprint_jlcpcb` internal filter to fix the JLCPCB bottom rotations. @@ -87,6 +89,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Footprints: now they are flagged with exclude from BoM and Pos, also with no court yard requirements for KiCad 7 - Symbol: Excluded from simulation for KiCad 7 +- Elecrow, FusionPCB, JLCPCB, PCBWay and P-Ban templates now moves the files + to the compressed output by default. + - Note that JLCPCB BoM and Position files aren't included anymore, they are + uploaded separately. ### Fixed - Schematics: problems with deep nested and recycled sheets (#520) diff --git a/docs/source/configuration/imports.rst b/docs/source/configuration/imports.rst index 9d68bcc4..94eac38e 100644 --- a/docs/source/configuration/imports.rst +++ b/docs/source/configuration/imports.rst @@ -323,6 +323,7 @@ The manufacturer templates (Elecrow, FusionPCB, JLCPCB, P-Ban and PCBWay) suppor - **_KIBOT_GERBER_LAYERS**: List of layers to use for the gerbers (default: a specially crafted list of layers) - **_KIBOT_PLOT_FOOTPRINT_REFS**: Include the footprint references in the gerbers (default: true) - **_KIBOT_PLOT_FOOTPRINT_VALUES**: Include the footprint values in the gerbers (default: true, except for JLCPCB) +- **_KIBOT_COMPRESS_MOVE**: Move the generated files to the compressed archive (default: true) The JLCPCB case is a little bit more complex and also supports: diff --git a/kibot/resources/config_templates/Elecrow.kibot.yaml b/kibot/resources/config_templates/Elecrow.kibot.yaml index 0b695991..07934e99 100644 --- a/kibot/resources/config_templates/Elecrow.kibot.yaml +++ b/kibot/resources/config_templates/Elecrow.kibot.yaml @@ -55,6 +55,7 @@ outputs: type: compress dir: @_KIBOT_MANF_DIR_COMP@ options: + move_files: @_KIBOT_COMPRESS_MOVE@ files: - from_output: _Elecrow_gerbers@_KIBOT_IMPORT_ID@ dest: / @@ -71,6 +72,7 @@ definitions: _KIBOT_MANF_DIR_COMP: '@_KIBOT_IMPORT_DIR@' _KIBOT_PLOT_FOOTPRINT_REFS: true _KIBOT_PLOT_FOOTPRINT_VALUES: true + _KIBOT_COMPRESS_MOVE: true _KIBOT_GERBER_LAYERS: | - copper - F.SilkS diff --git a/kibot/resources/config_templates/FusionPCB.kibot.yaml b/kibot/resources/config_templates/FusionPCB.kibot.yaml index d27ef390..a961edf9 100644 --- a/kibot/resources/config_templates/FusionPCB.kibot.yaml +++ b/kibot/resources/config_templates/FusionPCB.kibot.yaml @@ -55,6 +55,7 @@ outputs: type: compress dir: @_KIBOT_MANF_DIR_COMP@ options: + move_files: @_KIBOT_COMPRESS_MOVE@ files: - from_output: _FusionPCB_gerbers@_KIBOT_IMPORT_ID@ dest: / @@ -71,6 +72,7 @@ definitions: _KIBOT_MANF_DIR_COMP: '@_KIBOT_IMPORT_DIR@' _KIBOT_PLOT_FOOTPRINT_REFS: true _KIBOT_PLOT_FOOTPRINT_VALUES: true + _KIBOT_COMPRESS_MOVE: true _KIBOT_GERBER_LAYERS: | - copper - F.SilkS diff --git a/kibot/resources/config_templates/JLCPCB.kibot.yaml b/kibot/resources/config_templates/JLCPCB.kibot.yaml index 40db9769..2949054b 100644 --- a/kibot/resources/config_templates/JLCPCB.kibot.yaml +++ b/kibot/resources/config_templates/JLCPCB.kibot.yaml @@ -131,15 +131,12 @@ outputs: options: # Position and BoM can be disabled skip_not_run: true + move_files: @_KIBOT_COMPRESS_MOVE@ files: - from_output: _JLCPCB_gerbers@_KIBOT_IMPORT_ID@ dest: / - from_output: _JLCPCB_drill@_KIBOT_IMPORT_ID@ dest: / - - from_output: _JLCPCB_position@_KIBOT_IMPORT_ID@ - dest: / - - from_output: _JLCPCB_bom@_KIBOT_IMPORT_ID@ - dest: / ... definitions: @@ -156,6 +153,7 @@ definitions: _KIBOT_BOM_ENABLED: true _KIBOT_PLOT_FOOTPRINT_REFS: true _KIBOT_PLOT_FOOTPRINT_VALUES: false + _KIBOT_COMPRESS_MOVE: true _KIBOT_GERBER_LAYERS: | - copper - F.SilkS diff --git a/kibot/resources/config_templates/P-Ban.kibot.yaml b/kibot/resources/config_templates/P-Ban.kibot.yaml index 9d1a6402..113fd963 100644 --- a/kibot/resources/config_templates/P-Ban.kibot.yaml +++ b/kibot/resources/config_templates/P-Ban.kibot.yaml @@ -61,6 +61,7 @@ outputs: type: compress dir: @_KIBOT_MANF_DIR_COMP@ options: + move_files: @_KIBOT_COMPRESS_MOVE@ files: - from_output: _P-Ban_gerbers@_KIBOT_IMPORT_ID@ dest: / @@ -77,6 +78,7 @@ definitions: _KIBOT_MANF_DIR_COMP: '@_KIBOT_IMPORT_DIR@' _KIBOT_PLOT_FOOTPRINT_REFS: true _KIBOT_PLOT_FOOTPRINT_VALUES: true + _KIBOT_COMPRESS_MOVE: true _KIBOT_GERBER_LAYERS: | - F.Cu - B.Cu diff --git a/kibot/resources/config_templates/PCBWay.kibot.yaml b/kibot/resources/config_templates/PCBWay.kibot.yaml index 7e33e434..cdc62d5f 100644 --- a/kibot/resources/config_templates/PCBWay.kibot.yaml +++ b/kibot/resources/config_templates/PCBWay.kibot.yaml @@ -63,6 +63,7 @@ outputs: dir: @_KIBOT_MANF_DIR_COMP@ options: format: ZIP + move_files: @_KIBOT_COMPRESS_MOVE@ files: - from_output: _PCBWay_gerbers@_KIBOT_IMPORT_ID@ dest: / @@ -79,6 +80,7 @@ definitions: _KIBOT_MANF_DIR_COMP: '@_KIBOT_IMPORT_DIR@' _KIBOT_PLOT_FOOTPRINT_REFS: true _KIBOT_PLOT_FOOTPRINT_VALUES: true + _KIBOT_COMPRESS_MOVE: true _KIBOT_GERBER_LAYERS: | - copper - F.SilkS From 25771e04495ded4943cf26751c073bc50d2485b2 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Wed, 20 Dec 2023 08:36:50 -0300 Subject: [PATCH 14/18] [Tests] Forced --- .github/workflows/pythonapp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index a7d6a095..ba4dd181 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -1,4 +1,4 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python. +# This workflow will install Python dependencies, run tests and lint with a single version of Python # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions name: Regression tests From 97f67e5bca8d9ad24dc4c3c1c18aef739821840a Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Wed, 20 Dec 2023 10:28:10 -0300 Subject: [PATCH 15/18] [DOCs][PCB Print] Added remainder about alpha channel See #531 --- docs/samples/generic_plot.kibot.yaml | 6 ++++-- docs/source/configuration/outputs/pcb_print.rst | 2 ++ kibot/out_pcb_print.py | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/samples/generic_plot.kibot.yaml b/docs/samples/generic_plot.kibot.yaml index 9df2a97a..2d110341 100644 --- a/docs/samples/generic_plot.kibot.yaml +++ b/docs/samples/generic_plot.kibot.yaml @@ -2296,7 +2296,8 @@ outputs: # Order is important, the last goes on top. # You can reuse other layers lists, some options aren't used here, but they are valid layers: - # [string=''] Color used for this layer + # [string=''] Color used for this layer. + # KiCad 6+: don't forget the alpha channel for layers like the solder mask - color: '' # [string=''] A description for the layer, for documentation purposes. # A default can be specified using the `layer_defaults` global option @@ -2333,7 +2334,8 @@ outputs: # [list(dict)|list(string)|string] List of layers to replace `repeat_for_layer`. # This can be used to generate a page for each copper layer, here you put `copper` repeat_layers: - # [string=''] Color used for this layer + # [string=''] Color used for this layer. + # KiCad 6+: don't forget the alpha channel for layers like the solder mask - color: '' # [string=''] A description for the layer, for documentation purposes. # A default can be specified using the `layer_defaults` global option diff --git a/docs/source/configuration/outputs/pcb_print.rst b/docs/source/configuration/outputs/pcb_print.rst index 12d7c0ec..fdfd7f15 100644 --- a/docs/source/configuration/outputs/pcb_print.rst +++ b/docs/source/configuration/outputs/pcb_print.rst @@ -46,6 +46,7 @@ Parameters: - Valid keys: - ``color`` :index:`: ` [string=''] Color used for this layer. + KiCad 6+: don't forget the alpha channel for layers like the solder mask. - ``description`` :index:`: ` [string=''] A description for the layer, for documentation purposes. A default can be specified using the `layer_defaults` global option. - ``force_plot_invisible_refs_vals`` :index:`: ` [boolean=false] Include references and values even when they are marked as invisible. @@ -79,6 +80,7 @@ Parameters: - Valid keys: - ``color`` :index:`: ` [string=''] Color used for this layer. + KiCad 6+: don't forget the alpha channel for layers like the solder mask. - ``description`` :index:`: ` [string=''] A description for the layer, for documentation purposes. A default can be specified using the `layer_defaults` global option. - ``force_plot_invisible_refs_vals`` :index:`: ` [boolean=false] Include references and values even when they are marked as invisible. diff --git a/kibot/out_pcb_print.py b/kibot/out_pcb_print.py index 824d5061..081976c8 100644 --- a/kibot/out_pcb_print.py +++ b/kibot/out_pcb_print.py @@ -138,7 +138,8 @@ class LayerOptions(Layer): self._unknown_is_error = True with document: self.color = "" - """ Color used for this layer """ + """ Color used for this layer. + KiCad 6+: don't forget the alpha channel for layers like the solder mask """ self.plot_footprint_refs = True """ Include the footprint references """ self.plot_footprint_values = True From 454557a08919a34e4e9435736c3f839bab7334f1 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Wed, 20 Dec 2023 10:38:26 -0300 Subject: [PATCH 16/18] [DOCs] Linked the GitHub actions readme to the main docs - Also adjusted some small details --- docs/GITHUB-ACTIONS-README.md | 42 +++++++++++++++++--------------- docs/source/usage_with_ci_cd.rst | 8 ++++++ 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/docs/GITHUB-ACTIONS-README.md b/docs/GITHUB-ACTIONS-README.md index 93f0069e..c59d66af 100644 --- a/docs/GITHUB-ACTIONS-README.md +++ b/docs/GITHUB-ACTIONS-README.md @@ -1,40 +1,44 @@ -# Guide for using KiBot with Github Actions. +# Guide for using KiBot with GitHub Actions. +Author: @sethkaz -This is a guide for getting started using KiBOT with Github Actions. +This is a guide for getting started using KiBot with GitHub Actions. ## Basics -[Github Actions](https://github.com/actions) is a CI system that runs on Github. It uses [YAML files](https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html) to define what actions it will take. Unfortunately, some of the links between YAML lines and their associated actions are a bit cryptic. This guide will try to shed light on those cyptic portions. +[GitHub Actions](https://github.com/actions) is a CI system that runs on GitHub. It uses [YAML files](https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html) to define what actions it will take. Unfortunately, some of the links between YAML lines and their associated actions are a bit cryptic. This guide will try to shed light on those cryptic portions. -### Basic github file +### Basic GitHub file + +Must be located at `{repo root}/.github/workflows/{meaningful_name}.yml` -Must be located at `{repo root}/.github/workflows/{meaningful_name}.yml ```yaml name: KiBot_GitHub_Actions # This is a name. It can be anything you want. -on: [push, pull_request] # github triggers for running this. In this example it will run when anything is pushed to github or a pull request is created. +on: [push, pull_request] # GitHub triggers for running this. In this example it will run when anything is pushed to GitHub or a pull request is created. jobs: # List of jobs to be run. Can be used to better organize steps. KiBot-Generation: # This is a name. It can be anything you want. runs-on: ubuntu-latest # Don't change - container: ghcr.io/inti-cmnb/kicad7_auto:latest # Don't Change, except if needing older version of KiCAD. + container: ghcr.io/inti-cmnb/kicad7_auto_full:latest # Don't Change, except if needing older version of KiCad. - steps: + steps: - name: Checkout repo - uses: actions/checkout@v3 # Github built-in repo checkout step. + uses: actions/checkout@v3 # GitHub built-in repo checkout step. # Start of the KiBot steps - name: Run KiBot run: | kibot -e "project_name.kicad_sch" - # Post KiBot steps (Optional). + # Post KiBot steps (Optional). - name: Optionally do other things run: | - ECHO Run bash commands to do things like commiting the files or adding them as artifacts + echo "Run bash commands to do things like committing the files or adding them as artifacts" ``` ### Basic KiBot file -This file will match the syntax and keywords described in the [readme](../README.md). + +This file will match the syntax and keywords described in the [readme](https://kibot.readthedocs.io/en/latest/). + ```yaml kibot: version: 1 @@ -53,9 +57,9 @@ outputs: output: '%p-Schematic.%x' ``` -## Github-specific details +## GitHub-specific details -The `uses: actions/checkout` refers to a specific repo, [Github Actions](https://github.com/actions). +The `uses: actions/checkout` refers to a specific repo, [GitHub Actions](https://github.com/actions). ## KiBot Specific details @@ -63,12 +67,12 @@ The `uses: actions/checkout` refers to a specific repo, [Github Actions](https:/ ## Caveats, Gotchyas, and Pitfalls -1. KiBot requires a `{meaningful_name}.kibot.yaml` file name scheme. While most places use `*.yml` and `*.yaml` interchangeably, it is specific here that `*.kibot.yml` won't work. This is especially odd since github uses `*.yml` and kibot uses `*.yaml`. +1. KiBot requires a `{meaningful_name}.kibot.yaml` file name scheme. While most places use `*.yml` and `*.yaml` interchangeably, it is specific here that `*.kibot.yml` won't work. This is especially odd since GitHub uses `*.yml` and kibot uses `*.yaml`. ## Different ways of doing things -This section will try to describe some different options for doing things within KiBot and Github, and hope to explain pros and cons. +This section will try to describe some different options for doing things within KiBot and GitHub, and hope to explain pros and cons. -TODO: Fill this out. -TODO: (Topic) github artifacts vs exports commited. -TODO: (Topic) When to run KiBOT?? ERC/DRC only vs full outputs. +- TODO: Fill this out. +- TODO: (Topic) GitHub artifacts vs exports committed. +- TODO: (Topic) When to run KiBot?? ERC/DRC only vs full outputs. diff --git a/docs/source/usage_with_ci_cd.rst b/docs/source/usage_with_ci_cd.rst index 7087fd9e..5b9e4ab9 100644 --- a/docs/source/usage_with_ci_cd.rst +++ b/docs/source/usage_with_ci_cd.rst @@ -99,6 +99,14 @@ For more information about the docker images visit `kicad_debian `__ and `kicad_auto `__. +.. index:: + pair: usage; GitHub + +GitHub workflows +~~~~~~~~~~~~~~~~ + +A work-in-progress guide can be found `here `__. + .. index:: pair: usage; GitHub Actions From e1ccc99563df050029da67aee35f71877a9091cd Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Wed, 20 Dec 2023 12:27:39 -0300 Subject: [PATCH 17/18] [EasyEDA][Fixed] Problems with some step files - With custom encodings, not UTF-8 - Now handled as binary objects --- kibot/EasyEDA/easyeda_3d.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kibot/EasyEDA/easyeda_3d.py b/kibot/EasyEDA/easyeda_3d.py index d4203f22..b38be184 100644 --- a/kibot/EasyEDA/easyeda_3d.py +++ b/kibot/EasyEDA/easyeda_3d.py @@ -77,7 +77,7 @@ class EasyedaApi: logger.warning(W_EEDA3D+"Failed to download STEP 3D model data found for EasyEDA uuid: "+uuid) step = None else: - step = r.content.decode() + step = r.content return obj, step @@ -340,7 +340,7 @@ class Exporter3dModelKicad: else: name_step = os.path.splitext(name_step)[0]+'.step' name_step = os.path.join(lib_path, name_step) - with open(name_step, "w", encoding="utf-8") as my_lib: + with open(name_step, "wb") as my_lib: my_lib.write(self.output_step) return name_wrl or name_step From 8c1fafa9b9d867238638448d3c33b4cbb518f823 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Thu, 21 Dec 2023 13:04:51 -0300 Subject: [PATCH 18/18] [Added] Warning about KiCad Bug #16418 See #533 --- kibot/misc.py | 1 + kibot/out_pcb_print.py | 49 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/kibot/misc.py b/kibot/misc.py index 47279b6a..270afee0 100644 --- a/kibot/misc.py +++ b/kibot/misc.py @@ -289,6 +289,7 @@ W_EXTRAINVAL = '(W133) ' W_BADANGLE = '(W134) ' W_VALMISMATCH = '(W135) ' W_BADOFFSET = '(W136) ' +W_BUG16418 = '(W137) ' # Somehow arbitrary, the colors are real, but can be different PCB_MAT_COLORS = {'fr1': "937042", 'fr2': "949d70", 'fr3': "adacb4", 'fr4': "332B16", 'fr5': "6cc290"} PCB_FINISH_COLORS = {'hal': "8b898c", 'hasl': "8b898c", 'imag': "8b898c", 'enig': "cfb96e", 'enepig': "cfb96e", diff --git a/kibot/out_pcb_print.py b/kibot/out_pcb_print.py index 081976c8..14b96062 100644 --- a/kibot/out_pcb_print.py +++ b/kibot/out_pcb_print.py @@ -47,7 +47,7 @@ from .kicad.config import KiConf from .kicad.v5_sch import SchError from .kicad.pcb import PCB from .misc import (PDF_PCB_PRINT, W_PDMASKFAIL, W_MISSTOOL, PCBDRAW_ERR, W_PCBDRAW, VIATYPE_THROUGH, VIATYPE_BLIND_BURIED, - VIATYPE_MICROVIA, FONT_HELP_TEXT) + VIATYPE_MICROVIA, FONT_HELP_TEXT, W_BUG16418) from .create_pdf import create_pdf_from_pages from .macros import macros, document, output_class # noqa: F401 from .drill_marks import DRILL_MARKS_MAP, add_drill_marks @@ -889,6 +889,33 @@ class PCB_PrintOptions(VariantOptions): from lxml.etree import tostring return tostring(image).decode() +# def kicad7_scale_workaround(self, id, temp_dir, out_file, color, mirror, scale): +# logger.error(f'Fix {out_file}') +# svg = svgutils.fromfile(out_file) +# logger.error(self.get_view_box(svg)) +# bbox = GS.board.GetBoundingBox() +# logger.error(bbox.GetSize()) +# for f in GS.board.Footprints(): +# logger.error('Pads') +# for p in f.Pads(): +# bbox = p.GetBoundingBox() +# logger.error(bbox.GetSize()) +# logger.error('Graphics') +# for gi in f.GraphicalItems(): +# bbox = gi.GetBoundingBox() +# logger.error(bbox.GetSize()) +# logger.error('Drawings') +# for d in GS.board.Drawings(): +# bbox = d.GetBoundingBox() +# logger.error(bbox.GetSize()) +# logger.error('Tracks') +# for t in GS.board.Tracks(): +# bbox = t.GetBoundingBox() +# logger.error(bbox.GetSize()) +# +# def get_view_box(self, svg): +# return tuple(map(lambda x: float(x), svg.root.get('viewBox').split(' '))) + def plot_realistic_solder_mask(self, id, temp_dir, out_file, color, mirror, scale): """ Plot the solder mask closer to reality, not the apertures """ if not self.realistic_solder_mask or (id != F_Mask and id != B_Mask): @@ -1048,6 +1075,19 @@ class PCB_PrintOptions(VariantOptions): if cur_name != user_name and os.path.isfile(cur_name): os.replace(cur_name, user_name) + def check_ki7_scale_issue(self): + """ Check if all visible layers has scaling problems """ + if not GS.ki7: + return False + cur_vis = GS.board.GetVisibleLayers() + # Copper layers are OK + if len(cur_vis.CuStack()): + return False + for la in ['Edge.Cuts', 'F.SilkS', 'B.SilkS']: + if cur_vis.Contains(Layer.DEFAULT_LAYER_NAMES[la]): + return False + return True + def generate_output(self, output): self.check_tools() # Avoid KiCad 5 complaining about fake vias diameter == drill == 0 @@ -1114,6 +1154,11 @@ class PCB_PrintOptions(VariantOptions): if self.force_edge_cuts: vis_layers.addLayer(edge_id) GS.board.SetVisibleLayers(vis_layers) + needs_ki7_scale_workaround = p.scaling != 1.0 and self.check_ki7_scale_issue() + if needs_ki7_scale_workaround: + logger.warning(f"{W_BUG16418}In output `{self._parent.name}` page {n+1}: " + "KiCad 7 bug #16418 prevents correct page view. " + "Add some copper, silk or edge layer") # Use a dir for each page, avoid overwriting files, just for debug purposes page_str = "%02d" % (n+1) temp_dir = os.path.join(temp_dir_base, page_str) @@ -1151,6 +1196,8 @@ class PCB_PrintOptions(VariantOptions): filelist.append((pc.GetPlotFileName(), la.color)) self.plot_extra_cu(id, la, pc, p, filelist) self.plot_realistic_solder_mask(id, temp_dir, filelist[-1][0], filelist[-1][1], p.mirror, p.scaling) +# if needs_ki7_scale_workaround: +# self.kicad7_scale_workaround(id, temp_dir, filelist[-1][0], filelist[-1][1], p.mirror, p.scaling) # 2) Plot the frame using an empty layer and 1.0 scale po.SetMirror(False) if self.plot_sheet_reference: