DXF Export fails due to an error in dxf_outlines.py (float parsing error)

Bug #1693027 reported by Saren Taşçıyan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Confirmed
Undecided
Unassigned

Bug Description

Hi,

I am using Inkscape (on Ubuntu 16.04) for manufacturing devices for my research project. In 0.91, I was able to create my devices in Inkscape and save it as DXF files (which I had to convert later on to Gerber for the manufacturer).

After 0.92 update I am no longer able to save my file as DXF. The error log points out that the "mm" unit inside the string is the problem. There are several lines in dxf_outlines.py, which parses these strings as floats. As a workaround and to dissect the problem, I have modified first identified line as following:
float(node.get('cx', 0) -> float(node.get('cx', 0).replace('mm',''))
Then I have got the same error on other lines. Therefore, I have replaced those as well...
        elif node.tag == inkex.addNS('circle','svg'):
            cx = float(node.get('cx', 0).replace('mm',''))
            cy = float(node.get('cy', 0).replace('mm','').replace('mm',''))
            r = float(node.get('r').replace('mm',''))
            d = "m %s,%s a %s,%s 0 0 1 %s,%s %s,%s 0 0 1 %s,%s z" % (cx + r, cy, r, r, -2*r, 0, r, r, 2*r, 0)
            p = cubicsuperpath.parsePath(d)
        elif node.tag == inkex.addNS('ellipse','svg'):
            cx = float(node.get('cx', 0).replace('mm',''))
            cy = float(node.get('cy', 0).replace('mm','').replace('mm',''))
            rx = float(node.get('rx'))
            ry = float(node.get('ry'))
            d = "m %s,%s a %s,%s 0 0 1 %s,%s %s,%s 0 0 1 %s,%s z" % (cx + rx, cy, rx, ry, -2*rx, 0, rx, ry, 2*rx, 0)
            p = cubicsuperpath.parsePath(d)

Basically, this issue involves circles and ellipses. Of course removing unit from the string didn't solve the problem. But I have identified the lines involved. I hope this helps to improve Inkscape!

Revision history for this message
Saren Taşçıyan (sarentasciyan) wrote :
Revision history for this message
Alvin Penner (apenner) wrote :

could you attach the svg file that is causing the problem, for testing purposes?

Revision history for this message
Saren Taşçıyan (sarentasciyan) wrote :

This is a sample file reproducing the issue. I have copied the objects, which cause this problem. Small white objects on black background.

Revision history for this message
Alvin Penner (apenner) wrote :

thanks for the file,
confirmed on Windows 10, Inkscape 0.92.1 r15371

Changed in inkscape:
status: New → Confirmed
Revision history for this message
Saren Taşçıyan (sarentasciyan) wrote :

I guess this is a relevant piece of information: I have many such circles in my file. And these circles were originally generated in a separate python script. I generate repeating patterns in a script, because it is easier. Then I copied those shapes (all circles) into another inkscape SVG file. It might be that copying from plain SVG (generated by script) into inkscape SVG might be an issue, which then displayed itself during DXF export.

Revision history for this message
Alvin Penner (apenner) wrote :

Thank you for the last comment. I could not figure out how you got the mm units into the specification of (for example)
r="0.0015875002mm"
The Inkscape gui does not seem to support the use of such units when drawing a circle by hand, although it does interpret them if they are typed in manually using the XML editor. So this needs to be fixed in the dxf output.

As a separate issue, however, I should warn you that your radii specified as above, are currently being misinterpreted by the Inkscape gui as well, independently of the dxf output. If I highlight the above circle with r="0.0015875002mm", then I expect the width to be exactly .003175mm, since the stroke width is zero. However the Select tool shows the width to be .012mm, which is too high by a ratio of 96/25.4. Since this is not related to dxf output, I am going to report it as a separate bug.

description: updated
Revision history for this message
Alvin Penner (apenner) wrote :

separate report is Bug #1693200

Revision history for this message
Ralph Diehl (ralphd3g) wrote :

Experincing problem with SVG To DXF convertion to UCCNC.
Attachment file in UCCNC.
ralphd3g

Revision history for this message
Ralph Diehl (ralphd3g) wrote :

Added Information
Generial:

 Windows 10 Version 1709 OS B16299.125 64 bit intel(r) Core(tm) i5-72000 CPU @ 2.5 GHZ 2.71 GHZ

 UCCNC=CNC DRIVE MOTION CONTROLER FOR (UT100) BY PolgardiDesign (Switzerland & Hungry)
  Software Version 1.2006, Firmware Version 1.000, Hardware 0.00, API 2.0600

thank you for all that you do.
Ralphd3g

Revision history for this message
Alvin Penner (apenner) wrote :

@Ralph - could you attach the svg file that you are converting to dxf?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.