mondalaci / dxf2svg2kicad

DXF to SVG to KICAD_PCB converter webapp that runs purely on the client side
https://mondalaci.github.io/dxf2svg2kicad/
GNU General Public License v3.0
98 stars 22 forks source link

DXF conversion failed - NaN in output file #6

Closed nytowl closed 9 years ago

nytowl commented 9 years ago

I imported the dxf and it fails with the error below. Changing all of the NaNs in the output to -90 and it opens correctly

design_xplode Error loading board. PARSE_ERROR: need a NUMBER for 'segment angle' in input/source "/home/angus/Downloads/Quad_design_xplode.kicad_pcb", line 263, offset 108 from /build/buildd/kicad-0.20131208+bzr4024/common/dsnlexer.cpp : NeedNUMBER() : line 362

mondalaci commented 9 years ago

@nytowl Thanks for reporting this issue!

As strange as it might seem this works perfectly for me.

  1. Can you open the exported SVG in Inkscape?
  2. What is your KiCad version?
  3. Which browser do you use and what version?
mondalaci commented 9 years ago

Given that this works for me and I haven't received any answers I'm closing this issue.

nytowl commented 9 years ago

I didn't try number 1.

KiCad version is build 2013-jul-07-stable, I'm not sure what difference the kicad version makes as the file output from the web tool has NaNs in it.

I am using firefox 34 to do the conversion.

mondalaci commented 9 years ago

@nytowl You are totally right that the version of KiCad doesn't make any difference because the generated file features NaNs anyways. I didn't think this question through. Sorry about that.

As it turns out the problem is that in Firefox SVGPathElement.getTotalLength() and maybe SVGPathElement.getPointAtLength() too provide inaccurate results and as a consequence the relevant value becomes NaN. As for now the only solution is to use Chrome. I could probably reimplement these methods but I don't want to devote time to them given that they already work accurately in Chrome.

Nevertheless, now I check for the correct intervals and don't allow the value to go out of bounds, avoiding NaN values. Please note that this way even though the generated file will be readable by KiCad the relevant arcs will be inaccurate in the generated DXF when Firefox is used. I also provide a warning for Firefox users about this issue and suggest them to use Chrome whenever possible.

Given the above you should also use Chrome because it will generate an accurate DXF file unlike your workaround of replacing NaN values with -90 values.

Can I include your file into the tests directory to be able to easily reproduce this issue in the future? I'm personally also interested about what does your drawing feature. :)