Some DXF files generated by ezdxf 1.2.0 cannot be opened by AutoCAD
hu-xiaonan opened this issue · comments
Describe the bug
The DXF files (version R2004 and R2007) generated by ezdxf 1.2.0 cannot be opened by AutoCAD.
To Reproduce
import ezdxf
assert ezdxf.VERSION == '1.2.0'
doc = ezdxf.new(dxfversion='R2007') # Also R2004.
msp = doc.modelspace()
msp.add_line((0, 0), (10, 0))
doc.saveas('line.dxf')
AutoCAD (version 2018, 2019 and 2020) fails to open line.dxf and gives the following error.
Error 50 in drawing header on line 960
Invalid or incomplete DXF input -- drawing discarded.
The issue occurs on DXF files generated on both Windows (with python 3.9 and 3.11) and Linux (with python 3.11).
The issue only occurs on DXF files generated with version R2004 and R2007. For version R2000, R2010, R2013 and R2018, there is no problem.
The issue seems to be related to the new feature of XCLIP, as when I edit the DXF file and change the value of XCLIPFRAME
from 2 to 0 or 1, AutoCAD can open the file without any problem.
Thank you for your fast repsonse @mozman , but the issue has not been completely resolved. The problem remains for R2007.
The commit covered up the issue with R2004 by updating mindxf
of XCLIPFRAME
to R2007, but the problem actually lies in the default value of XCLIPFRAME
being 2, which is invalid for R2004 and R2007, as stated in addons/dwg/header_section.py
that
$XCLIPFRAME: RC # before R2010 the value can be 0 or 1 only.
Therefore, I believe it is better to adjust the default value of XCLIPFRAME
based on the specific DXF version.