Skip to content

3D solids on solidcore (replaces #20) - #22

Merged
withshalom merged 21 commits into
mainfrom
solids-21
Nov 16, 2026
Merged

withshalom merged 21 commits into
mainfrom
solids-21

Conversation

@withshalom

Copy link
Copy Markdown
Member

3D solids on solidcore (replaces #20)

This PR replaces #20. It carries SkryxDev's 18 commits from #20 unchanged (head 724a289) and adds the fixes and pieces that #20 was still missing. It merges cleanly into main (3b6e91c). Everything stays behind the cargo feature solids; without it the build, the tests and the wasm check are exactly what they are on main.

Why a replacement

  • 3D solids with solidcore, and a 3D Modeling workspace laid out as on Windows #20's CI fails in gate-solids: roundtrip::dwg::extended::regions. Commit b387fa9 saves regions as AutoCAD REGIONs (ACIS), and reading them back recomputes each arc's bulge from angles: a bulge of 0.5 comes back as 0.4999999999999999. The round-trip comparator compared regions with exact equality, even though its own rule elsewhere says converted angles allow floating-point roundoff.

  • The failure hid the rest of the suite. nextest stops at the first failure, so CI ran 2,861 of 3,842 tests. DIMSCALE / DIMSTYLE #21 was checked with the whole suite (results under Gates below).

  • Two gaps the review didn't catch:

    • a solid's colour, linetype and lineweight were lost on save;
    • every AutoCAD solid was re-described on save, so AutoCAD's own ACIS was lost even when nothing was edited.

    Both are fixed here.

What this PR adds on top of #20

1. CI fix: regions compare their bulges as converted angles (d03de31)

The round-trip comparator gets a Region arm. It compares loop count, outer/island flags, sources, vertex count, positions and widths exactly, and bulges with the same angle tolerance (8 ε) it already uses for every other converted angle. This applies the comparator's existing rule to regions rather than loosening it. All 348 round-trip tests pass with solids.

2. AutoCAD's own ACIS is kept for unedited solids, bodies and regions (6b92c47)

The problem. #20 turns every AutoCAD 3DSOLID, BODY and REGION into a DraftCraft solid or region on open, and drops the original. On save it writes DraftCraft's translation instead (SAT 400 or SAB 700). A drawing opened and saved without any edit therefore lost everything ACIS describes and DraftCraft doesn't model:

  • the ACIS version (AutoCAD 2010 writes ShapeManager 21500, not 400);
  • the solid's history link;
  • face colours and other attributes;
  • surfaces as their modeller defined them.

That works against the handoff's own goals (A5, A8, A9, A14).

The fix.

  • On open: the entity's groups and its SAB record move into Foreign::acis, an AcisSource keyed by handle that also records what the entity was read as. Foreign is the codebase's existing home for "everything of a file DraftCraft keeps without modelling it", and it already holds the data store.

  • On save: AutoCAD's description is written back when all of these hold:

    • the entity is unchanged (same body and placement, or the same region);
    • its handle is the same, so a copy never inherits another solid's history;
    • the target uses the same storage form (SAT in the entity up to 2010, SAB in the data store from 2013);
    • the target version is the source version or newer, since an older AutoCAD discards a newer ACIS description.

    Otherwise DraftCraft's translation is written, as before.

  • 2000/2004 into 2007+: a 2000/2004 solid saved into a 2007+ file gets the AcDb3dSolid marker that as_3dsolid writes.

Why this design: no change to Solid3d or Region (they're built in 20+ places), no flag that every editing command would have to clear, and no way for a stale description to be written for an edited solid. Edits are detected, not trusted.

Result, measured on the AutoCAD 2027 drawings in crates/io/tests/data/acad-solids/:

  • Opened and saved in the same version, every solid and region comes back with AutoCAD's exact SAT text or SAB bytes: basic, edited and free-form solids; regions; DXF and DWG; 2000, 2010, 2013 and 2018.
  • 2000 → 2010 and 2013 → 2018 also keep AutoCAD's data.
  • From DXF, the history link (350) survives, pointing at the kept history object under its new handle. The DWG reader doesn't read that link yet.
  • Moved and copied solids get a new description, as does a 2018 solid saved down to 2010.

3. Solids and regions keep their properties on save (6b92c47)

The bug in #20. A 3DSOLID, BODY or REGION is written from its own groups, and for_saving gave them only the modeler data. In DXF and DWG, every version, a solid or region lost its:

  • colour, including true colour;
  • linetype and linetype scale;
  • lineweight;
  • visibility;
  • transparency.

A red 0.50 mm solid came back ByLayer/ByLayer. This affected solids made in DraftCraft and solids read from AutoCAD.

The fix. The property groups come from the entity, through the same writer code every other entity uses: entity_props, pulled out of common_full and exposed as dxf_write::property_groups.

Tests added

Test Proves
an_unedited_autocad_solid_or_region_saves_as_autocad_wrote_it 14 file/version pairs (DXF and DWG, 2000 to 2018, solids and regions): AutoCAD's ACIS comes back byte-for-byte, and its modeler groups too in the same version
an_edited_copied_or_down_saved_solid_gets_a_new_description a moved solid, a copy and a down-save get DraftCraft's description; the others keep AutoCAD's; the volumes and centroids still match AutoCAD's MASSPROP
solids_and_regions_keep_their_properties colour, lineweight, transparency and linetype scale survive DXF and DWG 2000/2010/2018 (transparency in DWG from 2004, as the format allows), for new solids and regions and for AutoCAD's, and changing an AutoCAD solid's properties keeps its ACIS

Decisions: whose method where

We had our own fixes for the #20 review on a local branch. Where #20's fix does the same job as well, #20's stays, because swapping equivalent code would be churn. Ours goes in only where #20 had nothing, or where ours tested better.

Area #20 (SkryxDev) Ours In #21 Why
Commands that change several entities at once Session::all_or_nothing CommandSpec::atomic flag #20's Same guarantee (a failure leaves the drawing as it was); ours is a cleaner declaration but not worth the churn
Typed Z for 3D points Session::point_z, prompt::typed_z Input::Point3, Prompt::point3 #20's Equivalent at the command line; can be revisited when 3D picking lands
Saving solids ACIS writer, interim mesh form as fallback file form v2 as a block reference #20's AutoCAD's own 3DSOLID beats any DraftCraft form; the interim form is now a rare fallback (ACIS covers planes, analytic surfaces and NURBS)
Solids inside blocks, paint cache, gate-solids CI job yes similar #20's Done and tested
AutoCAD's ACIS for unedited solids re-described on every save kept and written back ours (new) Keeps history, attributes and ACIS version; see section 2
A solid's colour and other properties on save lost written from the entity ours (new) Bug fix; see section 3
Kernel panics on the web (handoff I1) look for a panic-free kernel run the kernel in a Web Worker that is replaced when it dies ours, future PR See below

How well solidcore handles the 3D

Judged on what the tests and AutoCAD's drawings show, not on claims.

Strong

  • Real B-rep modelling that builds for wasm32 with no unsafe:
    • primitives;
    • extrude and revolve;
    • booleans;
    • fillet and chamfer edges;
    • shell;
    • slice.
  • Volumes and centroids of AutoCAD's primitives match MASSPROP to its four printed decimals.
  • AutoCAD's edited solids (SUBTRACT, FILLETEDGE, CHAMFEREDGE) and free-form ones (LOFT, SWEEP along a helix) open as solids.
  • The ACIS round trip through STEP covers planes, cylinders, cones, spheres, tori and NURBS.
  • solidcore is actively maintained upstream (blend and boolean fixes in the pinned revision ce5c6e95).

Weak, and handled around it

  • A panic on wasm aborts the page. The session's panic guard only works natively. This is the one real risk for the browser build; the Web Worker host addresses it (future PR).
  • NURBS trims. solidcore has no exact pcurve of a spline edge on a spline surface, so the reader hands it ACIS's own.
  • What isn't read yet stays as AutoCAD saved it, never lost:
    • several lumps in one solid (handoff A3);
    • mirrored ACIS transforms (A4);
    • regions off the XY plane or with spline edges (A6).

Verdict: a sound base for 3D on the desktop today. The browser needs the worker before solids are turned on there.

Web (handoff I1): a future PR

Our answer to I1 is not a panic-free kernel. It's the kernel behind a message boundary: on the web, solidcore runs in a Web Worker, a kernel panic takes down only that worker, and the host replaces it for the next call.

  • solidcore side: written, not yet published. The solidcore-worker crate in our solidcore checkout (branch wasm-worker-host, about 1,100 lines) has:

    • the protocol, with bodies as .smb bytes checked on reading;
    • a stateless executor;
    • a platform-neutral host that fails a dead worker's calls with WorkerDied and replaces the worker;
    • the wasm32 Web Worker transport.

    It belongs in a solidcore PR, not here.

  • DraftCraft side: not written yet. On the web, solid commands would have to send their kernel calls through that host instead of calling solidcore directly.

That work is a PR of its own after this one, so it isn't in #21.

handoff.md against this PR

  • A8 (history) and A9 (face colours, materials): for unedited solids, the minimum is done here. AutoCAD's history link and ACIS attributes survive a round trip. Editing them is still to do.
  • A14 (round-trip report): the tests above are the round-trip evidence for solids and regions.
  • Next, in the handoff's order: A4 (mirrored ACIS transforms), A2 (SAB in DWG 2004 to 2010), A3 (several lumps).
  • A12 (legacy 3D entities flattened in the 3D view): best solved by the shared Craft viewport, a separate PR.

Still to check in AutoCAD

  • Open in AutoCAD 2027 the DXF and DWG files DIMSCALE / DIMSTYLE #21 writes from acad-solids with unedited solids:

    • same version;
    • 2000 → 2010 DXF, which adds the AcDb3dSolid marker.

    The ACIS is AutoCAD's own, so the risk is low, but it hasn't been seen in AutoCAD.

  • A coloured solid and region saved by DraftCraft: check that colour, lineweight and transparency show in AutoCAD.

  • From 3D solids with solidcore, and a 3D Modeling workspace laid out as on Windows #20, still open: NURBS faces written to ACIS (handoff A1). write_files_for_autocad (ignored test) writes the files for that check.

Gates

  • cargo xtask ci and cargo xtask ci --solids: running in GitHub Actions on this PR (local runs were cut short to push).

🤖 Generated with Claude Code

SkryxDev and others added 21 commits November 14, 2026 18:28
…ture kernel)

SolidCraft's kernel and geom crates as git dependencies pinned to withshalom/solidcraft
d11d268 (v0.27.0), with its truck patches repeated in the root manifest. Only
draftcraft-solid names them; cargo xtask layers enforces it. Without its kernel feature
the crate is empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…DE, REVOLVE, booleans, SLICE, FILLETEDGE, CHAMFEREDGE, SOLIDEDIT shell, INTERFERE, MASSPROP, FLATSHOT, SECTION)

Behind the engine feature `solids`; without it nothing changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…extension dictionary record, reopened as solids

DXF and DWG keep a DraftCraft solid as a polyface mesh every program can see, and an XRECORD
DRAFTCRAFT_SOLID in its extension dictionary with the body, placement and counts. With the io
feature `solids` the reader turns the mesh back into the solid (the engine redraws it from the
body); without it the mesh and its record are kept as they are. The save says so on the command
line. The `solids` feature reaches ui-egui, mcp and the three apps.

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…with wireframe, hidden and shaded styles

The engine keeps a 3D view per drawing (direction, framing, visual style); the commands change
the view, never the drawing. The drawing area paints it with egui's painter: faces back to
front, edges and silhouettes tested against the faces in front of them. The wheel zooms, the
middle button pans, Shift+middle (or the left button in 3DORBIT) orbits; clicks pick solids and
points on the XY plane. A View panel on the 3D Modeling tab. Without the solids feature
3DORBIT still says not available yet.

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

The kernel is now solidcore (tangency-labs/solidcore ce5c6e9, Apache-2.0), replacing
SolidCraft's truck-based kernel at the owner's request. The facade's API is unchanged:
- draftcraft-solid names solidcore-ops, -record and -tess; bodies are solidcore .smb behind
  the DCSMB001 magic, canonical so a reopened solid keeps its bytes.
- Hidden-line projection (FLATSHOT, views) is DraftCraft's own: exact edges projected,
  silhouettes from the mesh, visibility sampled against binned triangles.
- SOLIDEDIT shell passes solidcore's outward thickness negated; MASSPROP reports moments and
  products of inertia and radii of gyration.
- NOTICE and ATTRIBUTION carry solidcore's row and NVIDIA's SMLib notice.

The 3D UI follows the structure of AutoCAD's 3D Modeling workspace (structure only; every
icon drawn in code):
- Built-in workspaces 2D Drafting and 3D Modeling, switched from the Quick Access Toolbar,
  the status bar's Workspace Switching menu or WSCURRENT. In 3D Modeling the ribbon has its own
  Home (Modeling, Solid Editing, Draw, Modify, Section, View, Layers), Solid (Primitive,
  Solid, Boolean, Solid Editing, Section) and Visualize (Views, Visual Styles) tabs.
- Preset commands vpoint.top … vpoint.nwiso and vscurrent.2dwireframe … vscurrent.xray.
- In the 3D view: viewport controls [-][view][style], each a menu, and a 3D ViewCube that
  turns with the view, with 26 clickable spots, drag to orbit, Home, compass ring and a
  right-click menu; and a navigation bar (Zoom Extents, In, Out, Orbit).
- Italian and Chinese labels for the new strings.

xtask: `cargo xtask ci --solids` runs clippy and tests with the feature on, plus a wasm32
check of the kernel. docs/solids.md keeps the status, measurements and the advisory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd solids save as 3DSOLIDs

- crates/solid/src/acis: reads ACIS SAT/SAB in any dialect AutoCAD writes (through cadmpeg-asm)
  and writes ACIS 700 SAT and SAB, both by way of STEP with solidcore.
- crates/io/src/solid_acis: adopts 3DSOLIDs on open and writes them for every version (SAT in
  groups 1/3 up to 2010, a data store record of SAB from 2013); AutoCAD reference drawings in
  crates/io/tests/data/acad-solids with tests that compare against AutoCAD's MASSPROP.

Fixes from opening DraftCraft's files in AutoCAD 2027:
- DXF: a 3DSOLID (and any unknown entity read from DWG) now carries 100 AcDbEntity before its
  layer; without it AutoCAD refused the whole file.
- A cone's apex is written as a loop of one point edge, as AutoCAD does; without it AutoCAD
  called the cone an invalid solid with no volume.
- DWG 2000-2010: the SAT lines end with a line feed alone, as in AutoCAD's own files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The state of the AutoCAD check (SAT in DWG 2000/2010 still rejected with 75003), the gaps in file
compatibility, commands, 3D interaction, visualization and the web build, and the order to take them in.

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

AutoCAD 2027 discarded every solid DraftCraft wrote into a DWG 2000 or 2010 file (error 75003,
eCannotRestoreFromAcisFile), though it took the same SAT 700 text from DXF. AutoCAD's own DWG 2000
holds SAT 400, and its 3DSOLID container matches ours. SAT is now save format 400: no history fields
after an entity's attribute, no parameters or convexity on an edge, and a header that counts the
records. SAB stays 700 for the data store of 2013 and later.

Tests: sat_text_looks_like_acis_400, a_cone_apex_is_a_point_edge_loop (400 layout), and a check in
solids_save_as_autocad_3dsolids_in_every_version that every SAT for 2000 to 2010 is version 400.
Not yet checked in AutoCAD; handoff.md lists the check files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ACIS's own pcurves go to the kernel on spline faces, resampled onto the
kernel's edge parameter where it differs; a procedural helix becomes a
cubic spline; a closed circle edge starts exactly at its circle's angle 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The side face of a sweep closes on itself through a seam edge, whose two coedges carry ACIS
pcurves a period apart. The kernel's closed-form pcurve of the seam, worked out once for the
edge, put both uses on one side, and the face kept a sliver of its domain: the solid read with
the inner half of its tube only (volume 887). ACIS's own pcurves now come first.

The free-form test checks both solids against AutoCAD's MASSPROP: the loft 175685.13 about
z 36.27, the sweep 44855.46 about (150, 0, 40), read 44851.57 (the helix as a spline).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…m solids read

- Writer: spline-surface (exactsur), intcurve (exactcur) and an exppc pcurve on
  every coedge of a spline face, laid out as AutoCAD 2000 writes its LOFT and
  SWEEP in SAT 400; SAB stays save format 700 with full subtype names and the
  later formats' tails.
- Reader: SAT 400's exppc pcurves and parameterless circle edges; parcur rails,
  ASM-text procedural surfaces (loft_spl_sur, sweep_sur) and helices filled in
  from the records where cadmpeg-asm only reads them word by word.
- Tests: AutoCAD's loft and sweep from DXF 2000, DXF 2010 and DWG 2018 against
  MASSPROP; both written back as SAT and SAB and read again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…27 check passes

A SAT whose header gives no record count needs its end-of-data line. With SAT 700 and the line
dropped, AutoCAD 2027 discarded every solid of a DWG 2000 or 2010 file (error 75003).

Checked in AutoCAD 2027 with SAT 400 and the line kept. DraftCraft's DWG and DXF files in versions
2000, 2010, 2013 and 2018 open, and so do AutoCAD's own solids saved again by DraftCraft (DWG 2018,
DXF 2000). AUDIT finds 0 errors, SOLIDEDIT calls every solid valid, and MASSPROP matches to four
decimals: 8/8 per file, 6/6 for the resaved ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The interim form records each mesh's fingerprint (MARK "DraftCraft solid 2"):
  a mesh edited elsewhere stays a mesh, a missing part takes no other mesh, a
  mirrored solid's mesh faces out; interim solids open with their body's exact look.
- SLICE, SECTION and picking go along the line of sight and take typed Z.
- SLICE, SHELL, SWEEP, FLATSHOT and region booleans are all-or-nothing.
- INTERFERE skips far-apart solids and scales volumes by the placement.
- 3D view: solids in blocks, mirrored solids, off-screen occluders, paint cache.
- Workspaces: a saved "3D Modeling" is not hidden; greyed out without solids.
- CI: a gate job with solids; the web app no longer takes the solids feature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- REGION: ACIS sheet bodies read into regions (XY plane, lines and arcs) and
  regions written as REGION (SAT 400 / SAB 700, double-sided plane faces, one
  lump per outer loop with its holes). AutoCAD 2027's own regions open with its
  MASSPROP; DraftCraft's open in AutoCAD as REGIONs, AUDIT clean, EXTRUDE works.
- BODY: a BODY holding a solid opens as a solid and is saved as a BODY again.
- Region MASSPROP is exact on arcs (circular segments), equal to AutoCAD's.
- AutoCAD REGION test drawings (DXF 2000/2010/2018, DWG 2000/2013/2018).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…not $CTABLESTYLE

AutoCAD's DXF has no $CTABLESTYLE header variable (AutoCAD reports it as unknown): it keeps the
current table style as a DICTIONARYVAR of the AcDbVariableDictionary. DraftCraft's DXF now
writes that dictionary (and its DICTIONARYVAR class) as its DWG already did, and no longer
writes $CTABLESTYLE; $HANDSEED is raised above the dictionary's handles.

The dictionary is now modelled rather than kept raw: the DXF and DWG readers take it into
Drawing::variables (with the current table style), and both writers save it again with the
drawing's own current table style, so a style made current after opening is not lost to a
stale kept copy. $CTABLESTYLE in older files' headers is still read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…compared with AutoCAD

Checked against the code at afccf04: what already works, how to work (gates, the command
checklist, AutoCAD checks), and every missing piece by area (file compatibility, modelling
commands, 3D transforms, sub-objects, UCS and the 3D environment, sections and drawing views,
visualization, surfaces and meshes, platform), with the kernel functions that exist for each
and the order to do them in. docs/solids.md points to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With solids, a region is saved as AutoCAD's REGION (ACIS): an arc is a circle and its two ends, and its bulge comes back through the arc's angles (tan of a quarter of the sweep), so 0.5 may read as 0.4999999999999999. The comparator already allows converted angles their roundoff; a region's loops are now compared field by field with the bulges as such, the points and loops exact. This was the one failure of the gate with solids (roundtrip::dwg::extended::regions).

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

Saving wrote every solid and region as a new ACIS description, so a
drawing from AutoCAD lost what DraftCraft doesn't model (the solid's
history, face colours and attributes, the ACIS version) on any save,
edited or not. Opening now moves AutoCAD's entity groups and SAB to
Foreign::acis (an AcisSource by handle, with the entity as read), and
saving writes them back while the entity is unchanged and the file
holds them as they are: same form (SAT to 2010, SAB from 2013), a
version no older than the source. An edited, copied or down-saved
solid gets a new description, as before.

A 3DSOLID, BODY or REGION is written from its groups, and those held
only the modeler data: colour, linetype, lineweight, linetype scale,
visibility and transparency were lost in DXF and DWG, every version.
The property groups now come from the entity, through the writer's own
code (entity_props, shared with every other entity).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@withshalom
withshalom merged commit 0c956e9 into main Nov 16, 2026
2 checks passed
withshalom added a commit that referenced this pull request Nov 18, 2026
Status review of DraftCraft 3D (PRs #22/#23, handoff, SolidCore/SolidCraft forks), completeness vs the AutoCAD-3D goal, and a prioritised plan. Signed Chromie.
withshalom added a commit that referenced this pull request Nov 18, 2026
… releasable

3D (PRs #22 and #23, 3D-dev-state.MD) now lives on the 3D branch until it is finished. All DWG work stays on main, ACIS in DWG included. Backup of main before this merge: backup-11-18-2026 (1506ce6).
withshalom pushed a commit that referenced this pull request Nov 18, 2026
…(3D solids on solidcore)"

The 3D branch gets main after PR #26 with the 3D work put back, so that
later merges of main into 3D keep it. This reverts commit ee840fe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F67RssNr67uM2HRS3vdet4
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.

2 participants