Skip to content

Commit 37fb07c

Browse files
committed
[PCB Print][Added] Run table dependencies on-the-fly
- Added more info about how drill_pairs are generated - Removed dead code in pre_include_table.py
1 parent 4e47bd5 commit 37fb07c

6 files changed

Lines changed: 21 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2929
user defined CSSs might need some adjusts
3030
- Now when an output runs another outputs as dependencies the name of the
3131
created output is displayed.
32+
- When using `pcb_print` and including tables you no longer need to run the
33+
output that generates the CSV first, it gets generated on-the-fly
3234

3335

3436
## [1.9.0] - 2026-05-12

docs/samples/generic_plot.kibot.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3609,6 +3609,9 @@ outputs:
36093609
# You can also use it to generate pages with drill maps, in this case use `drill_pairs` here.
36103610
# Note that in this case the `repeat_for_layer` should be some drawing layer, which might contain
36113611
# a group used to insert the drill table (like in the `include_table` preflight).
3612+
# Note that the drill table needs an output that generates one or more CSV files and the group in the
3613+
# PCB must be named `kibot_table_OUTPUT_FOR_CSV_DRILLS`. See the `print_drill_table.kibot.yaml` example
3614+
# in the repo.
36123615
# The drill map needs KiCad 7 or newer
36133616
repeat_layers:
36143617
# [string=''] Color used for this layer.

docs/source/Changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ Changed
5555
complex and user defined CSSs might need some adjusts
5656
- Now when an output runs another outputs as dependencies the name of
5757
the created output is displayed.
58+
- When using ``pcb_print`` and including tables you no longer need to
59+
run the output that generates the CSV first, it gets generated
60+
on-the-fly
5861

5962
[1.9.0] - 2026-05-12
6063
--------------------

docs/source/configuration/outputs/PagesOptions.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ PagesOptions parameters
3737
You can also use it to generate pages with drill maps, in this case use `drill_pairs` here. |br|
3838
Note that in this case the `repeat_for_layer` should be some drawing layer, which might contain
3939
a group used to insert the drill table (like in the `include_table` preflight). |br|
40+
Note that the drill table needs an output that generates one or more CSV files and the group in the
41+
PCB must be named `kibot_table_OUTPUT_FOR_CSV_DRILLS`. See the `print_drill_table.kibot.yaml` example
42+
in the repo. |br|
4043
The drill map needs KiCad 7 or newer.
4144
- ``sheet`` :index:`: <pair: output - pcb_print - options - pages; sheet>` [:ref:`string <string>`] (default: ``'Assembly'``) Text to use for the `SHEET` in the title block.
4245
Pattern (%*) and text variables are expanded. |br|

kibot/out_pcb_print.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ def __init__(self):
289289
You can also use it to generate pages with drill maps, in this case use `drill_pairs` here.
290290
Note that in this case the `repeat_for_layer` should be some drawing layer, which might contain
291291
a group used to insert the drill table (like in the `include_table` preflight).
292+
Note that the drill table needs an output that generates one or more CSV files and the group in the
293+
PCB must be named `kibot_table_OUTPUT_FOR_CSV_DRILLS`. See the `print_drill_table.kibot.yaml` example
294+
in the repo.
292295
The drill map needs KiCad 7 or newer """
293296
self.repeat_inherit = True
294297
""" If we will inherit the options of the layer we are replacing.
@@ -1556,7 +1559,7 @@ def generate_output(self, output):
15561559

15571560
# Update all tables
15581561
if GS.ki7 and self._include_table_output:
1559-
update_table(self._include_table, self)
1562+
update_table(self._include_table, self, allow_run=True)
15601563

15611564
# Generate the output, page by page
15621565
pages = []
@@ -1566,7 +1569,7 @@ def generate_output(self, output):
15661569
g_drill_map = PCB_GROUP(GS.board)
15671570
self.add_drill_map_drawing(p, g_drill_map)
15681571
if GS.ki7 and self._include_table_output:
1569-
update_table(self._include_table, self, p._drill_pair_index, True)
1572+
update_table(self._include_table, self, p._drill_pair_index, True, allow_run=True)
15701573
# Make visible only the layers we need
15711574
# This is very important when scaling, otherwise the results are controlled by the .kicad_prl (See #407)
15721575
if self.individual_page_scaling:

kibot/pre_include_table.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
draw_marker, get_marker_best_pen_size,
1616
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT,
1717
GR_TEXT_HJUSTIFY_CENTER)
18-
from .kiplot import load_board, get_output_targets, look_for_output
18+
from .kiplot import load_board, get_output_targets, look_for_output, run_output
1919
from .misc import W_NOMATCHGRP
2020
from .optionable import Optionable
2121
from .registrable import RegOutput
@@ -265,11 +265,9 @@ def measure_table(cols, out, bold_headers, font=None):
265265
c.width = c.max_len/tot_len
266266

267267

268-
def update_table(ops, parent, force_index=-1, only_drill_tables=False):
268+
def update_table(ops, parent, force_index=-1, only_drill_tables=False, allow_run=False):
269269
logger.debug('Starting include table preflight')
270270
load_board()
271-
csv_files = []
272-
csv_name = []
273271
out_to_csv_mapping = {}
274272

275273
logger.debug('- Analyzing requested outputs')
@@ -284,12 +282,9 @@ def update_table(ops, parent, force_index=-1, only_drill_tables=False):
284282
targets, _, o = get_output_targets(out.name, parent)
285283

286284
csv_targets = [file for file in targets if file.endswith('.csv')]
287-
for file in csv_targets:
288-
csv_files.append(file)
289-
for file in csv_targets:
290-
file_name = os.path.basename(file)
291-
name_without_ext = os.path.splitext(file_name)[0]
292-
csv_name.append(name_without_ext)
285+
# Run the output if any of the files is missing and we are allowed to run them
286+
if any(not os.path.isfile(f) for f in csv_targets) and allow_run:
287+
run_output(csv)
293288
out_to_csv_mapping[out.name] = (out, csv_targets, o.type)
294289
logger.debug(f' - {out.name} -> {csv_targets}')
295290

0 commit comments

Comments
 (0)