Opened 12 years ago
Closed 12 years ago
#4680 closed defect (fixed)
Invalid DXF files
Reported by: | bishop | Owned by: | warmerdam |
---|---|---|---|
Priority: | high | Milestone: | 1.9.2 |
Component: | OGR_SF | Version: | 1.9.0 |
Severity: | normal | Keywords: | DXF driver, AutoCAD |
Cc: | neumann |
Description
The dxf files created via ogr2ogr (1.9.0 and 1.9.1) from any other formates are invalid. GDAL/OGR open such files, but AutoCAD and DWG TrueViewer report the error:
Customization file loaded successfully. Customization Group: TWVP The following error was encountered while reading in HATCH starting at line 1546: Error: expected group code 10 Invalid or incomplete DXF input -- drawing discarded. Press ENTER to continue:
I use the such command: ogr2ogr.exe -f DXF /path_to_folder/res.dxf /path_to_folder/file_name.shp
Attachments (6)
Change History (27)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Status: | new → assigned |
---|
I'm not sure how to get "TrueView" - can you provide a specific pointer? I tried AutoCAD 360 but it does not seem to support doing anything with dxf files except for uploading them.
comment:3 by , 12 years ago
Component: | default → OGR_SF |
---|
comment:4 by , 12 years ago
DWG TrueViewer is oficial viewer from Autodesk. You can get it e.g. here http://usa.autodesk.com/adsk/servlet/pc/item?siteID=123112&id=9078813
comment:5 by , 12 years ago
Cc: | added |
---|
comment:6 by , 12 years ago
Other free tools to test the dxf files are:
FreeCAD: http://librecad.org/ and DraftSight CAD from Dassault Systems
I could not get DraftSight to run, since it is a 32bit version and it had problems on my 64bit Ubuntu.
I see that the polygon converted DXF files do not display in FreeCAD while the linestring data works without problems.
Thanks for having a look at the problem.
Andreas
comment:7 by , 12 years ago
I have found that if I translate my normal polygon file to DXF with ogr2ogr-dev it will not read properly in qcad while the file I produced during driver development works fine. qcad actually reports some sort of "pow: ERANGE" error. I'm going to work on the assumption that this is fundamentally the same problem others are running into but I'd appreciate it if you guys could briefly confirm that poly_ogr_old.dxf works ok and poly_dev.dxf does not in the file:
comment:8 by , 12 years ago
I can confirm that poly_ogr_old.dxf works fine and poly_dev.dxf does not work.
Maybe the polygon filling that was introduced later on has to do with the problem? Just a wild guess ...
comment:9 by , 12 years ago
It seems likely now that the problem is writing things as a HATCH introduced in r22471. I have confirmed that reverting to old template files does not make a difference. If anyone has a *working* DXF file with hatches it might be useful for comparison. I will experiment with getting the hatches working qcad later in the day or tomorrow.
by , 12 years ago
Attachment: | simple_hatch_librecad.dxf added |
---|
Simple file with a hatched polyline created in librecad
comment:10 by , 12 years ago
I just attached a hatched polyline dxf created in LibreCAD. I can provide another one on Monday created in Autocad when I am back in the office.
Thanks, Andreas
comment:11 by , 12 years ago
Could someone check if the dxf file in wrk2.zip has a working polygon? I've taken a slightly different approach to stroking the boundary that seems to work with qcad. Perhaps it will also work with TrueView, etc.
comment:12 by , 12 years ago
wrk2.dxf seems to work fine in LibreCAD.
Will test in Autocad on Monday as this is the platform most of our customers use.
Thanks, Andreas
comment:13 by , 12 years ago
Bad news ...
When opening in Autocad, neither of the 3 files (poly_ogr_old.dxf, poly_dev.dxf, wrk2.dxf) opens correctly.
poly_ogr_old.dxf crashes Autodesk, the other two files open briefly - then Autocad waits for a command (Enter key) - and after pressing the enter key the file closes immediately.
No useful error messages unfortunately.
comment:14 by , 12 years ago
Andreas, as Frank suggested, perhaps you could create a DXF with hatches with Autocad ? Not sure if it is critical or not, but to be consistant with header.dxf, ideally this should be with $ACADVER = AC1018 (AutoCAD 2004/2005/2006 according to http://autodesk.blogs.com/between_the_lines/autocad-release-history.html/)
by , 12 years ago
Attachment: | temp_polygon_hatch_fillings.zip added |
---|
File with two polygons - one with solid fill one with hatch fill. Created with Autocad 2011
comment:15 by , 12 years ago
Hope my latest files will help? Contains 2 polygons. One with solid black fill, the other one with a hatch fill (diagonal lines). Exported in release versions 2000/2004/2010 and exported from Autocad 2011.
comment:16 by , 12 years ago
Maybe I have a solution for this, in the attachment you find the two files:
ogr_dxfwriterlayer.cpp, ogrdxflayer.cpp
from directory:
gdal-1.9.0\ogr\ogrsf_frmts\dxf\
I marked the changes with comments like (please remove before committing):
ak date ... ak end
The changes should fix the HATCH problem and add color to POINT, INSERT and HATCH.
Andre
comment:17 by , 12 years ago
Hi,
I tested the files "newpts.zip" and the patch that koestli provided. The file newpts.dxf opens fine in Autocad 2011. Also, polygon with fill hatches now convert and open fine.
So Frank - after review, can you please apply this patch to GDAL/OGR?
It would help us a lot.
Thanks, Andreas
comment:19 by , 12 years ago
Hi, I made some tests with and without the patch. The patch works great except when there is a hole in the polygon. Then, the dxf is again invalid.
Without the patch, i get the usual error: The following error was encountered while reading in HATCH starting at line 1546: Error: expected group code 10 Invalid or incomplete DXF input -- drawing discarded.
With the patch, i get:
The following error was encountered while reading in HATCH starting at line 2444: Error: expected group code 92 Invalid or incomplete DXF input -- drawing discarded.
I made a third test with GDAL 1.7.3 which output a two POLYLINE (one for the boundary and one for the hole) instead of a HATCH. In this case, the dxf is valid.
I tested with Autocad 2008.
Any idea how to fix that ? Or is it possible to force the use of POLYLINE instead of HATCH in GDAL 1.9.1 ? Jeff
by , 12 years ago
Attachment: | polygon_hole.zip added |
---|
Both the source Shape file and output dxf for a polygon with hole.
comment:20 by , 12 years ago
Milestone: | → 1.9.2 |
---|
Fix applied in trunk r24991 and branches/1.9 r24992 : """DXF: Write HACH (Polygon) compatible with other DXF viewers; Add color to POINT, INSERT and HATCH; add a configuration option DXF_WRITE_HATCH that can be set to NO to write POLYLINE instead of HATCH (just in case) (adapted from patch by koestli, #4680)"""
Starting with koestli patch, to fix the writing of polygons with holes, I've just moved the following snippet out of the loop that iterates over rings to write them in the main HATCH object where they normally apply.
WriteValue( 75, 0 ); // hatch style = Hatch "odd parity" area (Normal style) WriteValue( 76, 1 ); // hatch pattern type = predefined WriteValue( 98, 0 ); // 0 seed points
DWG TrueView 2013 seems to be happy with the generated polygons and display the hole correctly.
Please report if it works with other DXF viewers.
comment:21 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
The above fix was reported to work ( http://lists.osgeo.org/pipermail/gdal-dev/2012-October/034166.html ). Closing the ticket
It seems like currently we are unable to convert polygon features to dxf.