SetSketchPadLineWidth ... is this usable?

82 views
Skip to first unread message

Salvador E. Tropea

unread,
May 6, 2025, 8:59:18 AMMay 6
to KiCad Developers
Hi All!

I'm trying to make "kicad-cli pcb export PLOTTER" as functional as the
Python API, which IMHO is needed before moving to the inter-process API.

Two years ago I opened
https://gitlab.com/kicad/code/kicad/-/issues/13957 as a suggestion by
@craftyjon

As some functionality remains unimplemented I'm submitting patches to
fix them (PS and HPGL support already merged, scale setting waiting for
approval)

One missing functionality is the equivalent to SetSketchPadLineWidth, I
have working code that implements it, but I'm having some doubts.

Looking at the code I see it was intended to be useful, but from what I
see it never worked.

I tried it from the Python API using KiCad 6, 7, 8 and 9 without success.

The code does:

```

  if( aPlotMode == SKETCH )
        m_plotter->SetCurrentLineWidth( GetSketchPadLineWidth(),
&metadata );

```

https://gitlab.com/kicad/code/kicad/-/blob/master/pcbnew/plot_brditems_plotter.cpp?ref_type=heads#L279-280

This in BRDITEMS_PLOTTER::PlotPad

Then the code plots the pad calling FlashPad* but when you look at its
implementation for the PS/PDF/SVG all these functions does something
like this:

```

   if( aTraceMode == FILLED )
        SetCurrentLineWidth( 0 );
    else
        SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH );

```

https://gitlab.com/kicad/code/kicad/-/blob/master/common/plotters/PS_plotter.cpp?ref_type=heads#L147-150

Which defeats the caller intention. IMHO the else part should be removed.

I removed them and I managed to make it work.

The GUI dialog can't set it directly, but is controlled by:

```

m_plotOpts.SetSketchPadLineWidth(
board->GetDesignSettings().GetLineThickness( F_Fab ) );

```

So I see it was intended to work, but never tested.

My questions are:

1. Should I try to fix it?

2. Should we change the drivers so USE_DEFAULT_LINE_WIDTH uses a default
that can be set from the callers? Currently this default is driver
specific and usually "the smallest possible"

3. What about other sketch modes? I.e. the plot dialog allows to set
Postscript in sketch mode ... but the BRDITEMS_PLOTTER::PlotPad code
currently assumes that SKETCH == SketchPadsOnFabLayers ... What about
Postscript and HPGL? (BTW HPGL is full of bugs, some of them really
complex to address)

Regards, Salvador

Seth Hillbrand

unread,
May 6, 2025, 12:58:11 PMMay 6
to dev...@kicad.org
This setting is pretty deep into the weeds.  If we do decide that we should keep it (and make it work), I don't think that we should be exposing it into the cli as a flag without defining our use case for it.

