Eeschema export/plot to svg and crop to the size of schematics

Hello! I wonder if it is possible to plot schematics to svg from eeschema and simultaneously crop the size to the schematic. I noticed, there is an option plot size as Schematic size in the plot dialog, but it seems to refer to the size, specified in Page settings (used for KiCad 5.1.10 and 5.99 on Windows 10 and Ubuntu 21.04).

If description is confusing: I mean to export as svg with the size of drawn components only (preferably, with some margins). So if I have this schematic:

I need to have an output like this:
general_case_as_needed

While it renders like this (even if I un-click the checkmark Plot border and the title block):

P.S. My current workaround is plotting a whole page and running a script with Inkscape to crop. Just wondering if there is a better solution.

P.P.S. For some reason, after cropping with Inkscape the svg-file is heavier than the uncropped version after KiCad. How is that possible?

P.P.P.S: The code I use for batch crop:

find . -type f -iname "*.svg" -exec $SHELL -c '
  echo Processing file: "$0"
  inkscape "$0" --export-area-drawing \
                --export-plain-svg \
                --export-type=svg \
                --export-filename="$0" \
                --export-overwrite
' {} \;

I can’t answer your question (but I am interested as I have a similar workflow)

But the reason the file is “heavier” is inkscape adds a load of metadata to the SVG to help itself.

.SVG are text files, just as KiCad’s own file formats, and human readable.
Just recently I had a look at a PCB file exported to .SVG and it had about 200kB of trailing zero’s added to coordinates.

Have you tried deleting the page frame (or using a very sparse one)?

Another alternative is to save an empty schematic and your own both in .svg formats and compare them with a text file comparison program such as Meld Merge. With this you can probably relatively quickly identify the clutter and remove it without adding extra meta data.
(You can also use it to remove the clutter added by Inkscape)
Or use some other program that can work with .svg, there must be a bunch of them these days.

Euhm,
Have you tried just not plotting the border and title block?
image

If you make a block selection in KiCad V5, it immediately activates the “Block Move” function. KiCad-nightly V5.99 is more in line with other programs. You can first make a selection by dragging, then add to that selectrion by holding the Shift key, and then “do something” with the selection. I can see some use for Eeschema / File / Plot to have an option to plot the current selection only. Maybe there already is such a request on gitlab. Or if it’s important to you, you can make such a request yourself.

One of the images above clearly shows that I’m not plotting the page frame.

Looks like (as of now) I can only copy that block to some svg editor (like Inkscape) for further edition, but not much else.

Do you by chance know how to purge that away?

I haven’t test this, but apparently you can do Save as -> Plain SVG in inkscape to remove the metadata.

source:

OK, but it seems to be weird because I use the script (see the first post), where the parameter --export-plain-svg supposed to responsible exactly for that.

The other alternative could be that Kicad doesn’t fully honor the svg spec and inkscape does or inkscape produces a more human readable export
We are talking about 2.3kB here, the liberal use of whitespace and/or newline could easily realise this difference

–edit–
I just looked and yes, tonnes of additional formatting and information added, even with plane SVG

Would things work better if you changed the “page size”?

The minimum size seems to be 101.6 x 101.6 mm (so 4" x 4")

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