Option to hide component from PDF PCB Print
- option `hide_excluded` to hide components marked by the `exclude_filter`. - https://forum.kicad.info/t/fab-drawing-for-only-through-hole-parts/
This commit is contained in:
parent
e62e38b6ea
commit
499b3520a6
|
|
@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- skip_bottom: bottom components aren't rotated.
|
||||
- XLSX BoM: option to control the logo scale (#84)
|
||||
- Import mechanism for filters and variants (#88)
|
||||
- PDF PCB Print: option `hide_excluded` to hide components marked by the
|
||||
`exclude_filter`.
|
||||
https://forum.kicad.info/t/fab-drawing-for-only-through-hole-parts/
|
||||
- Internal BoM: option to avoid merging components with empty fields.
|
||||
Is named `merge_both_blank` and defaults to true.
|
||||
- Internal BoM: when a `Value` field can't be interpreted as a `number+unit`,
|
||||
|
|
|
|||
|
|
@ -1275,6 +1275,7 @@ Next time you need this list just use an alias, like this:
|
|||
- `dnf_filter`: [string|list(string)=''] Name of the filter to mark components as not fitted.
|
||||
A short-cut to use for simple cases where a variant is an overkill.
|
||||
- `drill_marks`: [string='full'] What to use to indicate the drill places, can be none, small or full (for real scale).
|
||||
- `hide_excluded`: [boolean=false] Hide components in the Fab layer that are marked as excluded by a variant.
|
||||
- `mirror`: [boolean=false] Print mirrored (X axis inverted). ONLY for KiCad 6.
|
||||
- `monochrome`: [boolean=false] Print in black and white.
|
||||
- `output`: [string='%f-%i%v.%x'] Filename for the output PDF (%i=layers, %x=pdf). Affected by global options.
|
||||
|
|
|
|||
|
|
@ -879,6 +879,8 @@ outputs:
|
|||
dnf_filter: ''
|
||||
# [string='full'] What to use to indicate the drill places, can be none, small or full (for real scale)
|
||||
drill_marks: 'full'
|
||||
# [boolean=false] Hide components in the Fab layer that are marked as excluded by a variant
|
||||
hide_excluded: false
|
||||
# [boolean=false] Print mirrored (X axis inverted). ONLY for KiCad 6
|
||||
mirror: false
|
||||
# [boolean=false] Print in black and white
|
||||
|
|
|
|||
|
|
@ -286,6 +286,38 @@ class VariantOptions(BaseOptions):
|
|||
for gi in self.old_badhes:
|
||||
gi.SetLayer(self.badhes)
|
||||
|
||||
def remove_fab(self, board, comps_hash):
|
||||
""" Remove from Fab the excluded components. """
|
||||
ffab = board.GetLayerID('F.Fab')
|
||||
bfab = board.GetLayerID('B.Fab')
|
||||
old_ffab = []
|
||||
old_bfab = []
|
||||
rescue = board.GetLayerID('Rescue')
|
||||
for m in board.GetModules():
|
||||
ref = m.GetReference()
|
||||
c = comps_hash.get(ref, None)
|
||||
if not c.included:
|
||||
# Remove any graphical item in the *.Fab layers
|
||||
for gi in m.GraphicalItems():
|
||||
l_gi = gi.GetLayer()
|
||||
if l_gi == ffab:
|
||||
gi.SetLayer(rescue)
|
||||
old_ffab.append(gi)
|
||||
if l_gi == bfab:
|
||||
gi.SetLayer(rescue)
|
||||
old_bfab.append(gi)
|
||||
# Store the data to undo the above actions
|
||||
self.old_ffab = old_ffab
|
||||
self.old_bfab = old_bfab
|
||||
self.ffab = ffab
|
||||
self.bfab = bfab
|
||||
|
||||
def restore_fab(self, board, comps_hash):
|
||||
for gi in self.old_ffab:
|
||||
gi.SetLayer(self.ffab)
|
||||
for gi in self.old_bfab:
|
||||
gi.SetLayer(self.bfab)
|
||||
|
||||
def run(self, output_dir):
|
||||
""" Makes the list of components available """
|
||||
if not self.dnf_filter and not self.variant:
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ class PDF_Pcb_PrintOptions(VariantOptions):
|
|||
""" Print layers in separated pages """
|
||||
self.mirror = False
|
||||
""" Print mirrored (X axis inverted). ONLY for KiCad 6 """
|
||||
self.hide_excluded = False
|
||||
""" Hide components in the Fab layer that are marked as excluded by a variant """
|
||||
super().__init__()
|
||||
self._expand_ext = 'pdf'
|
||||
|
||||
|
|
@ -75,6 +77,8 @@ class PDF_Pcb_PrintOptions(VariantOptions):
|
|||
comps_hash = self.get_refs_hash()
|
||||
self.cross_modules(board, comps_hash)
|
||||
self.remove_paste_and_glue(board, comps_hash)
|
||||
if self.hide_excluded:
|
||||
self.remove_fab(board, comps_hash)
|
||||
# Save the PCB to a temporal file
|
||||
with NamedTemporaryFile(mode='w', suffix='.kicad_pcb', delete=False) as f:
|
||||
fname = f.name
|
||||
|
|
@ -84,6 +88,8 @@ class PDF_Pcb_PrintOptions(VariantOptions):
|
|||
fproj = self._copy_project(fname)
|
||||
self.uncross_modules(board, comps_hash)
|
||||
self.restore_paste_and_glue(board, comps_hash)
|
||||
if self.hide_excluded:
|
||||
self.restore_fab(board, comps_hash)
|
||||
return fname, fproj
|
||||
|
||||
def get_targets(self, out_dir):
|
||||
|
|
|
|||
Loading…
Reference in New Issue