[gdal-dev] Problems converting polygons to DXF with ogr2ogr

Colin Wright wrightc at forthvalleygis.co.uk
Tue Jun 5 02:50:20 PDT 2012


Steve,
Thanks for your suggestion.  I tried opening the file in the Teigha
Viewer but it was giving an error as well.
The error in this case was:

ODA Warning: Syntax error or premature end of file on line/offset
1748.
Error: Loading of file "C:\Temp\cwpolytest.dxf" was failed.

In this case the line 1748 relates to a DICTIONARY line, which is
actually line #50 from the trailer.dxf file in OGR.
I've checked the header.dxf and trailer.dxf files and both are
identical to those in the gdal source code repository

Does anyone have a windows build of gdal 1.9 that does work for
converting polygons to dxf?

Thanks
Colin
—----------------------------------------------------------
On 6/4/2012 14:22 PM, Stephen Woodbridge wrote:

Colin,

You might want to try reading the dxf file the the Teigha File 
Convertor. This is a Windows utility that converts between dwg abd dxf

and the various versions of both. Its a free download and I just used
it 
to convert about 60K dwg files to dxf and it works great. You can 
specify what version of dxf you are reading or writing. Oh and there is

also a companion viewer application so you can view the files. I just 
found it a useful too because it was very flexible and supported 
multiple versions.

-Steve

On 6/4/2012 12:42 PM, Colin Wright wrote:
> With gdal 1.8 and 1.9 I am unable to convert any polygon datasets to
> DXF in a format where they can be read by AutoCad.  Every time I try
> to open a DXF created with these versions I get the 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.
>
> I've found a couple of mentions of this issue on the mailing list in
> the past but haven't seen any real solutions.  Details are below:
>
> I am currently using 1.9.0, and have tried converting
> programmatically from postgis 1.5.3 ->  DXF  and   have also tried
> using ogr2ogr from Shapefile ->  DXF with the same result. The
> OGR2OGR command lines I've tried are:
>
> ogr2ogr -f "DXF" polytest2.dxf polytest.shp or ogr2ogr -f "DXF" -nlt
> POLYGON polytest2.dxf polytest.shp
>
> The test shapefile contains only 3 simple polygon shapes with no
> holes or multi-part geometries, and as far as I can tell I'm using
> the standard DXF header and footer files that come with GDAL.  The
> DXFs work fine when created with the older 1.7 version of GDAL which
> just translates the polygons as lines.
>
> Does anyone know of another approach I can try, or is this a known
> bug?  I can send anyone a sample dxf file if they would like to take
> a look at it.
>
> Regards
>
> Colin Wright
>



More information about the gdal-dev mailing list