Repository navigation
Fix ACIS text decoding losing the character after 'A' in binary DXF files - #1492
Conversation
|
Thank you! If you make a round-trip of binary DXF files, the written data is maybe invalid, because the |
|
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. |
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.
Fixes #1490.
decode()inezdxf/tools/crypt.pyskipped 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):
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.tests/test_00_dxf_low_level_structs+tests/test_10_issues: 578 passed after.mypy --ignore-missing-imports -p ezdxf: clean before and after.