DXF export fails with <circle> elements in SVG file from CorelDraw

Bug #959671 reported by Ian Blythe
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Low
Unassigned

Bug Description

Traceback (most recent call last):

  File "dxf_outlines.py", line 252, in <module>

    e.affect()

  File "C:\Program Files (x86)\Inkscape\share\extensions\inkex.py", line 215, in affect

    self.effect()

  File "dxf_outlines.py", line 243, in effect

    self.process_group(doc)

  File "dxf_outlines.py", line 216, in process_group

    self.process_group(node)

  File "dxf_outlines.py", line 216, in process_group

    self.process_group(node)

  File "dxf_outlines.py", line 218, in process_group

    self.process_path(node, self.groupmat[-1])

  File "dxf_outlines.py", line 175, in process_path

    x = float(node.get('x'))

TypeError: float() argument must be a string or a number

Inkscape 0.48..2 r9819 Windows 7 Home Professional 64-bit

Tags: dxf exporting

Related branches

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

could you attach the .svg file?

su_v (suv-lp)
tags: added: exporting
removed: svg to
Revision history for this message
Ian Blythe (ipblythe) wrote : Re: [Bug 959671] Re: DXF export crashes from SVG

Hi Alvin,

File attached, the source files for this are only CDR, SVG and PLF,
and the laser cutter
I have access to only accepts DXF. Hence I was a bit disappointed to
find these bugs.

With my best regards
Ian

On Mon, Mar 19, 2012 at 8:26 PM, Alvin Penner <email address hidden> wrote:
> could you attach the .svg file?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/959671
>
> Title:
>  DXF export crashes from SVG
>
> Status in Inkscape: A Vector Drawing Tool:
>  New
>
> Bug description:
>  Traceback (most recent call last):
>
>    File "dxf_outlines.py", line 252, in <module>
>
>      e.affect()
>
>    File "C:\Program Files (x86)\Inkscape\share\extensions\inkex.py",
>  line 215, in affect
>
>      self.effect()
>
>    File "dxf_outlines.py", line 243, in effect
>
>      self.process_group(doc)
>
>    File "dxf_outlines.py", line 216, in process_group
>
>      self.process_group(node)
>
>    File "dxf_outlines.py", line 216, in process_group
>
>      self.process_group(node)
>
>    File "dxf_outlines.py", line 218, in process_group
>
>      self.process_path(node, self.groupmat[-1])
>
>    File "dxf_outlines.py", line 175, in process_path
>
>      x = float(node.get('x'))
>
>  TypeError: float() argument must be a string or a number
>
>  Inkscape 0.48..2 r9819 Windows 7 Home Professional 64-bit
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/inkscape/+bug/959671/+subscriptions

Revision history for this message
Alvin Penner (apenner) wrote : Re: DXF export crashes from SVG

confirmed on Inkscape rev 11098.
as a temporary workaround, could you try the following procedure. From the menu choose Edit->SelectAll. Then choose Path->ObjectToPath. This will attempt to convert all the objects into paths which hopefully will be readable.

When I do this I get the following result.

Changed in inkscape:
status: New → Confirmed
Revision history for this message
Alvin Penner (apenner) wrote :

- it looks like the problem is caused by the presence of 'circle' objects in the diagram. The current dxf output routine recognizes only two types of objects, namely 'path' (which includes arcs) and 'rect'
- when you do a Path->Object To Path operation, then a circle object will get converted to a path (which is actually four bezier curves)

Revision history for this message
su_v (suv-lp) wrote : Re: DXF export crashes from SVG

Setting bug importance to 'Low':
The provided sample SVG file originates from CorelDraw:
<!-- Creator: CorelDRAW -->
A workaround for SVG object types which Inkscape partially supports [1] exists: 'Path > Object to Path'.

---
[1] Basic SVG shapes (like e.g. <circle>) are rendered correctly but cannot be edited as shape, nor created/written in Inkscape.

Changed in inkscape:
importance: Undecided → Low
Revision history for this message
su_v (suv-lp) wrote :

<circle> and <ellipse> basic SVG shapes are now supported in DXF export, as tracked in more recent report based on Inkscape 0.91 (the latest Inkscape release does write <circle> and <ellipse> elements if feasible):
* Bug #1489320 “Circles are not exported when saving in DXF file format”
  https://bugs.launchpad.net/inkscape/+bug/1489320

The test case in this reports however still fails to export to DXF: AFAICT the circles don't have cx, cy explicitly defined (-> 0,0), and are then moved to the actual position with a transform attribute:

  <circle
   id="circle3057"
   r="1.5"
   transform="matrix(2.64845E-014 1 -1 2.64845E-014 295.5 255.967)"
   stroke-width="0.0762"
   stroke="#1F1A17"
   fill="none" />

According to the SVG 1.1 specification, this is valid:
http://www.w3.org/TR/SVG11/shapes.html#CircleElementCXAttribute

The extension in current trunk fails with this error (presumable expecting cx, cy to present even if redundant (because 0)):

Traceback (most recent call last):
  File "dxf_outlines.py", line 360, in <module>
    e.affect()
  File "/usr/share/inkscape/extensions/inkex.py", line 268, in affect
    self.effect()
  File "dxf_outlines.py", line 346, in effect
    self.process_group(doc)
  File "dxf_outlines.py", line 304, in process_group
    self.process_group(node)
  File "dxf_outlines.py", line 304, in process_group
    self.process_group(node)
  File "dxf_outlines.py", line 308, in process_group
    self.process_shape(node, self.groupmat[-1])
  File "dxf_outlines.py", line 224, in process_shape
    cx = float(node.get('cx'))
TypeError: float() argument must be a string or a number

summary: - DXF export crashes from SVG
+ DXF export fails with <circle> elements in SVG file from CorelDraw
Revision history for this message
Alvin Penner (apenner) wrote :

attached is a proposed fix for this bug.
this can be tested by copying the new file to the \Inkscape\share\extensions\ directory.

Revision history for this message
su_v (suv-lp) wrote :

Diff based on comment 8 tested successfully with test case from comment 2, using Inkscape 0.91+devel r14397.

Revision history for this message
su_v (suv-lp) wrote :

Alternative diff to the same effect (extended for the coordinates for <line> elements).

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

looks good to me!
I wasn't aware that this type of syntax was possible, it is much neater this way.
- could you go ahead and commit your latest version?

Revision history for this message
su_v (suv-lp) wrote :

On 2015-10-07 21:12 (+0200), Alvin Penner wrote:
> I wasn't aware that this type of syntax was possible, it is much neater this way.

IIRC I learned about it here:
http://infohost.nmt.edu/tcc/help/pubs/pylxml/web/Element-get.html

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

thanks, that looks like a very useful reference

Revision history for this message
su_v (suv-lp) wrote :

Diff committed in rev 14398.

Changed in inkscape:
milestone: none → 0.92
status: Confirmed → Fix Committed
tags: added: backport-proposed
Revision history for this message
su_v (suv-lp) wrote :

Fix backported to 0.91.x in rev 13843.

Changed in inkscape:
milestone: 0.92 → 0.91.1
tags: removed: backport-proposed
jazzynico (jazzynico)
Changed in inkscape:
milestone: 0.91.1 → 0.92
status: Fix Committed → Fix Released
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.