4

Here is an SVG file with some path :

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
 "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0"
    ... viewBox="0 0 1920.000000 1080.000000">
    <g transform="translate(0.000000,1080.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
        <path d="M16320 10788 c0 -5 132 -7 293 -6 293 2 259 6 -101 10 -105 2 -192 0
-192 -4z"/>
 <!-- Many other paths -->

I want to extract the paths data within the 1080x1920 reference frame. The translation and scaling have to be considered before extracting path data.
I currently use the Ungroup option in Inkscape before extracting all paths.
How to do it automatically (via command line or programm) ?

Noan Cloarec
  • 2,024
  • 2
  • 13
  • 25
  • 1
    Use the 'deep ungroup' extension to ungroup everything. It must be listed somewhere in the --verb-list . If you know you never have more than, say, 5 nested groups, you can also repeat the Ungroup verb a couple times, alternating with Select all. – Moini Dec 10 '19 at 22:38
  • Can it be done from command line? – Noan Cloarec Dec 12 '19 at 03:15
  • Yes. Extensions can be started via the Inkscape commandline (not without GUI), or they can run on their own, directly from the command line, without requiring Inkscape. Try 'python /path/to/ungroup-deep.py /path/to/yourdrawing.svg > /path/to/target_file.svg' (on a Linux shell, on Windows this may look a bit different.) – Moini Dec 13 '19 at 00:45
  • Unfortunately got: TypeError: can only concatenate str (not "NoneType") to str any hints on this? – Mateusz Gebroski May 21 '20 at 10:36

1 Answers1

3

You can run Inkscape actions from the command line

inkscape --actions "select-all:groups; SelectionUnGroup; export-filename: output.svg; export-plain-svg; export-do;" intput.svg
Igor Mikushkin
  • 1,250
  • 16
  • 25