Looking at the bug reports from where it was implemented (https://gitlab.com/kicad/code/kicad/-/issues/1885 and https://gitlab.com/kicad/code/kicad/-/issues/2274), neither seems to require setting the trace width.  I'd suggest that we remove the non-functional feature barring a well-defined need.

Seth

KiCad Services Corporation Logo
Seth Hillbrand
Lead Developer
+1-530-302-5483
Long Beach, CA
www.kipro-pcb.com    in...@kipro-pcb.com


--
You received this message because you are subscribed to the Google Groups "KiCad Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to devlist+u...@kicad.org.
To view this discussion visit https://groups.google.com/a/kicad.org/d/msgid/devlist/3db8d9c0-428b-4e34-9b0f-5904395b5478%40inti.gob.ar.

Jeff Young

unread,
May 7, 2025, 7:55:14 AMMay 7
to dev...@kicad.org
Only DXF supports the general “sketch all items”.  The GUI does not allow setting the sketch line width.

Only HPGL supports setting the default line width in the GUI.  It does not support “sketch all items”.

All formats now support sketching for pads.  HPGL uses the default line width; Gerber uses 0.1mm; all others use a hairline at 1200dpi (0.0212mm).

I’m not sure we need user control over it, but the discrepancy between Gerber and the others seems quite large.

(Note that the hairline at 1200dpi stems from algorithmic safety: one of PS/PDF/SVG will blow up if you give it 0 line widths, though I can’t remember which.)

Cheers,
Jeff.


Salvador E. Tropea

unread,
May 7, 2025, 8:29:26 AMMay 7
to dev...@kicad.org

Hi Jeff!

On 7/5/25 08:54, Jeff Young wrote:
Only DXF supports the general “sketch all items”.  The GUI does not allow setting the sketch line width.

But Postscript and HPGL has "Plot mode" enabled, and you can select "Sketch".

Which makes me think that DXF should be more consistent and move its option to "Plot mode"


Only HPGL supports setting the default line width in the GUI.


But here the concept is different. This is the physical size of the pen, but you might want to make traces wider than this, which won't be achieved changing this parameter.


 It does not support “sketch all items”.


It allows choosing "Plot mode" == Sketch, which is really important here because when you use a real plotter (I wonder if anybody still uses it) you don't want to fill the polygons (wasting your pen too fast).


All formats now support sketching for pads.  HPGL uses the default line width; Gerber uses 0.1mm; all others use a hairline at 1200dpi (0.0212mm).


But this isn't what the code is trying to do, as I posted before. This is what we get.


I’m not sure we need user control over it, but the discrepancy between Gerber and the others seems quite large.


But KiCad already has a setting for this in File|Board Settings ...|Text & Graphics|Defaults. The "Line Thickness" for "Fab Layers".

This is what the code is trying to use, and failing as I explained.

And this was added for this, as Seth referenced in the "issues"


(Note that the hairline at 1200dpi stems from algorithmic safety: one of PS/PDF/SVG will blow up if you give it 0 line widths, though I can’t remember which.)


BTW I remember that using this width made the printed stuff annoying because this is too fine.


Regards, Salvador


Antonio Diaz

unread,
May 7, 2025, 9:04:28 AMMay 7
to dev...@kicad.org
Hi all, 

Is there any documentation about how to develop KiCAD in FreeBSD userland? Or development must be in Linux or Windows? I am interested in make it possible to develop KiCAD with native tools in FreeBSD

Best, 

Antonio 

Seth Hillbrand

unread,
May 7, 2025, 11:24:16 AMMay 7
to dev...@kicad.org
I suggest starting with the port of KiCad at https://www.freshports.org/cad/kicad

This should get you a working KiCad build.  There are a few FreeBSD-specific patches that are maintained there that you will need to build KiCad.
KiCad Services Corporation Logo
Seth Hillbrand
Lead Developer
+1-530-302-5483
Long Beach, CA
www.kipro-pcb.com    in...@kipro-pcb.com

--
You received this message because you are subscribed to the Google Groups "KiCad Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to devlist+u...@kicad.org.

Jeff Young

unread,
May 7, 2025, 11:56:01 AMMay 7
to dev...@kicad.org
Hmmm… there are fundamental differences in the code between Plot Mode and DXF’s outline mode.  I’m not sure what they amount to (or if they’re only historical).

But I do not think we should be using Board Defaults for any of these things.  Those are only queried when creating new objects; they’re not “hot” properties.

Maybe this is all akin to fiducials, and should just be gotten rid of.  It is pretty hard to imagine someone using a pen-based plotter….

(And it would be great to get rid of Plot Mode, as there’s a lot of code to implement it.  We’d just need to keep the part for “sketch pads on fab layers”, and then decide how (or if) to control the pen width there.)

Jon Evans

unread,
May 7, 2025, 12:00:39 PMMay 7
to dev...@kicad.org
I would be in favor of us focusing on the kinds of outputs the vast majority of users actually need: Interchange formats with other software, not pen plotters.

Jeff Young

unread,
May 7, 2025, 12:27:22 PMMay 7
to dev...@kicad.org
To the extent that you’d be willing to remove an existing feature?  (Which is what I’m suggesting.)

Or just to not bother fixing the current warts?

Jon Evans

unread,
May 7, 2025, 12:50:39 PMMay 7
to dev...@kicad.org
For the sake of argument, I would propose removing pen-plotter specific stuff in V10 and putting no effort into supporting it in CLI and API in V9.

I would be open to hearing about why this is actually important to people, but for the moment it just seems like an extra burden on development for a tiny fraction of users, and I've never heard of HPGL or PS formats actually being used in industry when it comes to PCB design software exports.  Users who *do* have a pen plotter also probably have other software that can convert one of our actually widely-used formats (like DXF) as required.

-Jon

Salvador E. Tropea

unread,
May 7, 2025, 1:07:20 PMMay 7
to dev...@kicad.org

Hi Jon!

PS output is handled by the same code as PDF and SVG (is the base class), Is this correct?

Also: A lot of laser printers has native PS support and still working, transferring toner to a PCB using heat is a popular DIY mechanism, and avoiding PDF -> PS manipulation to send the PS directly to the printer is better.

About HPGL (real pen) the driver is hardly broken, the code assumes you can draw a pad and then draw its hole as a white object, which is conceptually wrong when applied to the HPGL driver ... well ... unless you add pen control and include a liquid paper pen in your plotter :-)))

Regards, Salvador

Salvador E. Tropea

unread,
May 15, 2025, 10:25:00 AMMay 15
to dev...@kicad.org

Hi!

Looking at the current code I see:

1. HPGL is gone

2. Full sketch is gone (only sketch pads)

My remaining doubt: What about SetSketchPadLineWidth? Will be added to this dialog to avoid using a global (and hidden) option?

Also: the command line can "sketch" DNP components ... should this also use SetSketchPadLineWidth? Which is the GUI counterpart for this option?

Regards, Salvador

Jeff Young

unread,
May 15, 2025, 6:43:10 PMMay 15
to dev...@kicad.org
In the GUI sketch DNP components is tied to “Cross-out” under “Indicate DNP on fabrication layers”.  There’s no independent control.

And yes, it uses SketchPadLineWidth.

I’d be inclined to expose SetSketchPadLineWidth somewhere, but I don’t feel strongly.

Cheers,
Jeff.

Salvador E. Tropea

unread,
May 16, 2025, 5:50:51 AMMay 16
to dev...@kicad.org

Ok, so then it will be ok to control it from the CLI, no?

It should be clear this is just the sketch width, not just for pads, right?

Reply all
Reply to author
Forward
0 new messages