Laser Stencil DXF Quality

I’ve been trying to produce a quality mylar laser stencil. KiCAD exports a really good DXF. When I view it inFreeCAD it looks perfect. However, when I look at the same DXF in InkScape or MeerK40t the resolution looks much lower with thick lines.

Any recommendations on a workflow to preserve the KiCAD quality export to a laser?

; MeerK40t

; FreeCAD view of same DXF F.Paste file

This has nothing to do with KiCad export. If that was faulty, then you could not properly view it in FreeCAD either. I guess the DXF open in those other programs normally too, but it’s some sort of line width setting.

@paulvdh -

I totally agree. KiCAD export DXF is working great. I’m wondering thought if I should be exporting in another format or using specific known KiCAD friendly utilities? I’m looking for a KiCAD friendly workflow.

Generally speaking DXF is the worst possible format for any translation. But its relatively straightforward to make, though SVG is easier to make. Both formats suffer from a terminal problem though. Neither format has a entirely stable definition in the size. So in a export import chain both formats can loose the scaling information.

The other problem is that Inkscape uses a different worldview form KiCAD. KiCAD follows the common CAD tradition that the entities consist of individual shapes, and line thickness is sometimes meaningless and the abstract center of the line is where the shape lies. Inkscape uses the worldview that drawing is the only thing that matters so you are assumed to be painting closed shapes. So incskape users would expect squares to be joined to one path while CAD users generally do not mind.

If inkscape is your poison then SVG is probably the better format. Just as long as you don’t open it in Illustrator.

The laser may or may not need the shapes to be closed if you intend to engrave the result, if you just want to cut it probably does not matter. It depends on the engraving software, and what industry to was designed for, if you use inkscape in the loop then probably it needs to be closed.

@joojala,

I despise Inkscape and have been trying to avoid it.

My preference would be to use CLI tools when possible. I love that gerbv can generate an SVG from a KiCAD exported F.paste gerber . Unfortunately, the solid forms are filled instead of outlined. KiCADs DXF output is just right with outline cuts of the solder pads.

If there is a preferred way to export paste layers into etching tools I’m happy to go that route.

I’ll see if I can get the line thickness down in Meerk40t or Inkscape.

I have a working setup now. Thank you both @joojala and @paulvdh for your helpful guidance.

If I import the KiCad generated DXF into MeerK40t I can save that file (default is SVG). Then edit he SVG changing all the values of stroke-width=“0.001” and get a super fine line to work with. I’ll post my final setup and script to generate shortly.

Now that you have a working solution, this is just FYI…

I generated a Spiral in FreeCAD.
It loads correctly in:
• Kicad (loaded into F-Silk)
• Libre-Office(Draw)
• Libre CAD

In Kicad, I loaded it into Margin layer, No problem.

It would Not load into Inkscape.

With a shape (a Spiral, for example) correctly Exported as DXF from FreeCAD, it loads correctly in Inkscape.

‘Correcrtly’, in this instance, means with setings in FreeCAD that work. Not all settings in FreeCAD yield good results. I’ve done many tests to determine what file/geometries work. The parameters for correct loading into Inkscape are Not available in Kicad’s DXF export.

Just out of curiosity. why dont you just export SVG from KiCAD, and just change fills to strokes? I’m pretty sure you can do this with something like sed or awk. Its just a search and replace after all.

I mean if you search:

fill:#C83434; fill-opacity:1.0000; stroke:none;fill-rule:evenodd;

and replace it with:

stroke:#000000; stroke-width:0.04; fill:none;

you get:

search-n-replace

Also i have yet to see a lasering software/driver that can not turn a engrave instruction to a vector cutting. But then ive only used 4 different software for this.

Great suggestions. Thank you.

I’ll try cut out mode from SVG which would simplify things.

Also the search replace with sed is pretty functional. Some artifacts left from a component, but handled 90% of the outlines in one expression.

sed -i 's/fill-rule="evenodd" fill="rgb(45.098039%, 45.098039%, 87.058824%)" fill-opacity="1"/stroke="#000000" stroke-width="0.04" fill="none"/g' file.svg

Nah DXF should be the best. DXF describes everything as primitives with all coordinates in actual units unlike SVG. The size definition is very stable and even internally there may be blocks that get scaled on insertion if you say, exported 2d views from a 3d model in solidworks where they end up basically inserting that 3d model into dxf and putting in the 2d translations. The problem is most parsers are incomplete especially since not every software has the same internal architecture to handle blocks and layers like a CAD tool.

1 Like

The problem is most parsers are incomplete especially since not every software has the same internal architecture to handle blocks and layers like a CAD tool.

So your export is perfect its the readers that are the problem. Yeah. It may be stable from kicads point of view. But having to read DXF files form random sources nearly daily its not a good format overall you can never know what size something is supposed to be. Usually has is right ballpark shape, might need healing. There are so many dialects and you can never know what your pipeline looks like.

DXF is like cad worlds version of CSV, it sort of the least problematic problematic format*.
But at least its relatively easy… oh it isn’t.**

Anyway in this case op wants to do kicad → dxf → svg translation which makes no sense for making fills outlines.

* From exporters point of view
** Yes i have maintained dxf readers and writers as well as IGES and STEP (which is something else). Making a exporter is always more easy than reading stuff somebody else made.