[PCB Print][Fixed] Interference with PRL and scaling
- The visible layers affected the position of the scaled image. This list is defined in the .kicad_prl file and the Python API loads it. Fixes #407
This commit is contained in:
parent
71ff354b9b
commit
ac81d18ea3
|
|
@ -22,6 +22,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Avoid interruptions when too many redirections is detected (#408)
|
- Avoid interruptions when too many redirections is detected (#408)
|
||||||
- PcbDraw:
|
- PcbDraw:
|
||||||
- KiCad 7.0.1 polygons used as board edge. (yaqwsx/PcbDraw#142)
|
- KiCad 7.0.1 polygons used as board edge. (yaqwsx/PcbDraw#142)
|
||||||
|
- PCB Print:
|
||||||
|
- Interference between the visible layers in the PRL file and the results
|
||||||
|
when scaling. (#407)
|
||||||
|
|
||||||
|
|
||||||
## [1.6.1] - 2023-03-16
|
## [1.6.1] - 2023-03-16
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ import re
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import importlib
|
import importlib
|
||||||
from pcbnew import B_Cu, F_Cu, FromMM, IsCopperLayer, PLOT_CONTROLLER, PLOT_FORMAT_SVG, F_Mask, B_Mask
|
from pcbnew import B_Cu, F_Cu, FromMM, IsCopperLayer, PLOT_CONTROLLER, PLOT_FORMAT_SVG, F_Mask, B_Mask, LSET
|
||||||
import shlex
|
import shlex
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
from tempfile import NamedTemporaryFile, mkdtemp
|
from tempfile import NamedTemporaryFile, mkdtemp
|
||||||
|
|
@ -1051,6 +1051,8 @@ class PCB_PrintOptions(VariantOptions):
|
||||||
layout = os.path.abspath(os.path.join(GS.get_resource_path('kicad_layouts'), 'default.kicad_wks'))
|
layout = os.path.abspath(os.path.join(GS.get_resource_path('kicad_layouts'), 'default.kicad_wks'))
|
||||||
logger.debug('- Using layout: '+layout)
|
logger.debug('- Using layout: '+layout)
|
||||||
self.layout = layout
|
self.layout = layout
|
||||||
|
# Memorize the list of visible layers
|
||||||
|
old_visible = GS.board.GetVisibleLayers()
|
||||||
# Plot options
|
# Plot options
|
||||||
pc = PLOT_CONTROLLER(GS.board)
|
pc = PLOT_CONTROLLER(GS.board)
|
||||||
po = pc.GetPlotOptions()
|
po = pc.GetPlotOptions()
|
||||||
|
|
@ -1074,6 +1076,12 @@ class PCB_PrintOptions(VariantOptions):
|
||||||
# Generate the output, page by page
|
# Generate the output, page by page
|
||||||
pages = []
|
pages = []
|
||||||
for n, p in enumerate(self.pages):
|
for n, p in enumerate(self.pages):
|
||||||
|
# Make visible only the layers we need
|
||||||
|
# This is very important when scaling, otherwise the results are controlled by the .kicad_prl (See #407)
|
||||||
|
vis_layers = LSET()
|
||||||
|
for la in p.layers:
|
||||||
|
vis_layers.addLayer(la._id)
|
||||||
|
GS.board.SetVisibleLayers(vis_layers)
|
||||||
# Use a dir for each page, avoid overwriting files, just for debug purposes
|
# Use a dir for each page, avoid overwriting files, just for debug purposes
|
||||||
page_str = "%02d" % (n+1)
|
page_str = "%02d" % (n+1)
|
||||||
temp_dir = os.path.join(temp_dir_base, page_str)
|
temp_dir = os.path.join(temp_dir_base, page_str)
|
||||||
|
|
@ -1160,6 +1168,8 @@ class PCB_PrintOptions(VariantOptions):
|
||||||
# Remove the temporal files
|
# Remove the temporal files
|
||||||
if not self.keep_temporal_files:
|
if not self.keep_temporal_files:
|
||||||
rmtree(temp_dir_base)
|
rmtree(temp_dir_base)
|
||||||
|
# Restore the list of visible layers
|
||||||
|
GS.board.SetVisibleLayers(old_visible)
|
||||||
logger.debug('Finished generating `{}`'.format(output))
|
logger.debug('Finished generating `{}`'.format(output))
|
||||||
|
|
||||||
def run(self, output):
|
def run(self, output):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue