Exporting from PCBNew for CNC job (specific CNC software))

Hi all.
I’m trying to realize a double side PCB, complete with some labels.
I’m getting some problem in different steps of the process.

  1. Initially, I wrote the labels I need (i.e. +5V, or LED+, or similar, to address me when soldering the components) directly on the PCB layer (front / back). Nevertheless, this way, the machining process will take a lot of time more than only routes.
  2. I’d like to have more control when machining the PCB outline / structural holes and so

Thus, I decided to use FlatCAM only to realize the isolation routes / holes / double side mills processing, and use a CNC dedicated software (thinking about Aspire) to realize the labels and the outlines/structural holes.
To get this, I exported from PCBNew the layers Front, Back and custom (where I imported the outline DXF to help me in positioning the components), choosing SVG as format.

The thing seems working, but when I import the SVGs in the CNC software, the draws are very little (i.e this PCB is 4060 mm, the SVGs are 46 mm), altought in kicad export dialog windows the scale is 1:1

This get me very frustrated, as it becomes really hard to create and place the label / holes and to set the milling parameters.

What have I to do to export the SVGs from PCBNew keeping the right dimensions?

Thanks

Andrea

For some weird reason KiCad prefers to use that other (non-metric) number format for some output formats, such as .DXF, but for .SVG the format is not even selectable, and I assume it uses mm.

What is your basis for assuming KiCad would be wrong?

.SVG is a vector format.
As an experiment I just generated some .SVG files with: Pcbnew / File / Plot / Plot Format: SVG and looked at them both in Inkscape and in a text editor.

In the text editor I see some metric measurements in the header (Close to A4 paper format):

width=“29.700220cm” height=“21.000720cm” viewBox=“0 0 116930 82680”>

However for the rest of the coordinates I see a lot of numbers with an X coordinate around 60000 and an Y coordinate around 40000

<path style=“fill:#000000; fill-opacity:1.0;
stroke:#000000; stroke-width:0; stroke-opacity:1;
stroke-linecap:round; stroke-linejoin:round;fill-rule:evenodd;”
d="M 62773.2,44264.6
62782.5,44266.1
62791.6,44268.5
62800.4,44271.7
62808.9,44275.9
62816.9,44280.8
62824.4,44286.5
63099.6,44517.4

This suggests that it uses units of 0.0001" or 0.1mil. Quite weird but my knowledge of .SVG is quite limited. I think units can be chosen arbitrarily and then scaled afterwards.

SVG defines “User Units” This is in the “viewBox” coordinates you posted. So here the user units correspond to 116930 = 29.70022cm

If your CNC software doesn’t support SVG units, then please ask them to fix this.

In KiCad v6, we have added the option to change the user units. This has no material effect on the file or scaling.

According to Python:

297.0022/25.4
11.693000000000001

And that’s suspicously close to that over-seas measuring scale.

And Indeed. In KiCad-nightly V5.99 I see a Plot format: SVG / SVG Options / Units: Millimeter" as default:

And, then again, opening a generated .svg in a text editor:

width=“29.700220cm” height=“21.000720cm” viewBox=“0 0 297002200 210007200”>

And this results in “user units” neatly mapping to nanometer resolution, and that should be plenty for any practical purpose.

All coordinates also add another 6 digits of precision to the coordinates. I would not call it a bug, but specifying a schematic in femtometers seems a bit overkill and needlessly makes files bigger:

d="M 133949112.000000,116626664.000000
133862510.000000,116676664.000000
133264545.000000,116790959.000000
133749112.000000,116280254.000000
133064545.000000,116444549.000000
133549112.000000,115933844.000000
132864545.000000,116098139.000000

My text editor finds the “.000000” string 31k times, which is 217kBytes of the 737kByte (34%) of the total file size, and if rounded or truncated to micrometer, the filesize would shrink by another 100kByte.

Going back to the plot dialog screen…
It seems logical that the “user units” should have been specified in real millimeters, what would have resulted in nanometers with the 6 digit precision? Still overkil, but better to have too many digits then not enough.

The first thing I can notice is a different plot setting window

It misses the SVG Option box…
I’m using Kicad 5.1.6, maybe this could be the issue…
I’m going to download the 5.1.10 and see what happens…

About the CNC software, I use to work often with SVG files, switching between different softwares (the most of time I’m more comfortable in using a software for some parts of the work, then switch to another to complete it, then switch again and so on) , and I never had any issues with SVG format…

UPDATE: after downloading and installing the 5.1.10 nothing changed, no SVG Option box…

Both Paul and Seth are talking about the testing version of KiCAD (v5.99) that is going to be released as v6 in the not so distant future. v5.10 is the stable, tested and current version of KiCAD.

Well, I presume the “SVG Option” box is referred to that release, so.
BTW, I did some…test.

The draw I’m referring to is 115x70 mm

I exported from PCBNew to SVG.
Here’s the PCBNew SVG’s header:

I imported the SVG in CNC software. The draw dimensions are now 3.246x1.975 mm…

I imported the same SVG into CDX7. The draw dimensions are correct: 115x70 mm
I exported from CDX7 to SVG. Here’s the CDX7 SVG’s header:

I imported the CDX7 SVG into CNC software. The draw dimensions are correct: 115x70 mm…

It seems I’d have to perform the full workaround the get the thing working, but this thing really puzzled me…

Trying to interpret both the headers, my puzzling goes worse…
Both headers show the same widht and height (in cm and mm, but it does’n matter, I presume…)
PCBNew header shows “viewbox” values very close to the draw, but CDX7 “viewbox” values are higher…
Nevertheless, the CDX7 SVG is shown correctly in CNC software, but PCBNew…
Here the CNC software window:


Green: the correct draw (from CDX7 SVG)
Red: the draw from PCBNew SVG (yep, that little little red spot…)

Why is it so puzzling?
As soon as I read “ViewBox” and re-read the line I posted I realized what most likely is the way it works.
The “width” and “Height” are real life values, here given in centimeter, and the “viewbox” is the same size, but mapped to some arbitrary units, and all other coordinates are in “viewbox” coordinates.

.SVG is a fully open standard so you can look it up, but I guess it will be quite a thick book. (But you only need a small part of it)

The fact that the measurements are right after you convert it with CDX7 into your CNC software confirms a few things.

  1. KiCad outputs correct measurements, or else no software would be able to correct it.
  2. Your CNC software is faulty because it can not read KiCad’s SVG output.

I believe your CNC software is flatcam?
I suggest you contact them and make them aware of this bug. I hope there is a friendly and responsive community around flatcam.

I’m using FlatCAM just for front, back and holes
Anyway, FlatCAM works fine when importing SVG, whatever software made it.
The CNC software I’m referring to is Aspire
For the sake of honesty, Aspire doesn’t import in the best way many kind of files (like DXF or similar), giving some…“custom” interpretation of them (i.e. DXF or even SVG curves are not imported as “curve” rather like “sequence of micro segments”, so I suppose SVG from PCBNew could suffer such similar…aparteid, plus a “size reduction”.
I think is a good machining software, maybe the “WYSIWYG” type…and very surely it doesn’t like the “team work” with other software…

BTW, thanks again for all the explanations.
Need to test some other methods.

Aspire definitely imports SVG files created by KiCAD as miniatures :smile:
Board:


Aspire:
AspireImportedSVG
Encircled dimensions are in millimeters!

I prefer using DXF when exporting.

Thanks, Brother, this proves myself that my neuron is still making its job :joy:

Well, I don’t make PCB’s on CNC, Just drill them on CNC (vias at the corners are for aligning).
I prefer graphical film and positive spray or pre-sensitized boards.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.