Repository navigation
Conversation
Remove the TableEntity exclusion from the DXF writer and implement writeTableEntity/writeTableCell, following the layout AutoCAD writes (and the DXF reader consumes): AcDbBlockReference data, then the AcDbTable section with version, style handle, horizontal direction, value flag, grid counts, row heights/column widths and the per-cell data with its contents (301 CELL_VALUE + value block). The ACAD_TABLE class entry is added automatically through IDxfClassDefined. Cell contents with no value are skipped; per-cell style overrides, the table cache block content and the TABLECONTENT object are not written yet.
Fill in the SingleTableEntity case with a valid 2x3 table (anonymous cache block, per-cell string values) and enable the round trip assertions for the DXF format on every version. The DWG half stays unasserted for now: the DWG writer does not restore the cell contents of this synthetic table yet, and DXF writing is the scope of the accompanying change.
…ity-write # Conflicts: # src/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs
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.
Resolves #1001
Related: #1085, #1217, #1324 (round-trip and table writing context)
Write TableEntity (ACAD_TABLE) to DXFDescription
The DXF writer currently drops
TableEntityon purpose:DxfSectionWriterBase.isEntitySupportedlists it under "Entity type not implemented", soevery DXF export silently loses tables (a notification is raised, the entity is skipped).
The DXF reader already implements the full
AcDbTablegrammar(
readTableEntityinDxfSectionReaderBase), and the DWG writer already writes tables, sothe DXF writer is the missing half.
What this PR does
Removes
TableEntityfrom the "not implemented" exclusion list inisEntitySupported.Adds a
case TableEntitybranch towriteEntity(placed beforecase Insert,since a
TableEntityis-anInsertand would otherwise be caught by the insert branch).Implements
writeTableEntity/writeTableCell, emitting the layout real AutoCAD filesuse (verified against
samples/sample_AC1032_ascii.dxf) and thatreadTableEntityconsumes:
The
ACAD_TABLEclass entry lands in the CLASSES section automatically:TableEntityalready implementsIDxfClassDefinedandCadWriterBase.UpdateDxfClassespicks it up.
Scope notes (what is intentionally not in this PR)
63/64/275..279/65..68) are not written yet: the entity reader's border-code mappingdiffers from the DXF reference (
279→Top, 275→Right, 276→Bottom, 278→Left), so writingthem today would round-trip into scrambled borders. Aligning the reader with the
reference should come first; the writer can then emit the block.
TABLECONTENTobject (343) are not written;CadTableEntityTemplatecollects the343handle but never uses it, so nothing is lost for the ACadSharp object model.Cell.MergedValueand break data are not written.WriterSingleObjectTests.SingleTableEntitycaseis round-tripped through DWG, the cell contents do not survive (pre-existing behavior,
the case asserted nothing before this PR); the DXF half of that case is now asserted on
every version.
Tests
src/ACadSharp.Tests/IO/TableEntityDxfWriteTests.cs(new file, 2 theories xAC1027/AC1032):
WriteReadTableEntityAscii/WriteReadTableEntityBinary. Each builds asynthetic document with an anonymous block
*T1, a table style reference, a 2x3 grid andper-cell string values (
R0C0..R1C2), writes the DXF (ASCII or binary) and asserts theround trip: exactly one
TableEntityin model space,Blockresolved, 2 rows / 3columns, and the corner cell texts
R0C0/R1C2intact. All 4 cases are red onmaster("The collection was empty" — the entity is skipped by the writer) and greenwith the change.
WriterSingleObjectTests.SingleTableEntity(the roundtrip case suggested by thecontributing guide): filled in with a valid 2x3 table and real assertions for the DXF
format on every version (
1e12f19); previously it built an invalid table and itsassertions were disabled by a TODO. The DXF assertions pass on all six versions
(AC1015..AC1032).
Full suite (
ACadSharp.Tests, net9.0, Release): 2496 tests — 2493 passed, 1–2 pre-existing(flaky) failures, 2 skipped. They fail identically on unmodified
master(
Tables.DimensionStyleTests.GetLinearMeasurementText— decimal-comparator culture issue;CadDocumentTests.AddCadObjectStressTest— intermittent, passed in this run). No newfailures. During bring-up
the writer also gained a guard for cell contents with no value (
CadValue.Value == null,common in empty cells of real files), without which re-writing the bundled samples
crashed.
AutoCAD compatibility
This PR is verified with an ACadSharp writer/reader round trip. Opening the produced file
in AutoCAD (and AUDIT) still needs a real AutoCAD run — the known table-style AUDIT issue
of freshly created documents (see the accompanying TABLESTYLE structure issue) applies to
any file written from a
new CadDocument()and is independent of this change.AI development
This change was developed with AI assistance under human supervision; the submitter
self-reviewed the diff, verified group codes against the repository samples and the
readTableEntity grammar, and ran the full test suite.