Skip to content

feat(modeling): polygonize linked STL slice contour - #5

Merged
Brutich merged 2 commits into
mainfrom
codex/polygonize-linked-stl-contour
Aug 27, 2026
Merged

Brutich merged 2 commits into
mainfrom
codex/polygonize-linked-stl-contour

Conversation

@Brutich

@Brutich Brutich commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #4.

What changed and why

The saved script now preserves the actual triangle-section segments instead of inferring an outline from a point-cloud concave hull. It snaps and deduplicates segment endpoints, nodes/dissolves the section network, polygonizes closed rings, heals bounded gaps between separate STL solids with an outward/inward buffer, and creates the largest exterior shell as Revit model lines.

The existing script and documentation paths remain unchanged so saved BIMO presets can continue to reference them.

Scope and intentional exclusions

Included:

  • replace ConcaveHull with NetTopologySuite segment union and Polygonizer;
  • add independent gap_healing_mm (250 mm default) and topology-preserving simplification (50 mm default) parameters;
  • allow gap healing and simplification to be disabled with 0;
  • expose segment, polygonizer, healed-shell, and final-shell diagnostics in OUT;
  • use the active document from __uidoc__.Document and keep the model write in one rollback-safe transaction;
  • update catalog.json and the paired guide with tuning guidance and prototype evidence;
  • add a durable decision record with evaluated alternatives, the gap-healing sweep, confidence boundaries, IronPython/Revit API traps, and remaining experiments;
  • route future agents to decision records from AGENTS.md without storing chat transcripts or unfiltered reasoning.

Excluded:

  • all-level batch processing;
  • courtyards, holes, and detached exterior contours;
  • automatic dependency installation;
  • changing or deleting existing model elements.

User impact

With the defaults, the script slices the selected linked STL at L3 + 1500 mm, uses a 25 mm endpoint grid, heals polygon fragments by 250 mm, simplifies by 50 mm, and creates the largest exterior shell as model lines. IN[3] and IN[4] can now be tuned independently to distinguish gap-healing effects from simplification discrepancies.

The script may create one cyan line subcategory, one horizontal SketchPlane, and one closed model-line chain in a single transaction. It does not modify the link or source STL.

Validation performed

  • python tools/validate_catalog.py — passed for 6 scripts.
  • git diff --check — passed.
  • The underlying approach was exercised through BIMO MCP in Revit 2024 on the current L3 + 1500 mm slice: 49 meshes, 7,264,272 triangles, 12,275 raw segments, 9,861 unique snapped segments, 997 polygonized fragments, 13 dangles, no cut edges, and no invalid rings.
  • With 250 mm gap healing and 50 mm simplification, the prototype created 179 model lines; the exterior-shell area changed from approximately 572.873 m² after healing to 573.418 m² after simplification. The result was visually reviewed against the linked building mesh.

The exact generalized repository file has not been executed as-is in Revit, so revit.tested remains empty.

Risks, limitations, and remaining checks

  • the 250 mm healing default is model-dependent and can bridge intended recesses or round corners;
  • default NetTopologySuite buffer joins can cause local rounding independently of simplification;
  • only the largest exterior shell is emitted; holes, courtyards, and detached contours are omitted;
  • large meshes still require a full triangle scan and may take tens of seconds;
  • run the exact catalog file in a disposable Revit 2024 model, verify selection handling and dependency loading, compare IN[4] = 50 with 25, 10, and 0, then verify undo removes all created elements.

Documentation impact

The paired guide and machine-readable catalog now describe polygonization, gap healing, tuning order, output diagnostics, model/file-system side effects, prototype validation, and the remaining exact-script Revit test. Decision record docs/decisions/0001-linked-stl-slice-contour.md is the long-lived source for alternatives, measurements, accepted reasoning, implementation traps, and future experiments; AGENTS.md and the script guide link to it.

@Brutich
Brutich marked this pull request as ready for review August 27, 2026 23:03
@Brutich
Brutich merged commit 062d3ad into main Aug 27, 2026
1 check passed
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.

Replace linked STL concave hull with polygonized section contour

1 participant