fix(board-view): frame get_board_2d_view to the board, not the A4 sheet

kicad-cli's `pcb export svg` defaults to `--page-size-mode 0` (the full drawing sheet), so only the area inside the sheet is plotted -- board geometry past the page edge is left out. Pass `--exclude-drawing-sheet` and `--page-size-mode 2` (board area only) so the output is sized to the board's bounding box and the full board is rendered. Both flags exist since KiCad 7, so KiCad 8/9 are unaffected.
This commit is contained in:
Judson Stephenson
2026-06-04 14:51:49 -05:00
parent 8fd5c8c64e
commit 409b18c83d
2 changed files with 21 additions and 0 deletions

View File

@@ -79,6 +79,19 @@ def test_inline_png_returns_base64_image_data(tmp_path):
assert "filePath" not in result
@pytest.mark.unit
def test_export_frames_to_board_area(tmp_path):
"""The export drops the drawing sheet and crops to the board area, so a small
board isn't rendered on a mostly-empty A4 page (kicad-cli's default)."""
cmd, root, board_path = _make_view_cmd(tmp_path)
w1, w2, w3 = _patch_kicad_cli(root)
with w1, w2 as run, w3, patch("commands.board.view._svg_to_png", return_value=_FAKE_PNG):
cmd.get_board_2d_view({"pcbPath": str(board_path), "format": "png"})
argv = run.call_args[0][0]
assert "--exclude-drawing-sheet" in argv
assert argv[argv.index("--page-size-mode") + 1] == "2"
@pytest.mark.unit
def test_inline_svg_returns_base64_image_data(tmp_path):
"""responseMode='inline' with format='svg' returns base64-encoded SVG in imageData."""