FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Saikei: horizontal alignment authoring foundation for Bonsai (+ alignment API fixes) by DesertSpringsCivil · Pull Request #9304 · IfcOpenShell/IfcOpenShell · GitHub

Saikei: horizontal alignment authoring foundation for Bonsai (+ alignment API fixes) - #9304

Open
DesertSpringsCivil wants to merge 3 commits into
IfcOpenShell:v0.9.0from
DesertSpringsCivil:review/pr1-foundation
Open

Saikei: horizontal alignment authoring foundation for Bonsai (+ alignment API fixes)#9304
DesertSpringsCivil wants to merge 3 commits into
IfcOpenShell:v0.9.0from
DesertSpringsCivil:review/pr1-foundation

Conversation

Copy link
Copy Markdown
Contributor

What this is

The first of a series of PRs bringing Saikei Civil's alignment authoring to Bonsai on the v0.9.0 line. This foundation PR contains horizontal alignment authoring end-to-end, plus a set of correctness fixes to ifcopenshell.api.alignment found while building on it.

The whole review surface on existing upstream code is ~69 additive lines across 8 shared files — everything else is new files (new Bonsai module, new tool/core layers, tests). No existing behavior is modified except the six API bug fixes below and a 4-line IfcStore attribute fix.

Bonsai side (feat(bonsai), 22 files)

  • CIVIL tab in the Properties editor with a Horizontal Alignment panel (Creation, PI Editor, Stationing sub-panels) and an Alignment workspace tool
  • Create alignment by PI method: viewport picking, live interleaved PI table (Civil 3D-style point/segment rows, coordinates held as text for survey precision), radius edits regenerate curves, PI edit mode (empties + G, Enter/Esc)
  • CSV import: extends Rick's bim.import_alignment_csv stop-gap in place (same operator id) — it now builds the full object hierarchy, handles aggregated child alignments, and sets the active alignment
  • Stationing: default stationing referent on creation via align_api.create, add-referent operator, unit-aware station formatting through ifcopenshell.util.alignment.station_as_string (imperial 100+50.00 / metric 10+050.000 from the project LENGTHUNIT)
  • All IFC authoring flows through ifcopenshell.api.alignment — the Bonsai layer adds no curve math of its own
  • IfcStore: declare cache/cache_path class attributes (first get_cache() call raised AttributeError, killing the load_post handler chain in headless runs)

API side (fix(api.alignment), 15 files)

Six correctness fixes, each with a red→green regression test:

  1. _create_geometric_representation: creatIfcShapeRepresentation typo — the child-alignment vertical+cant branch was unreachable
  2. segment_vertices: segment[1] → segments[1] (Helmert curves crashed)
  3. get_mapped_segments: wrong index for a Helmert curve's second half
  4. get_stationing_nest: now prefers the STATION-referent nest instead of the first nest containing any referent (collided with key-point nests)
  5. create_as_offset_curve: honors start_station with a stationing referent (was silently ignored)
  6. "P.V.I" → "P.V.I." label consistency

Plus two helpers Bonsai needs: clear_layout_segments and segment_vertices.

Testing

Notes for maintainers

🤖 Generated with Claude Code

DesertSpringsCivil and others added 3 commits August 15, 2026 15:54
…ment_vertices helpers

Fixes found while building Bonsai alignment authoring on top of the
alignment API:

- _create_geometric_representation: typo creatIfcShapeRepresentation ->
  createIfcShapeRepresentation (crashed 3D representation of gradient
  curves).
- get_mapped_segments: off-by-one — the second mapped segment of a
  two-segment mapping returned Segments[index] instead of
  Segments[index - 1].
- get_stationing_nest: matched the first nest containing any IfcReferent;
  now requires PredefinedType == "STATION" so position referents don't
  shadow the stationing nest.
- create_as_offset_curve: offset-curve alignments never received a
  stationing referent; now establishes the stationing scheme exactly as
  create() does for start_station.
- _get_segment_start_point_label: vertical CONSTANTGRADIENT/
  CONSTANTGRADIENT label "P.V.I" -> "P.V.I.".
- segment_vertices: restored helper returning (Start, End, TI, NI)
  control points per segment — needed by any PI-based editor and gone
  from the current API surface.

New Saikei helper: clear_layout_segments — the layout functions only
append and expose no clear/remove, so editing a layout (PI recalc, edit
mode) needs a safe way to drop real segments while keeping the
zero-length terminator and cleaning up mapped geometry without orphans.

Tests included for all of the above (test/api/alignment).
- segment_vertices: pass the entity_instance to map_shape directly —
  entity_instance.wrapped_data is gone in the 0.9 modular wrapper
  (verified against a locally built 0.9 runtime with the per-schema
  geometry-mapping plugins that the official win64 artifacts omit,
  upstream IfcOpenShell#9301/IfcOpenShell#9305).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Horizontal alignment authoring for IFC 4.3 in Bonsai, following the
core/tool/UI three-layer pattern:

- PI-method authoring: create an IfcAlignment + IfcAlignmentHorizontal
  and lay out LINE/CIRCULARARC segments from PI points and radii, with
  a full Blender object hierarchy for the alignment, layouts, segments
  and referents.
- Live PI table: Civil 3D-style interleaved point/segment rows with
  editable E/N coordinates and curve radii, recalculating lengths,
  arc lengths and stations as you type.
- Viewport picking: PolylineOperator-based PI picker with snapping and
  numeric input, auto-building the IFC segments on finish; a G-key PI
  edit mode with GPU tangent-line preview regenerates segments in place.
- CSV import: merged into the single upstream operator id
  bim.import_alignment_csv, now routed through core.import_alignment_csv
  which also builds viewport hierarchies for aggregated child
  alignments and materializes generated referents.
- Stationing: basic add-stationing-referent operator plus unit-aware
  station formatting (100+50.00 imperial / 10+050.000 metric) derived
  from the project LENGTHUNIT.
- Also includes an IfcStore fix: cache/cache_path class attributes were
  set by tool.Ifc but never declared on IfcStore nor reset by purge(),
  leaking the HDF5 cache across projects (4 lines in bim/ifc.py).

Shared-file footprint in existing Bonsai files is small and additive:
bim/__init__.py (+2), bim/ui.py (+20: CIVIL tab entry + one tab panel),
bim/prop.py (+1: CIVIL tab tuple), core/tool.py (+29: Alignment
interface), tool/__init__.py (+1), pytest.ini (+2 markers),
test/core/bootstrap.py (+10: alignment Prophecy fixture). Everything
else is new files under bim/module/alignment/, core/alignment.py,
tool/alignment.py and tests.

Tests: 17 core (Prophecy), plus tool and operator suites for PI math,
IFC segment creation, hierarchy management, PI edit mode, CSV import
and station formatting (Blender headless).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
IfcAlignment appears in the Add Element Definition dropdown (IFC4X3+);
creating one bootstraps the horizontal layout, stationing referent,
zero-length terminator, origin placement, and project aggregation via
add_horizontal_layout_to_alignment, which is rewritten to mirror
align_api.create()'s sequence (fixing a module-called-as-function
TypeError and a scrambled add_stationing_referent argument order the
unused route had masked). Root-module footprint: +32 lines across
tool/root.py, root/data.py, root/operator.py.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copy link
Copy Markdown
Contributor

@DesertSpringsCivil - cool! I'll take a look at this as soon as I can. Since you branched from 0.9.0, there may be some conflicts with the alignment api, but nothing we can't figure out.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL