Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export to DXF : "AutoCAD Message: Copy to clipboard failed" #6013

Closed
jbp35 opened this issue Jul 5, 2022 · 4 comments
Closed

Export to DXF : "AutoCAD Message: Copy to clipboard failed" #6013

jbp35 opened this issue Jul 5, 2022 · 4 comments
Milestone

Comments

@jbp35
Copy link
Contributor

jbp35 commented Jul 5, 2022

Expected behavior and actual behavior.

After exporting any file to DXF with GDAL, it is not possible to copy geometry in AutoCAD and causes the following error message: "AutoCAD Message: Copy to clipboard failed"

Steps to reproduce the problem.

  1. Use ogr2ogr to convert any file to DXF format
  2. Open the output in AutoCAD
  3. Select and try to copy an entity in the drawing causes the error

Operating system

All operation systems

GDAL version and provenance

GDAL 3.5.0

Troubleshooting

This issue seems to be caused by an Hard-owner ID/handle (F) pointing to a missing dictionary in the generated file.

Defining this missing dictionary manually at the end of the file fixes the issue:

0 ACDBPLACEHOLDER 5 F 102 {ACAD_REACTORS 330 E 102 } 330 E

Original DXF file created using ogr2ogr (renamed as TXT):
[export_from_gdal_with error.txt]
(https://github.com/OSGeo/gdal/files/9044889/export_from_gdal_with.error.txt)

Modified DXF file with added dictionary at the end (renamed as TXT):
export_from_gdal_with dictionnary added.txt

Here is the output of Audit command in Autocad which helped me track the origin of the issue:

Command: AUDIT
Fix any errors detected? [Yes/No] <N>:

Auditing Header

Auditing Tables
AcDbDictionaryWithDefault(E)
                     Default Name Is Missing            Add it
					 
					 
Auditing Entities Pass 1
AcDbLayerTableRecord: "0"
                 PlotstyleName Id Invalid               Null
AcDbLayerTableRecord: "0"         was not repaired.
Pass 1 100     objects audited


Auditing Entities Pass 2
AcDbDictionaryWithDefault(E)
                           Normal ePermanentlyErased
AcDbDictionaryWithDefault(E)      was not repaired.
AcDbLayerTableRecord: "0"
                 PlotstyleName Id Invalid               Null
AcDbLayerTableRecord: "0"         was not repaired.
Pass 2 100     objects audited


Auditing Blocks
 0       Blocks audited
 
 
Auditing AcDsRecords

Total errors found 4 fixed 0
Erased 0 objects
@rouault
Copy link
Member

rouault commented Jul 5, 2022

CC @atlight

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Jul 5, 2022

See #1213 (comment).
It seems to me issue probably more related to AutoCAD itself: https://duckduckgo.com/?q=copy+to+clipboard+failed&ia=web
The issue usually doesn't occur with other CAD software, e.g. DraftSight or nanoCAD.

@atlight
Copy link
Contributor

atlight commented Jul 5, 2022

@jbp35 thanks so much for debugging this!

It seems to me issue probably more related to AutoCAD itself

Yes, ironically enough, AutoCAD's DXF reader is pretty lousy.

We should fix this in GDAL. If you make a pull request against https://github.com/OSGeo/gdal/blob/master/data/trailer.dxf I'll merge it.

jbp35 added a commit to jbp35/gdal that referenced this issue Jul 5, 2022
@jbp35
Copy link
Contributor Author

jbp35 commented Jul 5, 2022

@jbp35 thanks so much for debugging this!

It seems to me issue probably more related to AutoCAD itself

Yes, ironically enough, AutoCAD's DXF reader is pretty lousy.

We should fix this in GDAL. If you make a pull request against https://github.com/OSGeo/gdal/blob/master/data/trailer.dxf I'll merge it.

@atlight You welcome, this has been quite a pain for me for a long time and couldn't take it any more!

I created a PR with the proposed fix:
#6014

Just to mention, I just code occasionally for fun and don't have much understanding of what's actually going on here. So a good review is definitely needed before merging this. Thanks!

rouault pushed a commit that referenced this issue Jul 5, 2022
@rouault rouault added this to the 3.5.2 milestone Jul 5, 2022
@rouault rouault closed this as completed Jul 5, 2022
g8sqh pushed a commit to g8sqh/gdal that referenced this issue Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants