diff --git a/CHANGELOG.md b/CHANGELOG.md index 993bdcc4..439be60f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support for Eurocircuits drill adjust to fix small OARs. Option `eurocircuits_reduce_holes`. (#227) - Diff: mechanism to compare using a variant (See #278) +- Sch Variant: option to copy the project. Needed for text variables. ### Fixed - Problems to compress netlists. (#287) diff --git a/README.md b/README.md index 9ce73a7f..3afef556 100644 --- a/README.md +++ b/README.md @@ -2802,6 +2802,8 @@ Notes: - **`name`**: [string=''] Used to identify this particular output definition. - **`options`**: [dict] Options for the `sch_variant` output. * Valid keys: + - `copy_project`: [boolean=false] Copy the KiCad project to the destination directory. + Disabled by default for compatibility with older versions. - `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. - `variant`: [string=''] Board variant to apply. diff --git a/docs/samples/generic_plot.kibot.yaml b/docs/samples/generic_plot.kibot.yaml index f08a5580..efd7976a 100644 --- a/docs/samples/generic_plot.kibot.yaml +++ b/docs/samples/generic_plot.kibot.yaml @@ -1678,6 +1678,9 @@ outputs: type: 'sch_variant' dir: 'Example/sch_variant_dir' options: + # [boolean=false] Copy the KiCad project to the destination directory. + # Disabled by default for compatibility with older versions + copy_project: false # [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' diff --git a/kibot/out_sch_variant.py b/kibot/out_sch_variant.py index 334b6d34..256ce9d3 100644 --- a/kibot/out_sch_variant.py +++ b/kibot/out_sch_variant.py @@ -3,6 +3,7 @@ # Copyright (c) 2020-2021 Instituto Nacional de TecnologĂ­a Industrial # License: GPL-3.0 # Project: KiBot (formerly KiPlot) +import os from .gs import GS from .out_base import VariantOptions from .macros import macros, document, output_class # noqa: F401 @@ -10,6 +11,10 @@ from .macros import macros, document, output_class # noqa: F401 class Sch_Variant_Options(VariantOptions): def __init__(self): + with document: + self.copy_project = False + """ Copy the KiCad project to the destination directory. + Disabled by default for compatibility with older versions """ super().__init__() def get_targets(self, out_dir): @@ -19,6 +24,8 @@ class Sch_Variant_Options(VariantOptions): super().run(output_dir) # Create the schematic GS.sch.save_variant(output_dir) + if self.copy_project: + GS.copy_project(os.path.join(output_dir, GS.sch_basename+'.kicad_pcb')) @output_class @@ -34,6 +41,9 @@ class Sch_Variant(BaseOutput): # noqa: F821 """ *[dict] Options for the `sch_variant` output """ self._sch_related = True + def get_output_sch_name(self, out_dir): + return os.path.join(out_dir, os.path.basename(GS.sch_file)) + def run(self, output_dir): # No output member, just a dir self.options.run(output_dir)