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

saveas() error: AssertionError: dictionary handle not resolved #833

Closed
xuanyuanminzheng opened this issue Feb 15, 2023 · 6 comments
Closed

Comments

@xuanyuanminzheng
Copy link

I simply readfile and saveas:

image

The program gave the following error, may I ask what may have caused it?

image

@mozman
Copy link
Owner

mozman commented Feb 15, 2023

I need the test data to help (upload as zip-archive).

@xuanyuanminzheng
Copy link
Author

xuanyuanminzheng commented Feb 15, 2023

I need the test data to help (upload as zip-archive).

@mozman
test.zip
Thank you for your attention!This is the test file.

@mozman
Copy link
Owner

mozman commented Feb 15, 2023

This is a complex DXF file created by a 3rd party application and also contains some errors:

Autodesk DWG Trueview 2023 can't open the file:

Error code (0x2) Das System kann die angegebene Datei nicht finden.
AcRxDynamicLinker failed to load 'acdgnlsdraw.crx'
acdgnlsdraw.crx
The following error was encountered while reading
in INSERT starting at line 602072:
Missing DXF group code: 2
Invalid or incomplete DXF input -- drawing discarded.
Press ENTER to continue:

BricsCAD can open the file, but the recover command found some errors:

128431 objects audited
Total errors found during audit 22, fixed 22

Ezdxf can read the file but isn't able to fix all issues and re-saving the file raises an exception:

C:\> ezdxf audit -s .\issue833.dxf
auditing file: .\issue833.dxf
7 issues fixed.

   1. Issue [115] fixed.
   Deleted entity INSERT(#1012B9EB) without a BLOCK name

   2. Issue [213] fixed in DICTIONARY(#12132F26).
   Removed entry "0$1227-PP$0$P-1.22.dgn-StrokePattern" with invalid handle in DICTIONARY(#12132F26)

   3. Issue [213] fixed in DICTIONARY(#12132F26).
   Removed entry "01$0$1227-GP$0$P-1.24.dgn-StrokePattern-59909" with invalid handle in DICTIONARY(#12132F26)

   4. Issue [213] fixed in DICTIONARY(#12132F26).
   Removed entry "0_00$0$S-100_CD_OB Ground Floor Framing Plan$0$A" with invalid handle in DICTIONARY(#12132F26)

   5. Issue [202] fixed.
   Fixed invalid owner handle in MATERIAL(#ED)

   6. Issue [202] fixed.
   Fixed invalid owner handle in MATERIAL(#EC)

   7. Issue [202] fixed.
   Fixed invalid owner handle in MATERIAL(#EE)

Found 0 errors, applied 7 fixes
Traceback (most recent call last):
  File "C:\Python311\Scripts\ezdxf-script.py", line 33, in <module>
    sys.exit(load_entry_point('ezdxf', 'console_scripts', 'ezdxf')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-x-x-x-x- snip

  File "c:\source\ezdxf.git\src\ezdxf\entities\xdict.py", line 53, in dictionary
    assert not isinstance(xdict, str), "dictionary handle not resolved"
AssertionError: dictionary handle not resolved

For such files you will always have to use the recover module to load the DXF file, see docs:

from ezdxf import recover

doc, auditor = recover.readfile("your.dxf")
auditor.print_fixed_errors()
auditor.print_error_report()

But that doesn't work for this example. I will try to extend the ezdxf auditor to process this file, but the problem is difficult to debug due to the size of the DXF file (183MB). You can't do anything now, you have to wait for the release of the next version of ezdxf.

@xuanyuanminzheng
Copy link
Author

@mozman Thank you very much for your help, I understand this is my dxf file has error, I will get the dwg file using AUTOCAD to convert and retest. Thank you again for your time.

mozman added a commit that referenced this issue Feb 15, 2023
Check if every entity is the entity that is stored for this handle in the
entity database.  This can happen if the same handle is assigned multiple
times to different entities.
@mozman
Copy link
Owner

mozman commented Feb 15, 2023

The application you are using is VERY bad and assigns the same handle for multiple entities - which is an absolute NO GO, every entity handle in a DXF document has to be unique.

Ezdxf removes entities with duplicate handles from the OBJECTS section and can export your example file, that now can be opened by TrueView 2023. But some data is lost, ezdxf maybe deleted important data.

You can not trust this exported DXF file and you should not trust that application you use!

@xuanyuanminzheng
Copy link
Author

@mozman
I think what you said is quite right. I converted my dwg file to dxf through AUTOCAD2020 and successfully solved the previous problem.
By the way, the first attempt in the afternoon still produced an error. Finally, I solved the problem by copying the contents of dwg file into a new image and saving dxf. I think there should be some mistakes in drawing my original dwg file.
Thank you very much for your help!

@mozman mozman closed this as completed Feb 15, 2023
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

2 participants