Skip to content

Read dimension object context data from DWG and DXF - #1272

Open
jarrett-meyer wants to merge 4 commits into
DomCR:masterfrom
jarrett-meyer:feature/dwg-reader-plotstyle-handles
Open

jarrett-meyer wants to merge 4 commits into
DomCR:masterfrom
jarrett-meyer:feature/dwg-reader-plotstyle-handles

Conversation

@jarrett-meyer

@jarrett-meyer jarrett-meyer commented Oct 6, 2026 •

Copy link
Copy Markdown

Annotative dimensions have one ACDB_*DIMOBJECTCONTEXTDATA_CLASS object per annotation scale. Each one points to the anonymous block with the dimension graphics for that scale, and stores the text and arrow placement for that scale. These objects were read as UnknownNonGraphicalObject, so the per-scale blocks and data could not be used.

This PR adds the dimension object context data classes and reads them from DWG and DXF.

Model

  • DimensionObjectContextData : AnnotScaleObjectContextData (abstract) with Block, TextLocation, TextRotation, TextMovement, DimensionTextArrowFit, IsDefaultTextLocation, the arrow flip flags, the text inside/outside extension flags, and OverrideFlags.
  • One subclass per dimension type, with its own points:
    • AlignedDimensionObjectContextData (ACDB_ALDIMOBJECTCONTEXTDATA_CLASS): DimensionLinePoint
    • AngularDimensionObjectContextData (ACDB_ANGDIMOBJECTCONTEXTDATA_CLASS): ArcPoint
    • DiametricDimensionObjectContextData (ACDB_DMDIMOBJECTCONTEXTDATA_CLASS): FirstArcPoint, DefinitionPoint
    • OrdinateDimensionObjectContextData (ACDB_ORDDIMOBJECTCONTEXTDATA_CLASS): DefinitionPoint, LeaderEndpoint
    • RadialDimensionObjectContextData (ACDB_RADIMOBJECTCONTEXTDATA_CLASS): FirstArcPoint
    • RadialDimensionLargeObjectContextData (ACDB_RADIMLGOBJECTCONTEXTDATA_CLASS): OverrideCenter, JogPoint
  • DxfFileToken and DxfSubclassMarker constants for each class.

Reading

  • DWG: the classes are dispatched through the readUnlistedType switch with the DxfFileToken constants.
  • DXF: DxfObjectsSectionReader reads the same fields.

Writing

The DWG and DXF writers skip these objects, the same way they handle other partially supported objects, so writing keeps its current behavior.

Tests

DimensionObjectContextDataTests reads a new sample, samples/annotative/annotative_dimensions_AC1032.dwg and its .dxf export:

  • DwgAndDxfMatch: the DWG and DXF readers produce the same context data.
  • ReadDwg: each dimension type gets the expected subclass, a distinct block per scale, and the expected points.
  • ReadOverrides: the per-scale overrides (text inside/outside, arrow fit, text movement, arrow flip) are read from both formats.

The sample has no data for RadialDimensionLargeObjectContextData: the jogged radial dimension is not read as an entity, so its context data is not reached.

The full ACadSharp.Tests suite passes on net9.0 (2441 passed, 2 skipped).

As requested, the other changes that were in this PR are now in separate PRs:

🤖 Generated with Claude Code

Comment thread src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs Outdated
Comment thread src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs Outdated
@DomCR DomCR added the feature New feature added label Oct 8, 2026
@jarrett-meyer
jarrett-meyer force-pushed the feature/dwg-reader-plotstyle-handles branch from 17a3d30 to 17034a5 Compare October 8, 2026 12:28
@DomCR

DomCR commented Oct 13, 2026

Copy link
Copy Markdown
Owner

For this PR please focus it on "dimension context data", the other changes should be in separated PRs, thanks.

jarrett-meyer and others added 4 commits October 13, 2026 08:27
Annotative dimensions have one ACDB_*DIMOBJECTCONTEXTDATA_CLASS object
per annotation scale, each pointing to the anonymous block with the
dimension graphics for that scale. These objects were read as unknown
non-graphical objects, so the per-scale blocks could not be found.

Add DimensionObjectContextData with the scale and the block, and read
it for every DIMOBJECTCONTEXTDATA class. Only the handles are read, not
the data fields, so both writers skip it like other partially supported
objects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Address review: dispatch through the switch with DxfFileToken
constants instead of a separate check. DWG files store the concrete
ACDB_*DIMOBJECTCONTEXTDATA_CLASS subclass names, so each is listed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DWG files store the concrete ACDB_*DIMOBJECTCONTEXTDATA_CLASS names;
there is no ACDB_DIMOBJECTCONTEXTDATA_CLASS class. Make
DimensionObjectContextData an abstract base (AcDbDimensionObjectContextData)
and add one class per type with its real DXF name and subclass marker:
aligned, angular, diametric, ordinate, radial and radial large.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Read the per-scale text location, text rotation, default text location
flag, overridden dimension variables (DIMTOFL, DIMSOXD, DIMTIX and the
override flags), arrow flips and the type-specific points of each
ACDB_*DIMOBJECTCONTEXTDATA_CLASS object, and read these objects from DXF.

The DWG bit layout was decoded from a drawing made in AutoCAD and checked
against its DXF export: text location is first, and DIMATFIT and DIMTMOVE
are stored as single override bits, so their values are only read from
DXF. The jogged radial class name is ACDB_RADIMLRGOBJECTCONTEXTDATA_CLASS
and its data extends the radial one.

Add samples/annotative with the drawing (7 annotative dimensions at 1:1
and 1:20, some with per-scale overrides) and tests comparing DWG and DXF.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jarrett-meyer
jarrett-meyer force-pushed the feature/dwg-reader-plotstyle-handles branch from 17034a5 to 23555b6 Compare October 13, 2026 13:34
@jarrett-meyer jarrett-meyer changed the title DWG reader: keep plot style, xref block and dimension context data; read RTEXT Read dimension object context data from DWG and DXF Oct 13, 2026
@jarrett-meyer

Copy link
Copy Markdown
Author

Done. This PR now only contains the dimension object context data. The other changes are in separate PRs:

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

feature New feature added

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants