diff --git a/README.md b/README.md index 956e2a82..396d6bbb 100644 --- a/README.md +++ b/README.md @@ -1365,6 +1365,7 @@ Next time you need this list just use an alias, like this: - `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. Internal variants and filters are currently ignored. + Exception: a KiCost variant that uses `variant` as variant field. - `fields`: [string|list(string)] List of fields to be added to the global data section. - `group_fields`: [string|list(string)] List of fields that can be different for a group. Parts with differences in these fields are grouped together, but displayed individually. @@ -1383,6 +1384,7 @@ Next time you need this list just use an alias, like this: - `name`: [string=''] New name. - `variant`: [string=''] Board variant to apply. Internal variants and filters are currently ignored. + Exception: a KiCost variant that uses `variant` as variant field. - `output_id`: [string=''] Text to use for the %I expansion content. To differentiate variations of this output. - `run_by_default`: [boolean=true] When enabled this output will be created when no specific outputs are requested. diff --git a/docs/samples/generic_plot.kibot.yaml b/docs/samples/generic_plot.kibot.yaml index e956927e..d29dd5b5 100644 --- a/docs/samples/generic_plot.kibot.yaml +++ b/docs/samples/generic_plot.kibot.yaml @@ -814,7 +814,8 @@ outputs: distributors: # [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. - # Internal variants and filters are currently ignored + # Internal variants and filters are currently ignored. + # Exception: a KiCost variant that uses `variant` as variant field dnf_filter: '_none' # [string|list(string)] List of fields to be added to the global data section fields: @@ -846,7 +847,8 @@ outputs: # [string=''] New name name: 'manf#' # [string=''] Board variant to apply. - # Internal variants and filters are currently ignored + # Internal variants and filters are currently ignored. + # Exception: a KiCost variant that uses `variant` as variant field variant: '' # PcbDraw - Beautiful 2D PCB render: diff --git a/kibot/out_kicost.py b/kibot/out_kicost.py index 3f7f6be6..bab5775b 100644 --- a/kibot/out_kicost.py +++ b/kibot/out_kicost.py @@ -8,6 +8,7 @@ from subprocess import check_output, STDOUT, CalledProcessError from .misc import CMD_KICOST, URL_KICOST, BOM_ERROR, DISTRIBUTORS, W_UNKDIST, ISO_CURRENCIES, W_UNKCUR, KICOST_SUBMODULE from .error import KiPlotConfigurationError from .optionable import Optionable +from .registrable import RegOutput from .gs import GS from .kiplot import check_script from .out_base import VariantOptions @@ -16,7 +17,8 @@ from .fil_base import FieldRename from . import log logger = log.get_logger() -WARNING_MIX = "Internal variants and filters are currently ignored" +WARNING_MIX = ("Internal variants and filters are currently ignored.\n" + "Exception: a KiCost variant that uses `variant` as variant field") class Aggregate(Optionable): @@ -98,6 +100,11 @@ class KiCostOptions(VariantOptions): return val def config(self, parent): + # If we are using a KiCost variant make it the default for `kicost_variant` + variant = RegOutput.check_variant(self.variant) + if variant is not None and variant.type == 'kicost' and variant.variant_field == 'variant': + logger.error('variant: '+str(variant.__dict__)) + self.kicost_variant = variant.variant super().config(parent) if not self.output: self.output = '%f.%x'