Skip to content

Write every CadValue type in DXF and read the date back - #1263

Open
ilCosmico wants to merge 4 commits into
DomCR:masterfrom
ilCosmico:dxf-cadvalue-write
Open

ilCosmico wants to merge 4 commits into
DomCR:masterfrom
ilCosmico:dxf-cadvalue-write

Conversation

@ilCosmico

Copy link
Copy Markdown
Contributor

Split from #1085 as you asked.

writeCadValue now 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.dxf is 93=7 90=0 with 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 FieldCadValues case checks every type on the DXF round trip, and WriteFieldDateValue covers 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.

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 branch has not been deployed

No deployments
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.

1 participant