From 2111eaf6d2e36b7455780a22bf8f5a0b057e037b Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Fri, 9 Sep 2022 09:08:26 -0300 Subject: [PATCH] [PCB Variant] Options for title and conditional project copy --- README.md | 3 +++ docs/samples/generic_plot.kibot.yaml | 5 +++++ kibot/out_pcb_variant.py | 10 +++++++++- tests/yaml_samples/pcb_variant_1.kibot.yaml | 1 - 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a55b8b53..43ec74f3 100644 --- a/README.md +++ b/README.md @@ -2283,9 +2283,12 @@ Notes: - **`options`**: [dict] Options for the `pcb_variant` output. * Valid keys: - **`output`**: [string='%f-%i%I%v.%x'] Filename for the output (%i=variant, %x=kicad_pcb). Affected by global options. + - `copy_project`: [boolean=true] Copy the KiCad project to the destination directory. - `dnf_filter`: [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. - `hide_excluded`: [boolean=false] Hide components in the Fab layer that are marked as excluded by a variant. + - `title`: [string=''] Text used to replace the sheet title. %VALUE expansions are allowed. + If it starts with `+` the text is concatenated. - `variant`: [string=''] Board variant to apply. - `category`: [string|list(string)=''] The category for this output. If not specified an internally defined category is used. Categories looks like file system paths, i.e. PCB/fabrication/gerber. diff --git a/docs/samples/generic_plot.kibot.yaml b/docs/samples/generic_plot.kibot.yaml index 63d125c9..ff4f5adb 100644 --- a/docs/samples/generic_plot.kibot.yaml +++ b/docs/samples/generic_plot.kibot.yaml @@ -1202,6 +1202,8 @@ outputs: type: 'pcb_variant' dir: 'Example/pcb_variant_dir' options: + # [boolean=true] Copy the KiCad project to the destination directory + copy_project: true # [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' @@ -1209,6 +1211,9 @@ outputs: hide_excluded: false # [string='%f-%i%I%v.%x'] Filename for the output (%i=variant, %x=kicad_pcb). Affected by global options output: '%f-%i%I%v.%x' + # [string=''] Text used to replace the sheet title. %VALUE expansions are allowed. + # If it starts with `+` the text is concatenated + title: '' # [string=''] Board variant to apply variant: '' # PcbDraw - Beautiful 2D PCB render: diff --git a/kibot/out_pcb_variant.py b/kibot/out_pcb_variant.py index 32816b31..c57d3b6c 100644 --- a/kibot/out_pcb_variant.py +++ b/kibot/out_pcb_variant.py @@ -18,6 +18,11 @@ class PCB_Variant_Options(VariantOptions): """ Hide components in the Fab layer that are marked as excluded by a variant """ self.output = GS.def_global_output """ *Filename for the output (%i=variant, %x=kicad_pcb) """ + self.copy_project = True + """ Copy the KiCad project to the destination directory """ + self.title = '' + """ Text used to replace the sheet title. %VALUE expansions are allowed. + If it starts with `+` the text is concatenated """ super().__init__() self._expand_id = 'variant' self._expand_ext = 'kicad_pcb' @@ -27,11 +32,14 @@ class PCB_Variant_Options(VariantOptions): def run(self, output): super().run(output) + self.set_title(self.title) self.filter_pcb_components(GS.board, do_3D=True) logger.debug('Saving PCB to '+output) GS.board.Save(output) - GS.copy_project(output) + if self.copy_project: + GS.copy_project(output) self.unfilter_pcb_components(GS.board, do_3D=True) + self.restore_title() @output_class diff --git a/tests/yaml_samples/pcb_variant_1.kibot.yaml b/tests/yaml_samples/pcb_variant_1.kibot.yaml index 48f45e7e..7a747291 100644 --- a/tests/yaml_samples/pcb_variant_1.kibot.yaml +++ b/tests/yaml_samples/pcb_variant_1.kibot.yaml @@ -14,5 +14,4 @@ outputs: type: pcb_variant options: variant: default - scaling: 0 title: 'Hello %V'