ScreamX
ScreamX

Reputation: 339

Convert XML to SVG

Good afternoon. There is an XML file of this kind:

<?xml version="1.0" encoding="utf-8"?>
<cut-list units="hundredths_mm" source="Creekside" job="Xiaomi Mi 5 Case back" width="6431" height="13906" device="Graphtec Cutter" media="" defaultsetting="Graphtec Cutter" rotation="0" alignment="NONE" filename="Xiaomi Mi 5 Case back.xml" badname2="core" settingssaved="false">
    <cut-path layer="NewLayer" visible="true">
        <point x="6417" y="13275"/>
        <point x="6417" y="642"/>
        <spline x0="6417" y0="642" x1="6417" y1="278" x2="6148" y2="14" x3="5810" y3="14"/>
        <spline x0="5810" y0="14" x1="5810" y1="14" x2="2201" y2="14" x3="2116" y3="14"/>
        <spline x0="2116" y0="14" x1="1926" y1="14" x2="1940" y2="490" x3="1940" y3="490"/>
        <spline x0="1940" y0="490" x1="1940" y1="687" x2="1940" y2="818" x3="1753" y3="818"/>
        <spline x0="1753" y0="818" x1="1612" y1="818" x2="1545" y2="747" x3="1545" y3="631"/>
        <spline x0="1545" y0="631" x1="1545" y1="631" x2="1552" y2="507" x3="1456" y3="507"/>
        <spline x0="1456" y0="507" x1="1322" y1="507" x2="1326" y2="680" x3="1231" y3="772"/>
        <spline x0="1231" y0="772" x1="1135" y1="864" x2="1051" y2="931" x3="871" y3="931"/>
        <spline x0="871" y0="931" x1="613" y1="931" x2="405" y2="776" x3="405" y3="370"/>
        <spline x0="405" y0="370" x1="405" y1="324" x2="479" y2="38" x3="338" y3="105"/>
        <spline x0="338" y0="105" x1="144" y1="246" x2="14" y2="405" x3="14" y3="666"/>
        <point x="14" y="13275"/>
        <spline x0="14" y0="13275" x1="14" y1="13613" x2="289" y2="13892" x3="627" y3="13892"/>
        <point x="5810" y="13892"/>
        <spline x0="5810" y0="13892" x1="6148" y1="13892" x2="6417" y2="13634" x3="6417" y3="13275"/>
        <point x="6417" y="13275"/>
    </cut-path>
</cut-list>

It is used for the Cut-Server program. Is it possible to convert it to SVG format? In principle, you can rename cut-path to path, etc., but what about the coordinates? I will be very grateful for the help.

P.S. Online converters do not accept this format.

Dimension numbers are in the format: 6431/1000 = 6.431 cm

Upvotes: 0

Views: 1168

Answers (1)

Owain Evans
Owain Evans

Reputation: 384

It is possible to convert to svg. It's unclear what exactly the commands are (especially without an image to see what it looks like i.e. working blind). Also the origin of the coordinate system maybe different to standard svg. I guess "point" is "moveto" in svg, "spline" is "curveto". You ignore the first x0 and y0 as they are stated as the last coordinates of the previous spline.

   <svg xmlns="http://www.w3.org/2000/svg" width="6431" height="13906">
<path d="M6417 13275 M6417 642
    C6417,278 6148,14 5810, 14
    C5810,14 2201,14 2116, 14
    C1926,14 1940,490 1940, 490
    C1940,687 1940,818 1753, 818
    C1612,818 1545,747 1545, 631
    C1545,631 1552,507 1456, 507
    C1322,507 1326,680 1231, 772
    C1135,864 1051,931 871, 931
    C613,931 405,776 405, 370
    C405,324 479,38 338, 105
    C144,246 14,405 14, 666
    L14, 13275
    C14, 13613, 289, 13892, 627, 13892
    L5810, 13892
    C6148, 13892, 6417, 13634, 6417, 13275
    L6417, 13275z
    "
    stroke="black" stroke-width="5" fill="none"/>
</svg>

I've added stroke="black" stroke-width="5" fill="none" as I think you want a line rather than a filled shape. Also you likely want scaling: the svg is too big to be seen on screen (required horizontal scrolling).

It's an advanced find and replace text exercise. If you have thousands of these, a script in SED https://en.wikipedia.org/wiki/Sed would be worth doing, but that's of course compatibility, use of SED, learning, time, etc..

Upvotes: 1

Related Questions