diff --git a/CHANGELOG.md b/CHANGELOG.md index 50826558..ae4453be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support for CURRENT_DATE text variable - Options to mirror the text in the user layers when creating a mirrored page (#561) + - Options to select which layers are used for centering purposes (#573) - Populate: - Basic support for regular list items (#480) - Position: diff --git a/docs/samples/generic_plot.kibot.yaml b/docs/samples/generic_plot.kibot.yaml index 79a76bec..289f2c7b 100644 --- a/docs/samples/generic_plot.kibot.yaml +++ b/docs/samples/generic_plot.kibot.yaml @@ -2342,6 +2342,9 @@ outputs: force_edge_cuts: false # [string=''] Color used for the `force_edge_cuts` option forced_edge_cuts_color: '' + # [boolean=true] Used when enabling the `force_edge_cuts`, in this case this is the `use_for_center` option of the forced + # layer + forced_edge_cuts_use_for_center: true # [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' @@ -2360,6 +2363,10 @@ outputs: # [boolean=true] Tell KiCad to apply the scaling for each page as a separated entity. # Disabling it the pages are coherent and can be superposed individual_page_scaling: true + # [boolean=false] Invert the meaning of the `use_for_center` layer option. + # This can be used to just select the edge cuts for centering, in this case enable this option + # and disable the `use_for_center` option of the edge cuts layer + invert_use_for_center: false # [boolean=false] Store the temporal page and layer files in the output dir and don't delete them keep_temporal_files: false # [string=''] Color used for micro `colored_vias` @@ -2407,6 +2414,9 @@ outputs: # [string=''] Suffix used in file names related to this layer. Derived from the name if not specified. # A default can be specified using the `layer_defaults` global option suffix: '' + # [boolean=true] Use this layer for centering purposes. + # You can invert the meaning using the `invert_use_for_center` option + use_for_center: true # [number=0.1] [0.02,2] For objects without width [mm] (KiCad 5) line_width: 0.1 # [boolean=false] Print mirrored (X axis inverted) @@ -2449,6 +2459,9 @@ outputs: # [string=''] Suffix used in file names related to this layer. Derived from the name if not specified. # A default can be specified using the `layer_defaults` global option suffix: '' + # [boolean=true] Use this layer for centering purposes. + # You can invert the meaning using the `invert_use_for_center` option + use_for_center: true # [number=1.0] Scale factor (0 means autoscaling) scaling: 1.0 # [string='Assembly'] Text to use for the `sheet` in the title block. diff --git a/docs/source/configuration/outputs/pcb_print.rst b/docs/source/configuration/outputs/pcb_print.rst index 93254e1f..bef24d5c 100644 --- a/docs/source/configuration/outputs/pcb_print.rst +++ b/docs/source/configuration/outputs/pcb_print.rst @@ -55,6 +55,8 @@ Parameters: - ``plot_footprint_values`` :index:`: ` [boolean=true] Include the footprint values. - ``suffix`` :index:`: ` [string=''] Suffix used in file names related to this layer. Derived from the name if not specified. A default can be specified using the `layer_defaults` global option. + - ``use_for_center`` :index:`: ` [boolean=true] Use this layer for centering purposes. + You can invert the meaning using the `invert_use_for_center` option. - **scaling** :index:`: ` [number=1.0] Scale factor (0 means autoscaling). - **sort_layers** :index:`: ` [boolean=false] Try to sort the layers in the same order that uses KiCad for printing. @@ -91,6 +93,8 @@ Parameters: - ``plot_footprint_values`` :index:`: ` [boolean=true] Include the footprint values. - ``suffix`` :index:`: ` [string=''] Suffix used in file names related to this layer. Derived from the name if not specified. A default can be specified using the `layer_defaults` global option. + - ``use_for_center`` :index:`: ` [boolean=true] Use this layer for centering purposes. + You can invert the meaning using the `invert_use_for_center` option. - ``sheet`` :index:`: ` [string='Assembly'] Text to use for the `sheet` in the title block. Pattern (%*) and text variables are expanded. @@ -121,6 +125,8 @@ Parameters: like the the solder mask are handled as images by the conversion tools. - ``drill_marks`` :index:`: ` [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`` :index:`: ` [string=''] Color used for the `force_edge_cuts` option. + - ``forced_edge_cuts_use_for_center`` :index:`: ` [boolean=true] Used when enabling the `force_edge_cuts`, in this case this is the `use_for_center` option of the forced + layer. - ``frame_plot_mechanism`` :index:`: ` [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. @@ -133,6 +139,9 @@ Parameters: Affected by global options. - ``individual_page_scaling`` :index:`: ` [boolean=true] Tell KiCad to apply the scaling for each page as a separated entity. Disabling it the pages are coherent and can be superposed. + - ``invert_use_for_center`` :index:`: ` [boolean=false] Invert the meaning of the `use_for_center` layer option. + This can be used to just select the edge cuts for centering, in this case enable this option + and disable the `use_for_center` option of the edge cuts layer. - ``keep_temporal_files`` :index:`: ` [boolean=false] Store the temporal page and layer files in the output dir and don't delete them. - ``micro_via_color`` :index:`: ` [string=''] Color used for micro `colored_vias`. - ``pad_color`` :index:`: ` [string=''] Color used for `colored_pads`. diff --git a/kibot/out_pcb_print.py b/kibot/out_pcb_print.py index 6ece32cd..a4586013 100644 --- a/kibot/out_pcb_print.py +++ b/kibot/out_pcb_print.py @@ -135,6 +135,9 @@ class LayerOptions(Layer): """ Include the footprint values """ self.force_plot_invisible_refs_vals = False """ Include references and values even when they are marked as invisible """ + self.use_for_center = True + """ Use this layer for centering purposes. + You can invert the meaning using the `invert_use_for_center` option """ def config(self, parent): super().config(parent) @@ -327,6 +330,9 @@ 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_use_for_center = True + """ Used when enabling the `force_edge_cuts`, in this case this is the `use_for_center` option of the forced + layer """ self.forced_edge_cuts_color = '' """ Color used for the `force_edge_cuts` option """ self.scaling = 1.0 @@ -352,6 +358,10 @@ class PCB_PrintOptions(VariantOptions): """ [0,6] Scale factor used to represent 1 mm in the SVG (KiCad 6). The value is how much zeros has the multiplier (1 mm = 10 power `svg_precision` units). Note that for an A4 paper Firefox 91 and Chrome 105 can't handle more than 5 """ + self.invert_use_for_center = False + """ Invert the meaning of the `use_for_center` layer option. + This can be used to just select the edge cuts for centering, in this case enable this option + and disable the `use_for_center` option of the edge cuts layer """ add_drill_marks(self) super().__init__() self._expand_id = 'assembly' @@ -1164,8 +1174,9 @@ class PCB_PrintOptions(VariantOptions): vis_layers = LSET() for p in self.pages: for la in p.layers: - vis_layers.addLayer(la._id) - if self.force_edge_cuts: + if la.use_for_center ^ self.invert_use_for_center: + vis_layers.addLayer(la._id) + if self.force_edge_cuts and (self.forced_edge_cuts_use_for_center ^ self.invert_use_for_center): vis_layers.addLayer(edge_id) GS.board.SetVisibleLayers(vis_layers) # Generate the output, page by page @@ -1176,8 +1187,9 @@ class PCB_PrintOptions(VariantOptions): if self.individual_page_scaling: vis_layers = LSET() for la in p.layers: - vis_layers.addLayer(la._id) - if self.force_edge_cuts: + if la.use_for_center ^ self.invert_use_for_center: + vis_layers.addLayer(la._id) + if self.force_edge_cuts and (self.forced_edge_cuts_use_for_center ^ self.invert_use_for_center): vis_layers.addLayer(edge_id) GS.board.SetVisibleLayers(vis_layers) needs_ki7_scale_workaround = p.scaling != 1.0 and self.check_ki7_scale_issue()