Skip to content

DWG reader: keep plot style, plot view and xref block handles - #1284

Open
jarrett-meyer wants to merge 1 commit into
DomCR:masterfrom
jarrett-meyer:feature/dwg-reader-plotstyle-handles-only
Open

jarrett-meyer wants to merge 1 commit into
DomCR:masterfrom
jarrett-meyer:feature/dwg-reader-plotstyle-handles-only

Conversation

@jarrett-meyer

Copy link
Copy Markdown

The DWG reader reads several handles and then throws them away. This PR keeps them on the model so callers can use them, for example to plot drawings with named plot styles. Split out of #1272 as requested.

  • Entity plot style. readCommonEntityData read the plot style flags (BB) and the plot style handle and discarded both. They are now in Entity.PlotStyleFlags (0 = by layer, 1 = by block, 3 = handle present) and Entity.PlotStyleHandle. The handle points to an entry of the ACAD_PLOTSTYLENAME dictionary.
  • Layer plot style. CadLayerTemplate had the build of PlotStyleHandle commented out, so Layer.PlotStyleName was always 0 for DWG files. It is now set from the handle, as the DXF reader already does with code 390.
  • Layer xref block. The handle read into CadLayerTemplate.LayerControlHandle is the external reference block handle (the existing TODO pointed this out), and nothing used that property. It is now exposed as Layer.XrefBlockHandle, and the unused template property is removed. This gives a reliable link from an xref-dependent layer to its xref block, even when the XREF| prefix of the layer name is stale.
  • Plot settings view. The R2004+ plot view handle was read into a local variable. It is now PlotSettings.PlotViewHandle.

These are exposed as raw handles, like the existing Layer.PlotStyleName, because the plot style name entries have no model class yet. I can change them to resolved objects if you prefer.

Tests

The full ACadSharp.Tests suite passes on net9.0 (2432 passed, 2 skipped). I did not add tests: the writer does not produce named plot styles or xref-dependent layers, so a meaningful synthetic DWG cannot be created for these paths. They were checked against real drawings that I cannot share.

🤖 Generated with Claude Code

The DWG reader read these handles and discarded them:
- entity plot style flags and plot style handle (named plot styles),
  now Entity.PlotStyleFlags and Entity.PlotStyleHandle;
- layer plot style handle, now set to Layer.PlotStyleName as the DXF
  reader already does;
- layer external reference block handle, which was stored in an unused
  LayerControlHandle template property, now Layer.XrefBlockHandle;
- plot settings plot view handle, now PlotSettings.PlotViewHandle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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