Import graphic as .svg file

Using v6.0.4, my plan was to create a pcb outline in Corel Draw, export that to an .svg file, then import that into KiCAD. But at the last hurdle I get a “No graphic items found in file” message. I was going to attach my file but cant see how to do that. I will post the contents of the file below.

I am able to open my .svg file in Win10 and my simple test rectangle graphic is showing so the error message is meaningless other than ‘something is wrong’. I have also played around with the settings in the corel draw export filter but with no improvement or success.

Unfortunately the docs for this topic have yet to be written. Any help appreciated.

[SOLVED] The issue turned out to be the end of line terminators in the .svg file. My pc is windows based and consequently the corel draw export filter uses CRLF as its end of line character. On the other hand pcbnew only accepts the unix based LF end of line character. I am not sure if this is a notifiable issue that needs to be addressed or not. Meanwhile I am happy to have an easy work around and thanks for all the suggestions and help.

This forum has an automatic anti-spam feature, and very new users can not upload files. According to your profile you have already reaced “basic” level and can now attach multiple pictures or upload a file. This forum can show some bitmap files inline, but it does not do that with .svg files, but you should still be able to upload it. (Or, worst case, zip it first and upload the zipped file.)

You can just drag the file from a filebrowser and drop it in the edit window, or use copy & paste.

Gosh, I dragged the .svg icon below from …/matplotlib/mpl-data/images to this edit window and this forum renders it.

back

I can also PCB Editor / File / Import / Graphics it.

I have some vague recollection of @ChrisGammell instituting this but I could be wrong.

It seems to work now.

There may be a limit in the primitives supported by KiCad. The imported image consists of quite a lot straight line segments, I count about 30 segments in what should be an arc. If I open the .svg in a text editor, there are not nearly enough coordinates in the file for this, so probably KiCad converts it to straight line segments (quite ugly).

Can you generate a DXF image? I think support for DXF image import is a bit better in KiCad.

So I started pushing random buttons in Inkscape and can confirm that the outline itself is made out of a curve (“path” according to peeking at the file with my text editor) But each round corner has just the end points and a single point in the middle as a control point.

KiCad expects lines and arcs (an maybe bezier curves?) If you can convert your image to contain only lines and arcs before you save it with corel draw it may work better.

@paulvdh thanks for the working SVG arrow object, it has helped me dig into his issue. I imported it into CorelDraw and can see the exact makeup of the path that constructs the arrow shape. I have made up a diagram that shows what I found. Hopefully you can see that attached. The arrow is made up as a start point (M), 7 lines (L) and 12 bezier curves (C). Note the most of the corners are in fact constructed as a pair of bezier curves with the exception of the two at the arrow base, which are only singles. I also learned that a single line only requires two elements whereas a bezier curve has six data elements for each curve segment. Also there are no ‘arcs’ involved, only straight lines and bezier curves. The whole path definition is terminated by the Z character.

There is no need whatsovever to reverse-engineer the SVG format. It is an open standard described and tutorialized (is that a word?) on many places on the 'web.

I do think that you want arc’s in your PCB outline. I have no experience with coreldraw, but I guess that exploding the path into separate elements turns it into line and arc segments which can be imported into KiCad.

This seems to be a reasonable tutorial about the SVG format:

But unfortunately the description of the Path primitive is quite short, and it does not even list the sort of curves supported by name.

This one is (very close to) the official specification.
https://www.w3.org/TR/SVG2/Overview.html

[SOLVED] after wading through the suggested tutorial and learning a heap about paths and lines and curves and arcs etc, I still had the same problem. ie some SVG files were importing to pcbnew and others were not. I started swapping blocks from a working file to a non working file until both files appeared identical but still the problem remained. At that point I decided to check the two files, including ‘non displaying characters’ and lo and behold, the one that did not work was a windows file and used CRLF to terminate the lines and the one that worked was a Unix file that used LF to terminate the lines. A quick EOL Conversion to Unix style did the trick and all files import fine now.

Does the SVG standard say anything about line endings?

I’d say that even if the SVG standard prescribes “Unix style” line endings KiCad should be able to read files that have other line ending styles. SVG is a readable ascii text file format after all.

I converted the earlier posted arrow to CRLF line endings, and I can still open it in the PCB Editor.
back

Are you using a Linux box? that might explain why the CRLF endings worked for you. From what I can make out SVG is a variant of the standard XML format so it has to be agnostic to line endings, surely. The other option would be for a check box to be available in the import filter to handle this issue, but that would seem pretty archaic to me and someone would need to put the effort in to implement that, so better I would have thought to make it automatic as part of the update. Also it is not immediately apparent what the eol characters are in any given file because they are generally hidden by default. Unless you actually go looking for them of course.

Another thought is that since SVG is such an integral part of the whole HTML/XML framework it may be that there is a setting somewhere in windows that has an impact on this behaviour. I have thoroughly searched corel draw and convinced myself that there is no setting in there to use to change the eol character. I also believe that if corel draw was installed on a linux box then default export eol would be a LF.

Yes.

And some *&^%$#@! to get over the 20 char limit.

So this is coming down to a OS compatibility issue that we are dealing with here. And since SVG is a type of XML, it has to be compatible without issues of this kind I would think.

And another observation is that the latest back arrow that you posted earlier today, thinking that you had converted it to CRLF, actually arrived in my browser using LF as the eol.

Yes, I also noticed, try this one:

back

Edit:
There is something weird happening here.
I think this website recognizes the pictures are the same except for the line endings, and then it just throws away the new picture and shows the old picture.

Edit again:
I distorted it a bit, in Inkscape, saved it, and replaced the line endings again in a text editor (from Unix to Windows format). Here it is:

back_CRLF_small

That does not work either. After a download I saw the complete picture got reformatted and line endings changed again to **LF only.
Zipping it up should keep it out of the paws of those gnarly web tools:
back_CRLF_small.svg.zip (1.3 KB)

Edit again again.
Yep, that works. (for me) I can still load this version into KiCad, but the curves still get translated into lots of small straight lines, so not very useful for KiCad. Just using separate lines and arcs makes more sense.

I am pretty happy with the outcome. My board outline is a compound shape that is entirely cubic bezier curves with smooth transitions and shows no sign at all of straight lines, no matter how far I zoom into the KiCad pcb editor. The only remaining problem of have is that the image is solid and I only want the outline so that is a work in progress.

Try this (in for example a test project).

  1. import your graphics, put it on Edge.Cuts during import, also set the default linewidth to something appropriate, (default lines on Edge.Cuts are I think 0.2mm)
    image
  2. Right click and Grouping / Ungroup from the popup menu:

    This polyline is probably directly usable as a PCB outline on Edge.cuts. Maybe the ungrouping is not needed. The definitive check would be an DRC that does not complain in combination with a set of Gerbers containing the graphics on the correct layer.
  3. If you now zoom in you can see the individual straight line segments. In the screenshot below I moved one control point.

I guess all of those micro lines exist because your shape is a polygon. I figured out how to set my path to ‘no-fill’ and imported to the edge.cuts layer with a 0.2mm outline. Below is what I have now. As you can see my grid is set to 0.01mm as in your example but there are no straight line segments, just the bezier curve line.

Yes you are correct, the import did create a bunch of line segments: I moved them so I could see them.

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