Added an option to select the kicad_wks for pcb_print

This commit is contained in:
Salvador E. Tropea 2022-04-16 15:20:02 -03:00
parent cffd3d0b89
commit eb1a57a10d
3 changed files with 18 additions and 5 deletions

View File

@ -1586,8 +1586,9 @@ Next time you need this list just use an alias, like this:
- `tent_vias`: [boolean=true] Cover the vias.
- `title`: [string=''] Text used to replace the sheet title. %VALUE expansions are allowed.
If it starts with `+` the text is concatenated.
- `plot_sheet_reference`: [boolean=true] Include the title-block.
- `plot_sheet_reference`: [boolean=true] Include the title-block (worksheet, frame, etc.).
- `png_width`: [number=1280] Width of the PNG in pixels.
- `sheet_reference_layout`: [string=''] Worksheet file (.kicad_wks) to use. Leave empty to use the one specified in the project.
- `title`: [string=''] Text used to replace the sheet title. %VALUE expansions are allowed.
If it starts with `+` the text is concatenated.
- `variant`: [string=''] Board variant to apply.

View File

@ -1044,10 +1044,12 @@ outputs:
# [string=''] Text used to replace the sheet title. %VALUE expansions are allowed.
# If it starts with `+` the text is concatenated
title: ''
# [boolean=true] Include the title-block
# [boolean=true] Include the title-block (worksheet, frame, etc.)
plot_sheet_reference: true
# [number=1280] Width of the PNG in pixels
png_width: 1280
# [string=''] Worksheet file (.kicad_wks) to use. Leave empty to use the one specified in the project
sheet_reference_layout: ''
# [string=''] Text used to replace the sheet title. %VALUE expansions are allowed.
# If it starts with `+` the text is concatenated
title: ''

View File

@ -270,7 +270,9 @@ class PCB_PrintOptions(VariantOptions):
To use the KiCad 6 default colors select `_builtin_default`.
Usually user colors are stored as `user`, but you can give it another name """
self.plot_sheet_reference = True
""" Include the title-block """
""" Include the title-block (worksheet, frame, etc.) """
self.sheet_reference_layout = ''
""" Worksheet file (.kicad_wks) to use. Leave empty to use the one specified in the project """
self.frame_plot_mechanism = 'internal'
""" [gui,internal,plot] Plotting the frame from Python is problematic.
This option selects a workaround strategy.
@ -343,6 +345,11 @@ class PCB_PrintOptions(VariantOptions):
setattr(self, member, getattr(self._color_theme, 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)
if self.sheet_reference_layout:
self.sheet_reference_layout = KiConf.expand_env(self.sheet_reference_layout)
if not os.path.isfile(self.sheet_reference_layout):
raise KiPlotConfigurationError("Missing page layout file: "+self.sheet_reference_layout)
def filter_components(self):
if not self._comps:
@ -653,8 +660,11 @@ class PCB_PrintOptions(VariantOptions):
temp_dir_base = mkdtemp(prefix='tmp-kibot-pcb_print-')
logger.debug('- Temporal dir: {}'.format(temp_dir_base))
self.find_paper_size()
# Find the layout file
layout = KiConf.fix_page_layout(GS.pro_file, dry=True)[1]
if self.sheet_reference_layout:
layout = self.sheet_reference_layout
else:
# Find the layout file
layout = KiConf.fix_page_layout(GS.pro_file, dry=True)[1]
if not layout or not os.path.isfile(layout):
layout = os.path.abspath(os.path.join(os.path.dirname(__file__), 'kicad_layouts', 'default.kicad_wks'))
logger.debug('- Using layout: '+layout)