[Globals] Added options to control which stuff is changed on PCB variants

- cross_footprints_for_dnp
- remove_adhesive_for_dnp
- remove_solder_paste_for_dnp
- hide_excluded (default value)

Related to #270
This commit is contained in:
Salvador E. Tropea 2022-09-13 10:44:07 -03:00
parent 661677608e
commit 6f2c4ccf24
11 changed files with 92 additions and 49 deletions

View File

@ -11,8 +11,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- File_Copy: used to copy files to the output directory. (#279) - File_Copy: used to copy files to the output directory. (#279)
- Support for Eurocircuits drill adjust to fix small OARs. - Support for Eurocircuits drill adjust to fix small OARs.
Option `eurocircuits_reduce_holes`. (#227) Option `eurocircuits_reduce_holes`. (#227)
- Support for changing text variables with variants during outputs creation. - Global options:
- Support for changing text variables with variants during outputs creation.
Option `set_text_variables_before_output`. (See #233) Option `set_text_variables_before_output`. (See #233)
- Options to control which stuff is changed on PCB variants: (See #270)
- cross_footprints_for_dnp
- remove_adhesive_for_dnp
- remove_solder_paste_for_dnp
- hide_excluded (default value)
- Diff: mechanism to compare using a variant (See #278) - Diff: mechanism to compare using a variant (See #278)
- Sch Variant: - Sch Variant:
- Option to copy the project. Needed for text variables. - Option to copy the project. Needed for text variables.

View File

@ -644,6 +644,7 @@ global:
- *copper_finish*: Alias for pcb_finish. - *copper_finish*: Alias for pcb_finish.
- `copper_thickness`: [number|string] Copper thickness in micrometers (1 Oz is 35 micrometers). - `copper_thickness`: [number|string] Copper thickness in micrometers (1 Oz is 35 micrometers).
KiCad 6: you should set this in the Board Setup -> Physical Stackup. KiCad 6: you should set this in the Board Setup -> Physical Stackup.
- `cross_footprints_for_dnp`: [boolean=true] Draw a cross for excluded components in the `Fab` layer.
- `cross_no_body`: [boolean=false] Cross components even when they don't have a body. Only for KiCad 6. - `cross_no_body`: [boolean=false] Cross components even when they don't have a body. Only for KiCad 6.
- `date_format`: [string='%Y-%m-%d'] Format used for the day we started the script. - `date_format`: [string='%Y-%m-%d'] Format used for the day we started the script.
Is also used for the PCB/SCH date formatting when `time_reformat` is enabled (default behavior). Is also used for the PCB/SCH date formatting when `time_reformat` is enabled (default behavior).
@ -688,6 +689,7 @@ global:
- `number`: [number=0] Error number we want to exclude. KiCad 5 only. - `number`: [number=0] Error number we want to exclude. KiCad 5 only.
- `regex`: [string=''] Regular expression to match the text for the error we want to exclude. - `regex`: [string=''] Regular expression to match the text for the error we want to exclude.
- *regexp*: Alias for regex. - *regexp*: Alias for regex.
- `hide_excluded`: [boolean=false] Default value for the `hide_excluded` option of various PCB outputs.
- `impedance_controlled`: [boolean=false] The PCB needs specific dielectric characteristics. - `impedance_controlled`: [boolean=false] The PCB needs specific dielectric characteristics.
KiCad 6: you should set this in the Board Setup -> Physical Stackup. KiCad 6: you should set this in the Board Setup -> Physical Stackup.
- `kiauto_time_out_scale`: [number=0.0] Time-out multiplier for KiAuto operations. - `kiauto_time_out_scale`: [number=0.0] Time-out multiplier for KiAuto operations.
@ -700,6 +702,8 @@ global:
Immersion Ag, ImAu, Immersion Gold, Immersion Au, Immersion Tin, Immersion Nickel, OSP and HT_OSP. Immersion Ag, ImAu, Immersion Gold, Immersion Au, Immersion Tin, Immersion Nickel, OSP and HT_OSP.
- `pcb_material`: [string='FR4'] PCB core material. Currently used for documentation and to choose default colors. - `pcb_material`: [string='FR4'] PCB core material. Currently used for documentation and to choose default colors.
Currently known are FR1 to FR5. Currently known are FR1 to FR5.
- `remove_adhesive_for_dnp`: [boolean=true] When applying filters and variants remove the adhesive (glue) for components that won't be included.
- `remove_solder_paste_for_dnp`: [boolean=true] When applying filters and variants remove the solder paste for components that won't be included.
- `restore_project`: [boolean=false] Restore the KiCad project after execution. - `restore_project`: [boolean=false] Restore the KiCad project after execution.
Note that this option will undo operations like `set_text_variables`. Note that this option will undo operations like `set_text_variables`.
- `set_text_variables_before_output`: [boolean=false] Run the `set_text_variables` preflight before running each output that involves variants. - `set_text_variables_before_output`: [boolean=false] Run the `set_text_variables` preflight before running each output that involves variants.
@ -2305,6 +2309,7 @@ Notes:
plot: uses KiCad Python API. Only available for KiCad 6. plot: uses KiCad Python API. Only available for KiCad 6.
You get the default frame and some substitutions doesn't work. You get the default frame and some substitutions doesn't work.
- `hide_excluded`: [boolean=false] Hide components in the Fab layer that are marked as excluded by a variant. - `hide_excluded`: [boolean=false] Hide components in the Fab layer that are marked as excluded by a variant.
Affected by global options.
- `keep_temporal_files`: [boolean=false] Store the temporal page and layer files in the output dir and don't delete them. - `keep_temporal_files`: [boolean=false] Store the temporal page and layer files in the output dir and don't delete them.
- `micro_via_color`: [string=''] Color used for micro `colored_vias`. - `micro_via_color`: [string=''] Color used for micro `colored_vias`.
- `pad_color`: [string=''] Color used for `colored_pads`. - `pad_color`: [string=''] Color used for `colored_pads`.
@ -2347,6 +2352,7 @@ Notes:
- `dnf_filter`: [string|list(string)='_none'] Name of the filter to mark components as not fitted. - `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. 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. - `hide_excluded`: [boolean=false] Hide components in the Fab layer that are marked as excluded by a variant.
Affected by global options.
- `title`: [string=''] Text used to replace the sheet title. %VALUE expansions are allowed. - `title`: [string=''] Text used to replace the sheet title. %VALUE expansions are allowed.
If it starts with `+` the text is concatenated. If it starts with `+` the text is concatenated.
- `variant`: [string=''] Board variant to apply. - `variant`: [string=''] Board variant to apply.
@ -2530,6 +2536,7 @@ Notes:
KiCad 5 forces it by default, and you can't control it from config files. KiCad 5 forces it by default, and you can't control it from config files.
Same for KiCad 6 when printing to separated pages. Same for KiCad 6 when printing to separated pages.
- `hide_excluded`: [boolean=false] Hide components in the Fab layer that are marked as excluded by a variant. - `hide_excluded`: [boolean=false] Hide components in the Fab layer that are marked as excluded by a variant.
Affected by global options.
- `mirror`: [boolean=false] Print mirrored (X axis inverted). ONLY for KiCad 6. - `mirror`: [boolean=false] Print mirrored (X axis inverted). ONLY for KiCad 6.
- `monochrome`: [boolean=false] Print in black and white. - `monochrome`: [boolean=false] Print in black and white.
- `output`: [string='%f-%i%I%v.%x'] Filename for the output PDF (%i=layers, %x=pdf). Affected by global options. - `output`: [string='%f-%i%I%v.%x'] Filename for the output PDF (%i=layers, %x=pdf). Affected by global options.
@ -3021,6 +3028,7 @@ Notes:
KiCad 5 forces it by default, and you can't control it from config files. KiCad 5 forces it by default, and you can't control it from config files.
Same for KiCad 6 when printing to separated pages. Same for KiCad 6 when printing to separated pages.
- `hide_excluded`: [boolean=false] Hide components in the Fab layer that are marked as excluded by a variant. - `hide_excluded`: [boolean=false] Hide components in the Fab layer that are marked as excluded by a variant.
Affected by global options.
- `mirror`: [boolean=false] Print mirrored (X axis inverted). ONLY for KiCad 6. - `mirror`: [boolean=false] Print mirrored (X axis inverted). ONLY for KiCad 6.
- `monochrome`: [boolean=false] Print in black and white. - `monochrome`: [boolean=false] Print in black and white.
- `title`: [string=''] Text used to replace the sheet title. %VALUE expansions are allowed. - `title`: [string=''] Text used to replace the sheet title. %VALUE expansions are allowed.

View File

@ -1160,7 +1160,8 @@ outputs:
# plot: uses KiCad Python API. Only available for KiCad 6. # plot: uses KiCad Python API. Only available for KiCad 6.
# You get the default frame and some substitutions doesn't work # You get the default frame and some substitutions doesn't work
frame_plot_mechanism: 'internal' frame_plot_mechanism: 'internal'
# [boolean=false] Hide components in the Fab layer that are marked as excluded by a variant # [boolean=false] Hide components in the Fab layer that are marked as excluded by a variant.
# Affected by global options
hide_excluded: false hide_excluded: false
# [boolean=false] Store the temporal page and layer files in the output dir and don't delete them # [boolean=false] Store the temporal page and layer files in the output dir and don't delete them
keep_temporal_files: false keep_temporal_files: false
@ -1257,7 +1258,8 @@ outputs:
# [string|list(string)='_none'] Name of the filter to mark components as not fitted. # [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 # A short-cut to use for simple cases where a variant is an overkill
dnf_filter: '_none' dnf_filter: '_none'
# [boolean=false] Hide components in the Fab layer that are marked as excluded by a variant # [boolean=false] Hide components in the Fab layer that are marked as excluded by a variant.
# Affected by global options
hide_excluded: false hide_excluded: false
# [string='%f-%i%I%v.%x'] Filename for the output (%i=variant, %x=kicad_pcb). Affected by global options # [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' output: '%f-%i%I%v.%x'
@ -1408,7 +1410,8 @@ outputs:
# KiCad 5 forces it by default, and you can't control it from config files. # KiCad 5 forces it by default, and you can't control it from config files.
# Same for KiCad 6 when printing to separated pages # Same for KiCad 6 when printing to separated pages
force_edge_cuts: true force_edge_cuts: true
# [boolean=false] Hide components in the Fab layer that are marked as excluded by a variant # [boolean=false] Hide components in the Fab layer that are marked as excluded by a variant.
# Affected by global options
hide_excluded: false hide_excluded: false
# [boolean=false] Print mirrored (X axis inverted). ONLY for KiCad 6 # [boolean=false] Print mirrored (X axis inverted). ONLY for KiCad 6
mirror: false mirror: false
@ -1867,7 +1870,8 @@ outputs:
# KiCad 5 forces it by default, and you can't control it from config files. # KiCad 5 forces it by default, and you can't control it from config files.
# Same for KiCad 6 when printing to separated pages # Same for KiCad 6 when printing to separated pages
force_edge_cuts: true force_edge_cuts: true
# [boolean=false] Hide components in the Fab layer that are marked as excluded by a variant # [boolean=false] Hide components in the Fab layer that are marked as excluded by a variant.
# Affected by global options
hide_excluded: false hide_excluded: false
# [boolean=false] Print mirrored (X axis inverted). ONLY for KiCad 6 # [boolean=false] Print mirrored (X axis inverted). ONLY for KiCad 6
mirror: false mirror: false

View File

@ -100,6 +100,8 @@ class Globals(FiltersOptions):
self.copper_thickness = 35 self.copper_thickness = 35
""" [number|string] Copper thickness in micrometers (1 Oz is 35 micrometers). """ [number|string] Copper thickness in micrometers (1 Oz is 35 micrometers).
KiCad 6: you should set this in the Board Setup -> Physical Stackup """ KiCad 6: you should set this in the Board Setup -> Physical Stackup """
self.cross_footprints_for_dnp = True
""" Draw a cross for excluded components in the `Fab` layer """
self.cross_no_body = False self.cross_no_body = False
""" Cross components even when they don't have a body. Only for KiCad 6 """ """ Cross components even when they don't have a body. Only for KiCad 6 """
self.date_format = '%Y-%m-%d' self.date_format = '%Y-%m-%d'
@ -130,6 +132,8 @@ class Globals(FiltersOptions):
For more information consult: https://www.eurocircuits.com/pcb-design-guidelines/drilled-holes/ """ For more information consult: https://www.eurocircuits.com/pcb-design-guidelines/drilled-holes/ """
self.field_3D_model = '_3D_model' self.field_3D_model = '_3D_model'
""" Name for the field controlling the 3D models used for a component """ """ Name for the field controlling the 3D models used for a component """
self.hide_excluded = False
""" Default value for the `hide_excluded` option of various PCB outputs """
self.kiauto_time_out_scale = 0.0 self.kiauto_time_out_scale = 0.0
""" Time-out multiplier for KiAuto operations """ """ Time-out multiplier for KiAuto operations """
self.kiauto_wait_start = 0 self.kiauto_wait_start = 0
@ -147,6 +151,10 @@ class Globals(FiltersOptions):
self.pcb_material = 'FR4' self.pcb_material = 'FR4'
""" PCB core material. Currently used for documentation and to choose default colors. """ PCB core material. Currently used for documentation and to choose default colors.
Currently known are FR1 to FR5 """ Currently known are FR1 to FR5 """
self.remove_solder_paste_for_dnp = True
""" When applying filters and variants remove the solder paste for components that won't be included """
self.remove_adhesive_for_dnp = True
""" When applying filters and variants remove the adhesive (glue) for components that won't be included """
self.restore_project = False self.restore_project = False
""" Restore the KiCad project after execution. """ Restore the KiCad project after execution.
Note that this option will undo operations like `set_text_variables` """ Note that this option will undo operations like `set_text_variables` """

View File

@ -99,6 +99,7 @@ class GS(object):
class_for_global_opts = None class_for_global_opts = None
global_castellated_pads = None global_castellated_pads = None
global_copper_thickness = None global_copper_thickness = None
global_cross_footprints_for_dnp = None
global_cross_no_body = None global_cross_no_body = None
global_date_format = None global_date_format = None
global_date_time_format = None global_date_time_format = None
@ -109,6 +110,7 @@ class GS(object):
global_edge_plating = None global_edge_plating = None
global_extra_pth_drill = None global_extra_pth_drill = None
global_field_3D_model = None global_field_3D_model = None
global_hide_excluded = None
global_kiauto_time_out_scale = None global_kiauto_time_out_scale = None
global_kiauto_wait_start = None global_kiauto_wait_start = None
global_impedance_controlled = None global_impedance_controlled = None
@ -118,6 +120,8 @@ class GS(object):
global_output = None global_output = None
global_pcb_finish = None global_pcb_finish = None
global_pcb_material = None global_pcb_material = None
global_remove_solder_paste_for_dnp = None
global_remove_adhesive_for_dnp = None
global_restore_project = None global_restore_project = None
global_set_text_variables_before_output = None global_set_text_variables_before_output = None
global_silk_screen_color = None global_silk_screen_color = None

View File

@ -43,7 +43,7 @@ class Optionable(object):
self._expand_id = '' self._expand_id = ''
self._expand_ext = '' self._expand_ext = ''
super().__init__() super().__init__()
for var in ['output', 'variant', 'units']: for var in ['output', 'variant', 'units', 'hide_excluded']:
glb = getattr(GS, 'global_'+var) glb = getattr(GS, 'global_'+var)
if glb and hasattr(self, var): if glb and hasattr(self, var):
setattr(self, var, glb) setattr(self, var, glb)

View File

@ -34,7 +34,8 @@ class Any_PCB_PrintOptions(VariantOptions):
self.mirror = False self.mirror = False
""" Print mirrored (X axis inverted). ONLY for KiCad 6 """ """ Print mirrored (X axis inverted). ONLY for KiCad 6 """
self.hide_excluded = False self.hide_excluded = False
""" Hide components in the Fab layer that are marked as excluded by a variant """ """ Hide components in the Fab layer that are marked as excluded by a variant.
Affected by global options """
self.title = '' self.title = ''
""" Text used to replace the sheet title. %VALUE expansions are allowed. """ Text used to replace the sheet title. %VALUE expansions are allowed.
If it starts with `+` the text is concatenated """ If it starts with `+` the text is concatenated """

View File

@ -252,7 +252,7 @@ class VariantOptions(BaseOptions):
def cross_modules(self, board, comps_hash): def cross_modules(self, board, comps_hash):
""" Draw a cross in all 'not fitted' modules using *.Fab layer """ """ Draw a cross in all 'not fitted' modules using *.Fab layer """
if comps_hash is None: if comps_hash is None or not GS.global_cross_footprints_for_dnp:
return return
# Cross the affected components # Cross the affected components
ffab = board.GetLayerID('F.Fab') ffab = board.GetLayerID('F.Fab')
@ -289,7 +289,7 @@ class VariantOptions(BaseOptions):
def uncross_modules(self, board, comps_hash): def uncross_modules(self, board, comps_hash):
""" Undo the crosses in *.Fab layer """ """ Undo the crosses in *.Fab layer """
if comps_hash is None: if comps_hash is None or not GS.global_cross_footprints_for_dnp:
return return
# Undo the drawings # Undo the drawings
for m in GS.get_modules_board(board): for m in GS.get_modules_board(board):
@ -307,7 +307,7 @@ class VariantOptions(BaseOptions):
def remove_paste_and_glue(self, board, comps_hash): def remove_paste_and_glue(self, board, comps_hash):
""" Remove from solder paste layers the filtered components. """ """ Remove from solder paste layers the filtered components. """
if comps_hash is None: if comps_hash is None or not (GS.global_remove_solder_paste_for_dnp or GS.global_remove_adhesive_for_dnp):
return return
exclude = LSET() exclude = LSET()
fpaste = board.GetLayerID('F.Paste') fpaste = board.GetLayerID('F.Paste')
@ -327,6 +327,7 @@ class VariantOptions(BaseOptions):
c = comps_hash.get(ref, None) c = comps_hash.get(ref, None)
if c and c.included and not c.fitted: if c and c.included and not c.fitted:
# Remove all pads from *.Paste # Remove all pads from *.Paste
if GS.global_remove_solder_paste_for_dnp:
old_c_layers = [] old_c_layers = []
for p in m.Pads(): for p in m.Pads():
pad_layers = p.GetLayerSet() pad_layers = p.GetLayerSet()
@ -341,6 +342,7 @@ class VariantOptions(BaseOptions):
p.SetLayerSet(pad_layers) p.SetLayerSet(pad_layers)
old_layers.append(old_c_layers) old_layers.append(old_c_layers)
# Remove any graphical item in the *.Adhes layers # Remove any graphical item in the *.Adhes layers
if GS.global_remove_adhesive_for_dnp:
for gi in m.GraphicalItems(): for gi in m.GraphicalItems():
l_gi = gi.GetLayer() l_gi = gi.GetLayer()
if l_gi == fadhes: if l_gi == fadhes:
@ -360,6 +362,7 @@ class VariantOptions(BaseOptions):
def restore_paste_and_glue(self, board, comps_hash): def restore_paste_and_glue(self, board, comps_hash):
if comps_hash is None: if comps_hash is None:
return return
if GS.global_remove_solder_paste_for_dnp:
for m in GS.get_modules_board(board): for m in GS.get_modules_board(board):
ref = m.GetReference() ref = m.GetReference()
c = comps_hash.get(ref, None) c = comps_hash.get(ref, None)
@ -370,6 +373,7 @@ class VariantOptions(BaseOptions):
res = restore.pop(0) res = restore.pop(0)
pad_layers.ParseHex(res, len(res)) pad_layers.ParseHex(res, len(res))
p.SetLayerSet(pad_layers) p.SetLayerSet(pad_layers)
if GS.global_remove_adhesive_for_dnp:
for gi in self.old_fadhes: for gi in self.old_fadhes:
gi.SetLayer(self.fadhes) gi.SetLayer(self.fadhes)
for gi in self.old_badhes: for gi in self.old_badhes:

View File

@ -229,7 +229,8 @@ class PCB_PrintOptions(VariantOptions):
""" When enabled the %i is always `assembly`, the %x will be NN.FORMAT (i.e. 01.png). """ When enabled the %i is always `assembly`, the %x will be NN.FORMAT (i.e. 01.png).
Note: page numbers can be customized using the `page_id` option for each page """ Note: page numbers can be customized using the `page_id` option for each page """
self.hide_excluded = False self.hide_excluded = False
""" Hide components in the Fab layer that are marked as excluded by a variant """ """ Hide components in the Fab layer that are marked as excluded by a variant.
Affected by global options """
self.color_theme = '_builtin_classic' self.color_theme = '_builtin_classic'
""" *Selects the color theme. Only applies to KiCad 6. """ *Selects the color theme. Only applies to KiCad 6.
To use the KiCad 6 default colors select `_builtin_default`. To use the KiCad 6 default colors select `_builtin_default`.

View File

@ -15,7 +15,8 @@ class PCB_Variant_Options(VariantOptions):
def __init__(self): def __init__(self):
with document: with document:
self.hide_excluded = False self.hide_excluded = False
""" Hide components in the Fab layer that are marked as excluded by a variant """ """ Hide components in the Fab layer that are marked as excluded by a variant.
Affected by global options """
self.output = GS.def_global_output self.output = GS.def_global_output
""" *Filename for the output (%i=variant, %x=kicad_pcb) """ """ *Filename for the output (%i=variant, %x=kicad_pcb) """
self.copy_project = True self.copy_project = True

View File

@ -2,6 +2,12 @@
kibot: kibot:
version: 1 version: 1
global:
# remove_solder_paste_for_dnp: false
# remove_adhesive_for_dnp: false
# cross_footprints_for_dnp: false
hide_excluded: true
variants: variants:
- name: 'production' - name: 'production'
comment: 'Production variant' comment: 'Production variant'
@ -45,7 +51,7 @@ outputs:
- name: 'diff_pcb' - name: 'diff_pcb'
comment: "PCB difference with variant" comment: "PCB difference with variant"
type: diff type: diff
layers: ['F.Cu', 'F.Fab'] layers: ['F.Cu', 'F.Fab', 'F.Adhes', 'F.Paste']
options: options:
# old: pcb_default # old: pcb_default
# old_type: output # old_type: output