DXF import sometimes gets divide by zero

Bug #892496 reported by Satyagraha 1956 on 2011-11-19
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Alvin Penner

Bug Description

Am using 0.48.2 r9819 (WinXP). When importing the attached DXF file, I get the following traceback:

Traceback (most recent call last):

  File "dxf_input.py", line 487, in <module>


  File "dxf_input.py", line 90, in export_SPLINE

    a1 = (vals[groups['40']][i] - vals[groups['40']][i-1])/(vals[groups['40']][i+2] - vals[groups['40']][i-1])

ZeroDivisionError: float division

su_v (suv-lp) on 2011-11-19
tags: added: importing
su_v (suv-lp) wrote :

Reproduced with Inkscape 0.48.2 and 0.48+devel r10744 on Mac OS X 10.5.8 (i386)

Interestingly not reproduced with the modified DXF input extension from
 Bug #797137 “Landscape and Layer Color options for DXF inport”

@Alvin - I don't know what change in that provided custom version does handle this exception, nor on which version of 'dxf_input.py' it is based. Maybe you could take a closer look?

Changed in inkscape:
importance: Undecided → Medium
status: New → Confirmed
Alvin Penner (apenner) wrote :

confirmed on Windows XP, Inkscape rev 10728.

fwiw, this file will not load into Voloview Express 2.01 so it is somehow not compliant with the dxf spec. Could you indicate how it was produced?

Alvin Penner (apenner) wrote :

> Maybe you could take a closer look?

yes, I'll check it out this weekend, probably a problem caused by color

su_v (suv-lp) wrote :

> this file will not load into Voloview Express 2.01

File opens without apparent errors in
- QCAD (Community edition)
- QCAD 3 Beta & RC1
- LibreCAD 1.0rc4
- Draftsight V1R13
- SolidWorks eDrawings

For information, this file is a public download from the link entitled "* DXF and DWG 2D-vector graphics [zip; 0.71 MB]" at:

I have seen this bug when importing DXF from several entirely unrelated product websites. Therefore I suspect there is one particular CAD program which generates these anomalous DXF format files - which one, though, I have no idea.

Alvin Penner (apenner) wrote :

attached is a new version of dxf_input.py, which avoids the crash. This will need to be put into the directory share\extensions\dxf_input.py

Alvin Penner (apenner) wrote :

three separate problems were encountered when loading the file.

1. The crash was caused by a new type of spline which is a subset of the multispline introduced in bzr rev 10183. The new type of spline contains knot points which are triply degenerate which caused the crash.
2. After fixing that, the file loaded without incident. However, a number of circular objects were missing. These were actually splines as well, in which the 'closed' attribute of Group Code 70 had been set, which caused the program to ignore these objects. It was not necessary to ignore these objects so the restriction was removed.
3. After fixing that, there were still a number of objects missing. These were objects of the type POLYLINE which contained VERTEX objects. Both of these types of objects are typical of AutoCad Release 12 files and they have been replaced by the LWPOLYLINE entity in Release 13. The dxf_input.py routine does not support AutoCad Release 12 features. To get around this, the file was loaded into QCad and then re-saved, which automatically converts it to Release 13.
     When loaded into Inkscape, the svg file is attached here. As far as I can tell, it is complete.

Alvin Penner (apenner) wrote :

committed to rev 10749

Changed in inkscape:
status: Confirmed → Fix Committed
su_v (suv-lp) on 2012-06-08
Changed in inkscape:
assignee: nobody → Alvin Penner (apenner)
milestone: none → 0.49
tags: added: backport-proposed
su_v (suv-lp) wrote :

Backported to branch 0.48.x in revision 9935.

tags: removed: backport-proposed
su_v (suv-lp) on 2012-12-12
Changed in inkscape:
milestone: 0.49 → 0.48.4
Ted Gould (ted) on 2012-12-17
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers