Skip to content

Read the surface entity family as modeler geometry - #1155

Merged
DomCR merged 6 commits into
DomCR:masterfrom
ilCosmico:feature/surface-entities-read
Oct 8, 2026
Merged

DomCR merged 6 commits into
DomCR:masterfrom
ilCosmico:feature/surface-entities-read

Conversation

@ilCosmico

Copy link
Copy Markdown
Contributor

This adds read support for the surface entities: SURFACE, PLANESURFACE, EXTRUDEDSURFACE, LOFTEDSURFACE, REVOLVEDSURFACE, SWEPTSURFACE and NURBSURFACE. Until now the DWG reader turned them into UnknownEntity and the DXF reader discarded them, so their ACIS payload was lost.

The new classes derive from ModelerGeometry, and that is most of the trick: the payload extraction already in place works unchanged. Pre-2013 files carry the payload in the entity itself, 2013+ files in the AcDs data section (DWG) or ACDSDATA (DXF), and both attach points are generic over ModelerGeometry.

In detail:

  • Surface carries the U/V isoline counts, one class per derived type, mapped by DXF name and subclass marker.
  • DWG: the surface types are routed in readUnlistedType to a reader that consumes the AcDbModelerGeometry common data. The subclass tails (sweep, loft and revolve parameters) are not decoded yet; the object data is length delimited, so the unread tail is skipped safely.
  • DXF: the surface types go through readEntity with the modeler geometry template, so codes 1/3 accumulate the SAT text and the subclass codes resolve through the map of the subclass being read.
  • Tests: in-memory DXF cases for the seven types, plus two DWG samples with loose extruded sheets (samples/surfaces), one saved as 2010 with the payload embedded in the entity and one as 2013 with the payload in the AcDs section.

The write side is out of scope here: today a Brep is always written as 3DSOLID, and the surface subclass fields are not decoded yet. Both are planned as a follow-up, the same read-first sequence used for the ACIS payload extraction.

@ilCosmico

Copy link
Copy Markdown
Contributor Author

Rebased on current master (3.6.51). Beyond the rebase the only change is in the surface read test: on R2013+ it now takes the ACIS payload from DataStorage by handle, since #1154 no longer populates AcisData there. The reader code is untouched, and the build and the surface tests are green on the new master.

@ilCosmico

ilCosmico commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi @DomCR, a gentle nudge on this one whenever you have a moment. It is additive: the surface entity classes plus two hooks in the readers. It does not touch the Prototype1b or ACDS code you are reworking in #1174, so it should stay out of the way of that refactor, and CI is green with the branch still merging cleanly.

On my side this is the last piece missing to read the surface family, so it would close the reading work.

@ilCosmico

Copy link
Copy Markdown
Contributor Author

Hi @DomCR, just a line to say that this one still merges cleanly on today's master, after all the movement of the last two weeks, so looking at it should not cost you any rebase work. If you would rather have it split into smaller pieces or reshaped in some way, tell me and I will do that.

@DomCR

DomCR commented Sep 29, 2026

Copy link
Copy Markdown
Owner

Hi @ilCosmico,

The implementation looks good, I've taken the dwg files, you can remove them, I'll save them in the dxf format too to have the dxf test, so the specific tests can be removed.

Before this one can be merged you need to modify the methods IsSupported in the writers so it doesn't throw and exception when writing the file.

Good work! sorry for the delayed review.

Comment thread src/ACadSharp/Entities/Surface.cs
Comment thread src/ACadSharp/Entities/Surface.cs Outdated
@ilCosmico
ilCosmico force-pushed the feature/surface-entities-read branch from e6e3603 to 8beb660 Compare September 30, 2026 09:08
@ilCosmico

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Updated and rebased on master:

  • The two DWG samples and the test that used them are out of the branch history, so they won't land in master. I kept DxfSurfaceTests, which builds its DXF in memory; tell me if you want that one out too.
  • The DWG and DXF writers now skip the surface entities with the not implemented notification instead of throwing.
  • File-scoped namespaces in all the new files.
  • I left Surface concrete: AutoCAD files contain plain SURFACE entities, the two samples you took included, so the reader needs to create it directly.
  • The surface entities implement IDxfClassDefined, with the values from the CLASSES section of AutoCAD files. NURBSURFACE is the exception: I have no file with one, so it uses the same flags as PLANESURFACE. If you have a sample, I'll check it.

Comment thread src/ACadSharp.Tests/IO/DXF/DxfSurfaceTests.cs Outdated
Comment thread src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs Outdated
@DomCR DomCR added bug Something isn't working feature New feature added and removed bug Something isn't working labels Oct 8, 2026
@DomCR
DomCR merged commit 0cca901 into DomCR:master Oct 8, 2026
7 checks passed
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