Author Topic: Conversion SVG <-> Sketch XML  (Read 5332 times)

Dannae

  • Hydlaa Citizen
  • *
  • Posts: 250
    • View Profile
Re: Conversion SVG <-> Sketch XML
« Reply #15 on: August 17, 2009, 04:45:29 pm »
Thanks Derula,

I gave it a try with your suggestion, but unfortunately still didn't get a conversion.

Here are the rresults:

Macintosh:sketchxmlapi Hobbes$ ruby svg2sketchxml.rb -v 1.svg 1.xml
./planeshift_sketch_xml.rb:143: warning: parenthesize argument(s) for future version
SVG2SketchXML 0.3
Simple SVG path to PlaneShift Sketch XML converter
Copyright (c) 2009 by Simon Paridon

Converting 1.svg...
  Opening SVG...
  Converting SVG...
  Processing group 'Layer_1'...
    Converting paths...
    Converting path 'M74.1,180C206.8,98.7,72.5-71.1,183.3,33.7c0,0,67.5-77.1,112,30.7
   c44.5,107.8-189.2,91.6-165.1,162c24.1,70.4,36.1,252.4-41,132.5C12.1,239-21.2,198.5,111.2,117.2' with color '0'...
    Reading set of points from SVG...
    Got Vector[74.1, 180.0, 1]. Deciding what to do with them...
    Starting new subpath.
    Reading set of points from SVG...
    Got Vector[206.8, 98.7, 1]Vector[72.5, 183.3, 1]Vector[33.7, 0.0, 1]. Deciding what to do with them...
    Applying transformation matrix to points...
    Adding cubic curve from Vector[74.1, 180.0, 1] to Vector[33.7, 0.0, 1].
    Reading set of points from SVG...
    Got Vector[0.0, 0.0, 1]Vector[67.5, 112.0, 1]Vector[30.7, 0.0, 1]. Deciding what to do with them...
    Applying transformation matrix to points...
    Adding cubic curve from Vector[33.7, 0.0, 1] to Vector[64.4, 0.0, 1].
    Reading set of points from SVG...
    Got Vector[44.5, 107.8, 1]Vector[91.6, 162.0, 1]. Deciding what to do with them...
    Applying transformation matrix to points...
    Adding cubic curve from Vector[64.4, 0.0, 1] to .
