diff --git a/kibot/out_any_layer.py b/kibot/out_any_layer.py index 68c23a11..2e4317a2 100644 --- a/kibot/out_any_layer.py +++ b/kibot/out_any_layer.py @@ -94,18 +94,6 @@ class AnyLayerOptions(VariantOptions): # We'll come back to this on a per-layer basis po.SetSkipPlotNPTH_Pads(False) - def filter_components(self, board): - """ Apply the variants and filters """ - if not self._comps: - return None - self.comps_hash = self.get_refs_hash() - self.cross_modules(board, self.comps_hash) - return self.remove_paste_and_glue(board, self.comps_hash) - - def unfilter_components(self, board): - self.uncross_modules(board, self.comps_hash) - self.restore_paste_and_glue(board, self.comps_hash) - def compute_name(self, k_filename, output_dir, output, id, suffix): if output: filename = self.expand_filename(output_dir, output, suffix, os.path.splitext(k_filename)[1][1:]) @@ -136,7 +124,7 @@ class AnyLayerOptions(VariantOptions): jobfile_writer = GERBER_JOBFILE_WRITER(GS.board) plot_ctrl.SetColorMode(True) # Apply the variants and filters - exclude = self.filter_components(GS.board) + exclude = self.filter_pcb_components(GS.board) # Plot every layer in the output generated = {} layers = Layer.solve(layers) @@ -193,7 +181,7 @@ class AnyLayerOptions(VariantOptions): f.write(content) # Restore the eliminated layers if exclude: - self.unfilter_components(GS.board) + self.unfilter_pcb_components(GS.board) def solve_extension(self, layer): if self._plot_format == PLOT_FORMAT_GERBER and self.use_protel_extensions: diff --git a/kibot/out_any_pcb_print.py b/kibot/out_any_pcb_print.py index 5ff434cb..b3244213 100644 --- a/kibot/out_any_pcb_print.py +++ b/kibot/out_any_pcb_print.py @@ -53,20 +53,13 @@ class Any_PCB_PrintOptions(VariantOptions): super().config(parent) self.drill_marks = DRILL_MARKS_MAP[self.drill_marks] - def filter_components(self, board, force_copy): + def filter_components(self, force_copy): if not self._comps and not force_copy: return GS.pcb_file, None - 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) + self.filter_pcb_components(GS.board) # Save the PCB to a temporal dir fname, pcb_dir = self.save_tmp_dir_board('pdf_pcb_print') - self.uncross_modules(board, comps_hash) - self.restore_paste_and_glue(board, comps_hash) - if self.hide_excluded: - self.restore_fab(board, comps_hash) + self.unfilter_pcb_components(GS.board) return fname, pcb_dir def get_targets(self, out_dir): @@ -93,7 +86,7 @@ class Any_PCB_PrintOptions(VariantOptions): if svg: cmd.append('--svg') self.set_title(self.title) - board_name, board_dir = self.filter_components(GS.board, self.title != '') + board_name, board_dir = self.filter_components(self.title != '') cmd.extend([board_name, os.path.dirname(output)]) cmd, video_remove = add_extra_options(cmd) # Add the layers diff --git a/kibot/out_base.py b/kibot/out_base.py index 2702f808..91b3b716 100644 --- a/kibot/out_base.py +++ b/kibot/out_base.py @@ -408,6 +408,24 @@ class VariantOptions(BaseOptions): for gi in self.old_bfab: gi.SetLayer(self.bfab) + def filter_pcb_components(self, board): + if not self._comps: + return False + self.comps_hash = self.get_refs_hash() + self.cross_modules(board, self.comps_hash) + self.remove_paste_and_glue(board, self.comps_hash) + if hasattr(self, 'hide_excluded') and self.hide_excluded: + self.remove_fab(board, self.comps_hash) + return True + + def unfilter_pcb_components(self, board): + if not self._comps: + return + self.uncross_modules(board, self.comps_hash) + self.restore_paste_and_glue(board, self.comps_hash) + if hasattr(self, 'hide_excluded') and self.hide_excluded: + self.restore_fab(board, self.comps_hash) + def set_title(self, title): self.old_title = None if title: diff --git a/kibot/out_pcb_print.py b/kibot/out_pcb_print.py index 5616a9e2..63ef428f 100644 --- a/kibot/out_pcb_print.py +++ b/kibot/out_pcb_print.py @@ -337,24 +337,6 @@ class PCB_PrintOptions(VariantOptions): if not ln.startswith('