From 22d618a425e9396daa6d48538ea044ec788cf820 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Tue, 6 Sep 2022 11:06:44 -0300 Subject: [PATCH] [PCB Print] Added option to configure the forced edge color. Closes #281 --- CHANGELOG.md | 1 + README.md | 1 + docs/samples/generic_plot.kibot.yaml | 2 ++ kibot/out_pcb_print.py | 15 +++++++++++---- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 584f164c..e40540c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 KiCad bug [11562](https://gitlab.com/kicad/code/kicad/-/issues/11562) - Internal BoM: KiCad 6 text variables expansion in the fields (#247) - Compress: Option to store symlinks. (See #265) +- PCB Print: Option to configure the forced edge color. (#281) ### Fixed - OAR computation (Report) (#225) diff --git a/README.md b/README.md index 94d9ed85..0cdd8264 100644 --- a/README.md +++ b/README.md @@ -2227,6 +2227,7 @@ Notes: - `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. - `drill_marks`: [string='full'] [none,small,full] What to use to indicate the drill places, can be none, small or full (for real scale). + - `forced_edge_cuts_color`: [string=''] Color used for the `force_edge_cuts` option. - `frame_plot_mechanism`: [string='internal'] [gui,internal,plot] Plotting the frame from Python is problematic. This option selects a workaround strategy. gui: uses KiCad GUI to do it. Is slow but you get the correct frame. diff --git a/docs/samples/generic_plot.kibot.yaml b/docs/samples/generic_plot.kibot.yaml index 040b260a..5e465a8f 100644 --- a/docs/samples/generic_plot.kibot.yaml +++ b/docs/samples/generic_plot.kibot.yaml @@ -1090,6 +1090,8 @@ outputs: drill_marks: 'full' # [boolean=false] Add the `Edge.Cuts` to all the pages force_edge_cuts: false + # [string=''] Color used for the `force_edge_cuts` option + forced_edge_cuts_color: '' # [string='PDF'] [PDF,SVG,PNG,EPS,PS] Format for the output file/s. # Note that for PS you need `ghostscript` which isn't part of the default docker images format: 'PDF' diff --git a/kibot/out_pcb_print.py b/kibot/out_pcb_print.py index e19f5cf0..eeda77a0 100644 --- a/kibot/out_pcb_print.py +++ b/kibot/out_pcb_print.py @@ -264,6 +264,8 @@ class PCB_PrintOptions(VariantOptions): """ Store the temporal page and layer files in the output dir and don't delete them """ self.force_edge_cuts = False """ *Add the `Edge.Cuts` to all the pages """ + self.forced_edge_cuts_color = '' + """ Color used for the `force_edge_cuts` option """ self.scaling = 1.0 """ *Default scale factor (0 means autoscaling)""" self.realistic_solder_mask = True @@ -303,6 +305,8 @@ class PCB_PrintOptions(VariantOptions): self.validate_color(member) else: setattr(self, member, getattr(self._color_theme, color)) + if self.forced_edge_cuts_color: + self.validate_color('forced_edge_cuts_color') if self.frame_plot_mechanism == 'plot' and GS.ki5: raise KiPlotConfigurationError("You can't use `plot` for `frame_plot_mechanism` with KiCad 5. It will crash.") KiConf.init(GS.pcb_file) @@ -921,11 +925,14 @@ class PCB_PrintOptions(VariantOptions): if self.force_edge_cuts: edge_layer = LayerOptions.create_layer('Edge.Cuts') edge_id = edge_layer._id - layer_id2color = self._color_theme.layer_id2color - if edge_id in layer_id2color: - edge_layer.color = layer_id2color[edge_id] + if self.forced_edge_cuts_color: + edge_layer.color = self.forced_edge_cuts_color else: - edge_layer.color = "#000000" + layer_id2color = self._color_theme.layer_id2color + if edge_id in layer_id2color: + edge_layer.color = layer_id2color[edge_id] + else: + edge_layer.color = "#000000" # Generate the output, page by page pages = [] for n, p in enumerate(self.pages):