Opened 8 years ago

Closed 8 years ago

#6460 closed defect (invalid)

ogr save dxf file,autocad don‘t open

Reported by: mmtxcp Owned by: warmerdam
Priority: highest Milestone:
Component: OGR_SF Version: unspecified
Severity: major Keywords:
Cc:

Description

I use GDAL to read the DXF file, and then save as a DXF file, the use of AutoCAD 2014 failed to open, but QCAD, ArcGIS can be opened correctly. With test code (above gdal2.0 version) and DXF original documents and generate the results of the DXF file.

Attachments (4)

ceshi.dxf (149.5 KB ) - added by mmtxcp 8 years ago.
test.cpp (5.3 KB ) - added by mmtxcp 8 years ago.
result1.dxf (106.0 KB ) - added by mmtxcp 8 years ago.
screen.png (85.0 KB ) - added by mmtxcp 8 years ago.

Download all attachments as: .zip

Change History (9)

by mmtxcp, 8 years ago

Attachment: ceshi.dxf added

by mmtxcp, 8 years ago

Attachment: test.cpp added

by mmtxcp, 8 years ago

Attachment: result1.dxf added

by mmtxcp, 8 years ago

Attachment: screen.png added

comment:1 by mmtxcp, 8 years ago

Version: unspecified

The reason is that the following functions lead to OGRDXFWriterDS: long: WriteEntityID (*fpIn VSILFILE, nPreferredFID long), the feature DXF access to the ID is a value, and the TranslateGenericProperty function within the 5: case PoFeature->SetField ("EntityHandle", pszValue); storage is not a ID, resulting in re write DXF, the coding error occurs! The solution is to write feature before setting the ID to -1 (pFeature->SetFID (-1);)

comment:2 by mmtxcp, 8 years ago

pFeature->SetFID(-1);

OGRErr err = pNewLayer->CreateFeature(pFeature);

comment:3 by Even Rouault, 8 years ago

Can you generate a proper patch with svn diff or diff -u for your proposed correction ?

comment:4 by Even Rouault, 8 years ago

Actually re-reading, I think the issue comes from your code. You call directly CreateFeature() from the feature got from the source dataset. And particularly you inherit from its FID. You should unset the FID with pFeature->SetFID(-1); in your own code. I'm not sure why not using the source FID doesn't work however but there are a few comments in the DXF driver about issues with FID (OGRDXFWriterLayer::WriteCore())

comment:5 by Even Rouault, 8 years ago

Resolution: invalid
Status: newclosed

Closing, assuming this was a mis use of the API

Note: See TracTickets for help on using tickets.