From 10feb4c0a475ee2c797f2c74264f127832e0a260 Mon Sep 17 00:00:00 2001 From: Martin Scharrer Date: Mon, 27 Oct 2025 16:45:09 +0100 Subject: [PATCH] Add line width argument for SVG preview and export. --- boxes/__init__.py | 8 +++++++- documentation/src/usermanual.rst | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/boxes/__init__.py b/boxes/__init__.py index 06a6bd053..3555a4ef8 100755 --- a/boxes/__init__.py +++ b/boxes/__init__.py @@ -408,6 +408,9 @@ def __init__(self) -> None: defaultgroup.add_argument( "--output", action="store", type=str, default="box.svg", help="name of resulting file") + defaultgroup.add_argument( + "--line_width", action="store", type=(lambda x: float('NaN') if x == "" else float(x)), default="", + help='line width for SVG preview and export (in mm) (default: 2x burn but at least 0.05) [\U0001F6C8](https://florianfesti.github.io/boxes/html/usermanual.html#line-width)') def spacing_type(x): try: return (float(x), 0.) @@ -464,7 +467,10 @@ def open(self): self.ctx.set_line_width(0.01) self.set_source_color(Color.BLUE) else: - self.ctx.set_line_width(max(2 * self.burn, 0.05)) + line_width = self.line_width + if line_width != line_width: # check for NaN (default) + line_width = max(2 * self.burn, 0.05) + self.ctx.set_line_width(line_width) self.set_source_color(Color.BLACK) self.spacing = 2 * self.burn + self.spacing[0] * self.thickness + self.spacing[1] diff --git a/documentation/src/usermanual.rst b/documentation/src/usermanual.rst index 72d20c62c..42234e340 100644 --- a/documentation/src/usermanual.rst +++ b/documentation/src/usermanual.rst @@ -87,6 +87,14 @@ much smaller it is than its nominal size. The burn value should be around half of the difference. To test the fit for several values at once you can use the **BurnTest** generator in the "Parts and Samples" section. +line_width +.......... + +The line width parameter defines how wide the lines in the SVG preview +and download files are drawn. By default it is twice the burn value but +at least 0.05mm. This paramteter allows to overwrite if required by some +laser engraving software. + spacing .......