svg2sketchxml.rb:480:in `parse_path': undefined method `x' for nil:NilClass (NoMethodError)
   from svg2sketchxml.rb:289:in `parse_group'
   from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/element.rb:891:in `each'
   from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/xpath.rb:53:in `each'
   from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/element.rb:891:in `each'
   from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/element.rb:393:in `each_element'
   from svg2sketchxml.rb:288:in `parse_group'
   from svg2sketchxml.rb:103:in `convert'
   from svg2sketchxml.rb:77:in `convert'
   from svg2sketchxml.rb:530
   from svg2sketchxml.rb:9:in `each_pair'
   from svg2sketchxml.rb:8:in `upto'
   from svg2sketchxml.rb:8:in `each_pair'
   from svg2sketchxml.rb:525

I'll try the application you suggested next.

Dannae

  • Hydlaa Citizen
  • *
  • Posts: 250
    • View Profile
Re: Conversion SVG <-> Sketch XML
« Reply #16 on: August 17, 2009, 04:59:15 pm »
oops! javascript:void(0);

Sorry, I didn't see there was a page 2 until after posting and that you solved the problem.

Thanks so much Derula! Yay!!!

derula

  • Hydlaa Citizen
  • *
  • Posts: 405
  • My main: Jamona Shikon
    • View Profile
    • Ugly Horst Tld.
Re: Conversion SVG <-> Sketch XML
« Reply #17 on: August 17, 2009, 06:02:53 pm »
Thanks so much Derula! Yay!!!

You're welcome. Don't forget to show me the results :D

Edit: Fixed another bug where symmetric curves in the XML failed to convert.
« Last Edit: August 19, 2009, 12:41:24 pm by derula »

raffe

  • Traveller
  • *
  • Posts: 28
    • View Profile
Re: Conversion SVG <-> Sketch XML
« Reply #18 on: February 05, 2010, 09:36:41 am »
Hi!

I run XP.
I went to http://www.ruby-lang.org/en/downloads and installed Ruby.
I went to http://inkscape.org/download/?lang=en and installed Inkscape
I made one line, three lines (a triangle) and a rectangle (with rectangle tool) in Inkscape.
In Inkscape I saved test4.svg
With Ruby I did
Code: [Select]
C:\Ruby\sketchxmlapi>ruby svg2sketchxml.rb test4.svg test4.xml
./planeshift_sketch_xml.rb:143: warning: parenthesize argument(s) for future ver
sion
SVG2SketchXML 0.3b
Simple SVG path to PlaneShift Sketch XML converter
Copyright (c) 2009 by Simon Paridon

Converting test4.svg...
Saving test4.xml...
Finished!

I loaded test4.xml to Planeshift map. But I only see the rectangle, not the triangle or the line. If I write only lines, I dont see them. My XML:
Code: [Select]
- <pages>
- <page l="24" w="744" h="1052" t="50">
  <ln col="0" pts="326 98 326 98" />
  <ln col="0" pts="103 87 254 87" />
  <ln col="0" pts="103 87 103 195" />
  <ln col="0" pts="254 87 254 195" />
  <ln col="0" pts="103 195 254 195" />
  </page>
  </pages>
Any ideas?
« Last Edit: February 05, 2010, 09:42:50 am by raffe »

derula

  • Hydlaa Citizen
  • *
  • Posts: 405
  • My main: Jamona Shikon
    • View Profile
    • Ugly Horst Tld.
Re: Conversion SVG <-> Sketch XML
« Reply #19 on: February 05, 2010, 06:55:26 pm »
Hi!

Hi! :)

I loaded test4.xml to Planeshift map. But I only see the rectangle, not the triangle or the line. If I write only lines, I dont see them. My XML:
Code: [Select]
- <pages>
- <page l="24" w="744" h="1052" t="50">
  <ln col="0" pts="326 98 326 98" />
  <ln col="0" pts="103 87 254 87" />
  <ln col="0" pts="103 87 103 195" />
  <ln col="0" pts="254 87 254 195" />
  <ln col="0" pts="103 195 254 195" />
  </page>
  </pages>
Any ideas?

Huh, that's strange. The three latter lines in the XML are the rectangle. The first one:
Code: [Select]
  <ln col="0" pts="326 98 326 98" /> is simple a line from one point (x=326, y=98) to the same, i.e. a dot.

It's probably a bug. Could you please send me the SVG somehow (e.g. by opening it in a text editor and copy-pasting it to Pastebin)? I'll have a look at it then.

(Note that the Stars/Polygons tool isn't supported yet, though I might be able to add it, but it's not really necessary for triangles... drawing one with the bezier tool should work though. If it's not bugged, which it just might be :P)

raffe

  • Traveller
  • *
  • Posts: 28
    • View Profile
Re: Conversion SVG <-> Sketch XML
« Reply #20 on: February 06, 2010, 09:33:15 am »
For this XML
Code: [Select]
<pages>
<page l='24' w='500' h='600' t='50'>
<ln col='0' pts='-71 -106 -71 -106'/>
<ln col='0' pts='43 137 191 137'/>
<ln col='0' pts='43 137 43 274'/>
<ln col='0' pts='191 137 191 274'/>
<ln col='0' pts='43 274 191 274'/>
</page>
</pages>

I used this SVG (in Pastebin):
http://pastebin.org/87039
And here SVG is in code tags:
Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<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"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="500"
   height="600"
   id="svg2"
   version="1.1"
   inkscape:version="0.47 r22583"
   sodipodi:docname="New document 1">
  <defs
     id="defs4">
    <inkscape:perspective
       sodipodi:type="inkscape:persp3d"
       inkscape:vp_x="0 : 526.18109 : 1"
       inkscape:vp_y="0 : 1000 : 0"
       inkscape:vp_z="744.09448 : 526.18109 : 1"
       inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
       id="perspective10" />
  </defs>
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="0.35"
     inkscape:cx="375"
     inkscape:cy="520"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="false"
     inkscape:window-width="798"
     inkscape:window-height="802"
     inkscape:window-x="22"
     inkscape:window-y="29"
     inkscape:window-maximized="0" />
  <metadata
     id="metadata7">
    <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
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(0,-452.36218)">
    <rect
       style="fill:#0000ff;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
       id="rect2816"
       width="148.57143"
       height="137.14285"
       x="42.857143"
       y="137.14285"
       transform="translate(0,452.36218)" />
    <path
       style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
       d="m 217.14286,128.57143 2.85714,140 68.57143,-34.28572 -71.42857,-105.71428 z"
       id="path2818"
       transform="translate(0,452.36218)" />
    <path
       style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
       d="M 345.71429,128.57143 340,254.28571"
       id="path2820"
       transform="translate(0,452.36218)" />
  </g>
</svg>
« Last Edit: February 06, 2010, 09:50:50 am by raffe »

raffe

  • Traveller
  • *
  • Posts: 28
    • View Profile
Re: Conversion SVG <-> Sketch XML
« Reply #21 on: February 06, 2010, 09:34:41 am »
Delete this post (cant find where I do it)...
« Last Edit: February 06, 2010, 09:40:54 am by raffe »

derula

  • Hydlaa Citizen
  • *
  • Posts: 405
  • My main: Jamona Shikon
    • View Profile
    • Ugly Horst Tld.
Re: Conversion SVG <-> Sketch XML
« Reply #22 on: February 06, 2010, 11:07:59 am »
Hi, i fixed your bugs (and I hope didn't add too many new ones!).

Well it was about relative paths. The SVG specification is so horribly imprecise. I just read it wrong.

On the way, I found another bug, which is ... pretty strange. I fixed it, but don't know why it works this way round and not the way I had it O.o

Anyway, this showed me much more that there are probably more bugs in there. Just tell me if you find another one!

You can download the new version from here.

Thanks for the find! :)

raffe

  • Traveller
  • *
  • Posts: 28
    • View Profile
Re: Conversion SVG <-> Sketch XML
« Reply #23 on: February 06, 2010, 11:18:44 am »
Hi, i fixed your bugs (and I hope didn't add too many new ones!).

Well it was about relative paths. The SVG specification is so horribly imprecise. I just read it wrong.

On the way, I found another bug, which is ... pretty strange. I fixed it, but don't know why it works this way round and not the way I had it O.o

Anyway, this showed me much more that there are probably more bugs in there. Just tell me if you find another one!

You can download the new version from here.

Thanks for the find! :)
:thumbup: Thank YOU for your fantastic work!  :love:

I will  try the new release when I get home this evening... Cant wait!  \\o//

raffe

  • Traveller
  • *
  • Posts: 28
    • View Profile
Re: Conversion SVG <-> Sketch XML
« Reply #24 on: February 06, 2010, 01:16:12 pm »
I will  try the new release when I get home this evening... Cant wait!  \\o//
Works great! Thanks again!

derula

  • Hydlaa Citizen
  • *
  • Posts: 405
  • My main: Jamona Shikon
    • View Profile
    • Ugly Horst Tld.
Re: Conversion SVG <-> Sketch XML
« Reply #25 on: February 06, 2010, 05:19:15 pm »
You're welcome!

If this helps you to bring some art into the world, I'd be happy to see it (ingame, or simply in this or another thread as a screen shot). Even if it's "just" maps :P

And yeah, don't hesitate to ask if you feel there's another bug, as there sure are still some left :)

derula

  • Hydlaa Citizen
  • *
  • Posts: 405
  • My main: Jamona Shikon
    • View Profile
    • Ugly Horst Tld.
Re: Conversion SVG <-> Sketch XML
« Reply #26 on: March 14, 2010, 05:50:26 am »
Hey, I've just uploaded a new version (0.3d, hehe) which (fixes|adds) some smaller bugs (I hope it's "fixes").

Plus, it works in Ruby 1.9 now \ö/ (at least the parts I've tested). Thanks to kaerli2 for reporting it didn't.

Download link stays the same.

feas

  • Traveller
  • *
  • Posts: 34
    • View Profile
Re: Conversion SVG <-> Sketch XML
« Reply #27 on: February 09, 2016, 07:19:18 am »
Hello,

I tried to convert a map I made with Inkscape 0.48.5 r10040 and received an error.

simplified inkscape file : https://www.dropbox.com/s/swdwkf237csj5kf/dome.svg?dl=0

error running program: https://www.dropbox.com/s/xcm61m6bpw79uvh/svg-sketches.txt?dl=0

Last I saw it worked with ruby 1.9, I do have a newer version of ruby installed and not sure how to downgrade to try it with 1.9 to see if that is the issue.

Thanks for looking


BoevenF

  • Hydlaa Notable
  • *
  • Posts: 543
  • Amdeneir citizen, mostly travelling
    • View Profile
    • The Doømed Ones SVG
Re: Conversion SVG <-> Sketch XML
« Reply #28 on: February 09, 2016, 06:00:26 pm »
Hi feas,
it seems the file planeshift_sketch_xml is not loaded.

Change the first require line in svg2sketchxml.rb from
Code: [Select]
require('planeshift_sketch_xml')to
Code: [Select]
require('./planeshift_sketch_xml')
With this it works, although your dome.svg reaches the limit of 200 elements. I guess you'll need to simplify the drawing. Happy sketches!  :)

edit:
I have an old ruby 1.9.3p484, but I had your same error until I changed that line.
« Last Edit: February 09, 2016, 06:23:36 pm by BoevenF »

feas

  • Traveller
  • *
  • Posts: 34
    • View Profile
Re: Conversion SVG <-> Sketch XML
« Reply #29 on: February 09, 2016, 06:44:15 pm »
BoevenF Sir you are a rockstar! Thanks for the help!