CNC programing with Inkscape svg files.

I am hoping some one in here has done some CNC programing and used Inkscape to vectorise their designs.

I am looking at this SVG specification that Inkscape specifies on their website: Paths — SVG 2

And I have the attached Inkscape svg file that I created by vectorising a .jpg file from DipTrace.
I had to rename it to a .cpp in order to attach it.

I am intending to read this file and reproduce the image in a MS Windows app and then upload custom CNC commands to a CNC device of my own design.

Refer to "<path id="path21"" below (not all of it is there because it is too big)

Now right from the start this file does not follow the standard for paths!

m 14.272381,197.21428......these are clearly absolute coordinates. So 'm' should be 'M'

A bit further on we have m 149.775329,0 V 147.72661 It still does not follow the standard - absolute coordinates with 'm'

Then I find this m -41.31733,42.0513. These are clearly relative coordinates with a 'm'.

So how are you supposed to tell if the coordinates are relative or absolute when they are not adhering the the standard they have specified?

Has anyone else figured out how to read an inkscape file and accurately reproduce the image in it?

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   id="svg8"
   version="1.1"
   viewBox="0 0 149.86 99.144661"
   height="99.144661mm"
   width="149.86mm">
  <defs
     id="defs2" />
  <metadata
     id="metadata5">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     transform="translate(-14.272381,-147.64195)"
     id="layer1">
    <path
       id="path21"
       d="m 14.272381,197.21428 v -49.57233 h 74.929998 74.930001 v 49.57233 49.57233 H 89.202379 14.272381 Z m 149.775329,0 V 147.72661 H 89.202379 14.357048 v 49.48767 49.48767 h 74.845331 74.845331 z m -41.31733,42.0513 c -0.34889,-0.0933 -0.73,-0.36062 -0.88261,-0.61896 l -0.14356,-0.24303 -20.50542,0.0305 c -11.277976,0.0168 -20.657811,0.0563 -20.844077,0.0877 -0.416246,0.0703 -0.686248,-0.0572 -0.949959,-0.44848 -0.250765,-0.37211 -0.250765,-0.82804 0,-1.20015 0.261036,-0.38736 0.531682,-0.51551 0.992164,-0.46979 0.307781,0.0306 0.431363,0.0962 0.643973,0.34217 l 0.2631,0.30436 h 20.200409 20.20041 l 0.13831,-0.23414 c 0.0761,-0.12877 0.27825,-0.32879 0.44928,-0.4445 0.30673,-0.20749 0.33526,-0.21036 2.08898,-0.21036 1.71327,0 1.78952,0.007 2.09438,0.19671 0.17402,0.1082 0.38226,0.30822 0.46276,0.4445 0.13498,0.22851 0.18447,0.24779 0.63612,0.24779 0.26936,0 0.48974,-0.0204 0.48974,-0.0453 0,-0.0249 -0.0667,-0.14694 -0.14816,-0.27115 -0.12483,-0.19025 -0.15252,-0.47471 -0.17578,-1.80555 -0.0316,-1.8092 0.0283,-2.14869 0.45437,-2.57477 l 0.29291,-0.29291 v -2.50049 -2.50048 h -0.82004 c -0.71848,0 -0.84366,0.0222 -1.01074,0.17914 -0.23382,0.21966 -0.83827,0.29489 -1.13002,0.14063 -0.31427,-0.16617 -0.5952,-0.6368 -0.5952,-0.99711 0,-0.36031 0.28093,-0.83093 0.5952,-0.9971 0.29175,-0.15426 0.8962,-0.079 1.13002,0.14063 0.16708,0.15695 0.29226,0.17914 1.01074,0.17914 h 0.82004 v -1.86267 -1.86266 h -0.82004 c -0.71848,0 -0.84366,0.0222 -1.01074,0.17914 -0.23382,0.21966 -0.83827,0.29489 -1.13002,0.14063 -0.31427,-0.16617 -0.5952,-0.6368 -0.5952,-0.99711 0,-0.36031 0.28093,-0.83093 0.5952,-0.9971 0.29175,-0.15426 0.8962,-0.079 1.13002,0.14063 0.16708,0.15695 0.29226,0.17914 1.01074,0.17914 h 0.82004 v -0.59267 -0.59266 h -0.82004 c -0.71848,0 -0.84366,0.0222 -1.01074,0.17914 -0.23382,0.21966 -0.83827,0.29489 -1.13002,0.14063 -0.31427,-0.16617 -0.5952,-0.6368 -0.5952,-0.99711 0,-0.36031 0.28093,-0.83093 0.5952,-0.9971 0.29175,-0.15426 0.8962,-0.079 1.13002,0.14063 0.16708,0.15695 0.29226,0.17914 1.01074,0.17914 h 0.82004 v -0.59267 -0.59266 h -0.82004 c -0.71848,0 -0.84366,0.0222 -1.01074,0.17914 -0.23382,0.21966 -0.83827,0.29489 -1.13002,0.14063 -0.31427,-0.16617 -0.5952,-0.6368 -0.5952,-0.99711 0,-0.36031 0.28093,-0.83093 0.5952,-0.9971 0.29175,-0.15426 0.8962,-0.079 1.13002,0.14063 0.16708,0.15695 0.29226,0.17914 1.01074,0.17914 h 0.82004 v -0.59267 -0.59266 h -0.82004 c -0.71848,0 -0.84366,0.0222 -1.01074,0.17914 -0.23382,0.21966 -0.83827,0.29489 -1.13002,0.14063 -0.31427,-0.16617 -0.5952,-0.6368 -0.5952,-0.99711 0,-0.36031 0.28093,-0.83093 0.5952,-0.9971 0.29175,-0.15426 0.8962,-0.079 1.13002,0.14063 0.16697,0.15685 0.29231,0.17914 1.00749,0.17914 h 0.81679 l 0.0244,-2.83408 c 0.0243,-2.82025 0.0253,-2.83503 0.21709,-3.02684 0.18769,-0.18775 0.24328,-0.19341 2.14313,-0.21838 1.75554,-0.0231 1.97741,-0.0421 2.22031,-0.19018 0.70557,-0.43021 1.66438,0.0843 1.66438,0.89315 0,0.35564 -0.16362,0.63989 -0.49809,0.86529 -0.38317,0.25822 -0.82904,0.25145 -1.22703,-0.0186 -0.30236,-0.20519 -0.35582,-0.21167 -1.74747,-0.21167 h -1.43556 v 11.84644 11.84642 l 0.29207,0.18051 c 0.16064,0.0993 0.37971,0.32146 0.48683,0.49374 0.18712,0.30093 0.19477,0.38305 0.19477,2.09123 0,1.71327 -0.007,1.78951 -0.19672,2.09438 -0.10819,0.17402 -0.30822,0.38226 -0.4445,0.46276 -0.2103,0.12423 -0.24778,0.19926 -0.24778,0.49599 0,0.58657 -0.10834,0.62987 -1.57591,0.62987 h -1.26625 l -0.14637,0.24779 c -0.0805,0.13627 -0.28874,0.3363 -0.46276,0.4445 -0.29955,0.18625 -0.40195,0.19747 -1.92504,0.21101 -0.88477,0.008 -1.70392,-0.0112 -1.82034,-0.0423 z m 3.57605,-0.33802 c 0.17402,-0.10819 0.38225,-0.30822 0.46276,-0.4445 l 0.14637,-0.24778 h 1.26625 c 1.46757,0 1.57591,-0.0433 1.57591,-0.62987 0,-0.29673 0.0375,-0.37177 0.24778,-0.496 0.13628,-
       style="fill:#000000;stroke-width:0.08466666" />
  </g>
