Skip to content

Fix ACIS text decoding losing the character after 'A' in binary DXF files - #1492

Merged
mozman merged 1 commit into
mozman:masterfrom
1915rising:fix/1490-crypt-decode-binary-escape
Nov 26, 2026
Merged

mozman merged 1 commit into
mozman:masterfrom
1915rising:fix/1490-crypt-decode-binary-escape

Conversation

@1915rising

Copy link
Copy Markdown
Contributor

Fixes #1490.

decode() in ezdxf/tools/crypt.py skipped the byte after every 0x5E ("^", the encoded letter "A") unconditionally. That byte is the escape space, and it exists only in ASCII DXF files. I verified this in the reporter's files at the raw byte level: in the ASCII file every "^" is stored as "^ ", in the binary file the next content byte follows "^" directly (0 occurrences of "^ " in the whole binary file). In binary DXF the skipped byte is real content, so "Alliance ACIS" came back as "Aliance AIS".

The fix skips the byte after 0x5E only when it is a space (0x20) — the fix shape proposed in the issue, reproduced and verified locally first.

Reproduction (the issue's script, on the reporter's k_regions_solids_2004 files):

  • Before: the binary file reads "@33 Open Design Aliance AIS Builder", the ASCII file reads "@33 Open Design Alliance ACIS Builder"; 4 of 107 ACIS lines differ.
  • After: all ACIS content lines are identical between the binary and the ASCII file. The only remaining differences are the save timestamps stored inside the two files themselves (13:56:44 vs 13:56:43).

Tests:

  • tests/test_00_dxf_low_level_structs/test_012_crypt.py: two regression tests added, one per storage form. The binary-form test fails before the fix and passes after; the ASCII form decodes as before.
  • Targeted set (test_012_crypt, binary tag tests, the ACIS tests in test_02/test_04/test_05): 317 passed before, 319 passed after.
  • tests/test_00_dxf_low_level_structs + tests/test_10_issues: 578 passed after.
  • mypy --ignore-missing-imports -p ezdxf: clean before and after.

@mozman

mozman commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Thank you!

If you make a round-trip of binary DXF files, the written data is maybe invalid, because the crypt.encode function still write a space after 'A'.
Can you verify this with an Autodesk CAD application? (Autodesk apps are very picky, other CAD applications may work)

@1915rising

Copy link
Copy Markdown
Contributor Author

Thank you for checking it. I cannot verify this with an Autodesk application: I do not have one available in my environment, so I cannot confirm how Autodesk accepts or rejects such a file.

What I verified locally: crypt.encode() appends a space after the encoded form of the letter A unconditionally, with no distinction between ASCII and binary output. A binary DXF file written through export_sat_data therefore contains that space in the ACIS text, while the binary files in the original report contain none. An ezdxf-to-ezdxf round trip is self-consistent with the decode fix in this PR, because the fixed decoder skips that space, but that does not prove that a picky Autodesk application accepts the written binary data.

So the encode side likely needs the same ASCII/binary distinction as the decode side, but I cannot prove the Autodesk behaviour from here.

@mozman
mozman merged commit 0535856 into mozman:master Nov 26, 2026
12 checks passed
mozman added a commit that referenced this pull request Nov 26, 2026
Until this fix SAT data of ACIS entities was wrong encoded in Binary DXF files written by ezdxf.
Autodesk TrueView did not not show this ACIS based entities.
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

Successfully merging this pull request may close these issues.

Binary DXF from BricsCAD: ACIS text loses the character after "A"

2 participants