From 2c0fe980a706ac3d117b1799a3e4844bacf7d718 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Fri, 10 Jan 2025 12:43:32 -0300 Subject: [PATCH] [PCB Print][Fixed] drill map needs KiCad 7 or newer --- docs/samples/generic_plot.kibot.yaml | 7 ++++--- .../configuration/outputs/PagesOptions.rst | 8 +++++++- kibot/out_pcb_print.py | 16 ++++++++++------ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/docs/samples/generic_plot.kibot.yaml b/docs/samples/generic_plot.kibot.yaml index 1bb0efe5e..88cbe26e7 100644 --- a/docs/samples/generic_plot.kibot.yaml +++ b/docs/samples/generic_plot.kibot.yaml @@ -3062,12 +3062,13 @@ outputs: # [boolean=true] If we will inherit the options of the layer we are replacing. # Disable it if you specify the options in `repeat_layers`, which is unlikely repeat_inherit: true - # [list(dict)|list(string)|string='inners'] [all,selected,copper,technical,user,inners,outers,*] - # List of layers to replace `repeat_for_layer`. + # [list(dict)|list(string)|string='inners'] [all,selected,copper,technical,user,inners,outers,*] List + # of layers to replace `repeat_for_layer`. # This can be used to generate a page for each copper layer, here you put `copper`. # You can also use it to generate pages with drill maps, in this case use `drill_pairs` here. # Note that in this case the `repeat_for_layer` should be some drawing layer, which might contain - # a group used to insert the drill table (like in the `include_table` preflight) + # a group used to insert the drill table (like in the `include_table` preflight). + # The drill map needs KiCad 7 or newer repeat_layers: # [string=''] Color used for this layer. # KiCad 6+: don't forget the alpha channel for layers like the solder mask diff --git a/docs/source/configuration/outputs/PagesOptions.rst b/docs/source/configuration/outputs/PagesOptions.rst index fd8433d8f..1b9b81687 100644 --- a/docs/source/configuration/outputs/PagesOptions.rst +++ b/docs/source/configuration/outputs/PagesOptions.rst @@ -29,7 +29,13 @@ PagesOptions parameters See `repeat_layers`. - ``repeat_inherit`` :index:`: ` [:ref:`boolean `] (default: ``true``) If we will inherit the options of the layer we are replacing. Disable it if you specify the options in `repeat_layers`, which is unlikely. -- ``repeat_layers`` :index:`: ` [:ref:`LayerOptions parameters `] [:ref:`list(dict) ` | :ref:`list(string) ` | :ref:`string `] (default: ``'inners'``) (choices: "all", "selected", "copper", "technical", "user", "inners", "outers") (also accepts any string). +- ``repeat_layers`` :index:`: ` [:ref:`LayerOptions parameters `] [:ref:`list(dict) ` | :ref:`list(string) ` | :ref:`string `] (default: ``'inners'``) (choices: "all", "selected", "copper", "technical", "user", "inners", "outers") (also accepts any string) List + of layers to replace `repeat_for_layer`. |br| + This can be used to generate a page for each copper layer, here you put `copper`. |br| + You can also use it to generate pages with drill maps, in this case use `drill_pairs` here. |br| + Note that in this case the `repeat_for_layer` should be some drawing layer, which might contain + a group used to insert the drill table (like in the `include_table` preflight). |br| + The drill map needs KiCad 7 or newer. - ``sheet`` :index:`: ` [:ref:`string `] (default: ``'Assembly'``) Text to use for the `SHEET` in the title block. Pattern (%*) and text variables are expanded. |br| The %ll is the list of layers included in this page. |br| diff --git a/kibot/out_pcb_print.py b/kibot/out_pcb_print.py index 8fbed0b90..f90ff26b1 100644 --- a/kibot/out_pcb_print.py +++ b/kibot/out_pcb_print.py @@ -269,12 +269,13 @@ def __init__(self): This can be used to generate a page for each copper layer, here you put `F.Cu`. See `repeat_layers` """ self.repeat_layers = LayerOptions - """ [list(dict)|list(string)|string='inners'] [all,selected,copper,technical,user,inners,outers,*] - List of layers to replace `repeat_for_layer`. + """ [list(dict)|list(string)|string='inners'] [all,selected,copper,technical,user,inners,outers,*] List + of layers to replace `repeat_for_layer`. This can be used to generate a page for each copper layer, here you put `copper`. You can also use it to generate pages with drill maps, in this case use `drill_pairs` here. Note that in this case the `repeat_for_layer` should be some drawing layer, which might contain - a group used to insert the drill table (like in the `include_table` preflight)""" + a group used to insert the drill table (like in the `include_table` preflight). + The drill map needs KiCad 7 or newer """ self.repeat_inherit = True """ If we will inherit the options of the layer we are replacing. Disable it if you specify the options in `repeat_layers`, which is unlikely """ @@ -998,6 +999,8 @@ def search_text(self, svg, texts): def add_drill_map_drawing(self, p, g): if p._is_drill: + if not GS.ki7: + raise KiPlotConfigurationError('The `pcb_print` drill map needs KiCad 7 or newer') layer = p._drill_map_layer index = p._drill_pair_index draw_drill_map(g, layer, index, self._drill_unify_pth_and_npth, @@ -1745,9 +1748,10 @@ def get_conf_examples(name, layers): ly['color'] = '#14332440' pages.append(page) # Drill map - page = {'repeat_for_layer': 'User.Drawings', 'repeat_layers': 'drill_pairs', 'layers': - [{'layer': 'User.Drawings', 'color': '#000000'}, {'layer': 'Edge.Cuts', 'color': '#000000'}]} - pages.append(page) + if GS.ki7: + page = {'repeat_for_layer': 'User.Drawings', 'repeat_layers': 'drill_pairs', 'layers': + [{'layer': 'User.Drawings', 'color': '#000000'}, {'layer': 'Edge.Cuts', 'color': '#000000'}]} + pages.append(page) ops = {'format': fmt, 'pages': pages, 'keep_temporal_files': True} if fmt in ['PNG', 'SVG']: ops['add_background'] = True