From 71f2894ef4008d537ffa8a7afdf8adc1a733668c Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Mon, 26 Dec 2022 09:06:37 -0300 Subject: [PATCH] [PDF/SVG PCB Print] Implemented sub-PCBs --- kibot/out_any_pcb_print.py | 10 +++++----- kibot/out_base.py | 6 +++++- .../print_pcb_sub_pcb_bp.kibot.yaml | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 tests/yaml_samples/print_pcb_sub_pcb_bp.kibot.yaml diff --git a/kibot/out_any_pcb_print.py b/kibot/out_any_pcb_print.py index ca1c5cf6..3cec4246 100644 --- a/kibot/out_any_pcb_print.py +++ b/kibot/out_any_pcb_print.py @@ -54,12 +54,14 @@ class Any_PCB_PrintOptions(VariantOptions): super().config(parent) self.drill_marks = DRILL_MARKS_MAP[self.drill_marks] - def filter_components(self, force_copy): - if not self._comps and not force_copy: + def filter_components(self): + if not self.will_filter_pcb_components() and self.title == '': return GS.pcb_file, None self.filter_pcb_components(GS.board) + self.set_title(self.title) # Save the PCB to a temporal dir fname, pcb_dir = self.save_tmp_dir_board('pdf_pcb_print') + self.restore_title() self.unfilter_pcb_components(GS.board) return fname, pcb_dir @@ -86,8 +88,7 @@ class Any_PCB_PrintOptions(VariantOptions): cmd.extend(['--color_theme', self.color_theme]) if svg: cmd.append('--svg') - self.set_title(self.title) - board_name, board_dir = self.filter_components(self.title != '') + board_name, board_dir = self.filter_components() cmd.extend([board_name, os.path.dirname(output)]) cmd, video_remove = add_extra_options(cmd) # Add the layers @@ -96,7 +97,6 @@ class Any_PCB_PrintOptions(VariantOptions): cmd.append('Edge.Cuts') # Execute it ret = exec_with_retry(cmd) - self.restore_title() # Remove the temporal PCB if board_dir: logger.debug('Removing temporal variant dir `{}`'.format(board_dir)) diff --git a/kibot/out_base.py b/kibot/out_base.py index 007be15a..34e49662 100644 --- a/kibot/out_base.py +++ b/kibot/out_base.py @@ -716,8 +716,12 @@ class VariantOptions(BaseOptions): dest = os.path.join(d, os.path.basename(GS.pcb_file)) self._sub_pcb.load_board(dest) + def will_filter_pcb_components(self): + """ True if we will apply filters/variants """ + return self._comps or self._sub_pcb + def filter_pcb_components(self, board, do_3D=False, do_2D=True, highlight=None): - if not self._comps and not self._sub_pcb: + if not self.will_filter_pcb_components(): return False if self._comps: self.comps_hash = self.get_refs_hash() diff --git a/tests/yaml_samples/print_pcb_sub_pcb_bp.kibot.yaml b/tests/yaml_samples/print_pcb_sub_pcb_bp.kibot.yaml new file mode 100644 index 00000000..13d2b5db --- /dev/null +++ b/tests/yaml_samples/print_pcb_sub_pcb_bp.kibot.yaml @@ -0,0 +1,17 @@ +# Example KiBot config file +kibot: + version: 1 + +import: + - file: battery_pack_sub_pcbs.kibot.yaml + +outputs: + - name: 'print_front' + comment: "Print F.Cu+F.SilkS" + type: pdf_pcb_print + dir: Layers + options: + title: 'Fake title for front copper and silk (%S)' + layers: + - layer: F.Cu + - layer: F.SilkS