</svg>

CNCLaserEngraverBottom.cpp (161 KB)

The standard says this:

Start a new sub-path at the given (x,y) coordinate. M (uppercase) indicates that absolute coordinates will follow; m (lowercase) indicates that relative coordinates will follow. If a moveto is followed by multiple pairs of coordinates, the subsequent pairs are treated as implicit lineto commands. Hence, implicit lineto commands will be relative if the moveto is relative, and absolute if the moveto is absolute. If a relative moveto (m) appears as the first element of the path, then it is treated as a pair of absolute coordinates. In this case, subsequent pairs of coordinates are treated as relative even though the initial moveto is interpreted as an absolute moveto.

But it appears that that bit in bold should read "treated as a pair of absolute coordinates, except if the command that closed the previous path was a 'Z'"

If correct then this seems to be a very muddled way of implementing this standard.

Exceptions just end up confusing the hell out of people.

This all sounds like it is outside the scope of the Arduino Forum.

Is the ultimate aim to convert an SVG file to a GCode file for the CNC system?

I have recently started using SVG files to define a web diagram and discovered in the process that the SVG files produced by Inkscape etc have an ENORMOUS amount of superfluous "junk" - presumably in the interest of "standardisation".

Maybe you could write a Python program to eliminate all but the essentials?

...R