[Python] SetScale fails to compute the bbox for some layers
Description
When using the Python API and PCB_PLOT_PARAMS.SetScale the result is ok for things like F.Cu, F.SilkS, Edge.Cuts, etc. You get the layer scaled and centered.
But when using F.Paste, F.Adhes, F.Fab, Dwgs.User, etc. You get the layer scaled, but not centered, so you usually get nothing. If you plot to SVG and open it with inkscape you can see the elements are there, just not centered, and hence outside the "paper".
Here is a code example:
import pcbnew
layer = 'F.Fab'
board = pcbnew.LoadBoard('simple_2layer.kicad_pcb')
pc = pcbnew.PLOT_CONTROLLER(board)
po = pc.GetPlotOptions()
visible = pcbnew.LSET()
visible.addLayer(board.GetLayerID(layer))
board.SetVisibleLayers(visible)
po.SetScale(2)
pc.SetLayer(board.GetLayerID(layer))
assert pc.OpenPlotfile('t', pcbnew.PLOT_FORMAT_SVG, 'test')
pc.PlotLayer()
pc.ClosePlot()
Steps to reproduce
- Run the test.py example from here: Scaled_not_centered.zip
- Open simple_2layer-t.svg you get simple_2layer-t.svg
- All the legends are outside the page
KiCad Version
Application: KiCad PCB Editor x86_64 on x86_64
Version: 7.0.9-7.0.9~ubuntu23.04.1, release build
Libraries:
wxWidgets 3.2.2
FreeType 2.12.1
HarfBuzz 6.0.0
FontConfig 2.14.1
Platform: Debian GNU/Linux 12 (bookworm), 64 bit, Little endian, wxGTK, gnome-xorg, x11
wxWidgets: 3.2.2 (wchar_t,wx containers) GTK+ 3.24
Boost: 1.74.0
OCC: 7.6.3
Curl: 7.88.1
ngspice: 38
Compiler: GCC 12.3.0 with C++ ABI 1017
Build settings:
KICAD_SPICE=ON