Repository navigation
Conversation
writeCadValue now writes the unit type, the format and the formatted value, skips the data of empty and unknown values and writes dates as the 16 byte block AutoCAD uses. The reader decodes that block back into the date.
An unknown value without the empty flag, as read from a pre R2007 DWG, carries its data in 91 like the DWG writer does, otherwise it is lost when the DXF is read back.
This was referenced Sep 30, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split from #1085 as you asked.
writeCadValuenow writes every value type AutoCAD uses in DXF (long, double, string, date and point), with flags, units and format taken from the model, and the DXF reader decodes the date back. On master a FIELD with a date value is lost on read-back, and an empty unknown value comes back as 0.About code 91 on unknown values: you were right that removing it breaks things. AutoCAD never writes it when the value is empty, since every unknown value in
sample_AC1032_ascii.dxfis93=7 90=0with no data. But an AutoCAD 2000 drawing with FIELD values has unknown values that are not empty, and without the 91 they read back as null. The second commit writes 91 only when the value is not empty, the same rule the DWG writer follows.The new
FieldCadValuescase checks every type on the DXF round trip, andWriteFieldDateValuecovers the date. The date stays out of the shared case because in DWG R2000 and R2004 it does not round-trip, on master too, because of the converter in CSUtilities (DomCR/CSUtilities#27).The last commit moves the SYSTEMTIME date conversion into
CadUtils, next to the Julian date helpers, so that the DWG and DXF code share it instead of keeping two copies. The two new helpers have doc comments, while the other methods in the class don't. I usually add them, but tell me if you'd rather keep the class as it was, or if you want me to document the other methods too for consistency.