Skip to content

Commit

Permalink
[PCB Print][Fixed] Problems when using the default worksheet
Browse files Browse the repository at this point in the history
- And the internal frame plotter
- Variables not expanded

Fixes #767
  • Loading branch information
set-soft committed Jan 9, 2025
1 parent c4e302c commit 4180a9a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Via pairs overwritten by PTH files (#758)
- Navigate Results:
- Problems when using `erc: true` or `drc: true` (#742)
- PCB Print:
- Problems when using the default worksheet and the internal frame plotter
(#767)

### Changed
- Default temporal layer for internal use is now "Margin", instead of "User.9"
Expand Down
5 changes: 5 additions & 0 deletions docs/source/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ Fixed

- Problems when using ``erc: true`` or ``drc: true`` (#742)

- PCB Print:

- Problems when using the default worksheet and the internal frame
plotter (#767)

Changed
~~~~~~~

Expand Down
3 changes: 2 additions & 1 deletion kibot/kicad/worksheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,8 @@ def load(file):
elif e_type == 'tbtext':
obj = WksText.parse(e)
if not version:
obj.text = text_from_ki5(obj.text)
# Translate KiCad 5 %X markers, and also change the sexp tree
e[1] = obj.text = text_from_ki5(obj.text)
elements.append(obj)
elif e_type == 'polygon':
elements.append(WksPolygon.parse(e))
Expand Down
36 changes: 15 additions & 21 deletions kibot/out_pcb_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,28 +703,22 @@ def plot_frame_ki8_external(self, dir_name, p, page, pages, color):
self.pcb.write(pcb_name)
# Copy the project
pro_name, _, _ = GS.copy_project(pcb_name)
# Make a local WKS available
if self._sheet_reference_layout:
# Worksheet override
wks = os.path.abspath(self._sheet_reference_layout)
wks = KiConf.fix_page_layout(os.path.join(pcb_dir, GS.pro_fname), force_pcb=wks, force_sch=wks)
else:
# Original worksheet
wks = KiConf.fix_page_layout(os.path.join(pcb_dir, GS.pro_fname))
# Copy the layout, user provided or default, we need to expand vars here
# In particular KiBot internal stuff
wks = KiConf.fix_page_layout(os.path.join(pcb_dir, GS.pro_fname), force_pcb=self.layout, force_sch=self.layout)
wks = wks[1]
if wks:
logger.debugl(1, ' - Worksheet: '+wks)
try:
ws = kicad_worksheet.Worksheet.load(wks)
error = None
except (kicad_worksheet.WksError, SchError) as e:
error = str(e)
if error:
raise KiPlotConfigurationError('Error reading `{}` ({})'.format(wks, error))
# Expand the variables in the copied worksheet
tb_vars = self.fill_kicad_vars(page, pages, p)
ws.expand(tb_vars, remove_images=True)
ws.save(wks)
logger.debugl(1, ' - Worksheet: '+wks)
try:
ws = kicad_worksheet.Worksheet.load(wks)
error = None
except (kicad_worksheet.WksError, SchError) as e:
error = str(e)
if error:
raise KiPlotConfigurationError('Error reading `{}` ({})'.format(wks, error))
# Expand the variables in the copied worksheet
tb_vars = self.fill_kicad_vars(page, pages, p)
ws.expand(tb_vars, remove_images=True)
ws.save(wks)
# Plot the frame using a helper script
# kicad-cli fails: https://gitlab.com/kicad/code/kicad/-/issues/18928
script = os.path.join(GS.get_resource_path('tools'), 'frame_plotter')
Expand Down

0 comments on commit 4180a9a

Please sign in to comment.