[SCH Variant] Added option to copy the project

- May contain text variables
This commit is contained in:
Salvador E. Tropea 2022-09-09 11:33:40 -03:00
parent 0a817bfc60
commit 11cba00a1f
4 changed files with 16 additions and 0 deletions

View File

@ -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)

View File

@ -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.

View File

@ -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'

View File

@ -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)