Commit Graph

20919 Commits

Author SHA1 Message Date
Gorgious56 2456808b67 Defer mathutils imports in stair gizmo tests
Aligns with the test/bim/ convention: heavy imports go inside test
functions so the autouse _require_real_bpy fixture skips cleanly
when bpy is mocked, rather than module-level imports failing at
collection time and erroring out the whole file.

Generated with the assistance of an AI coding tool.
2026-06-11 18:30:10 +02:00
Gorgious56 7d779df981 Add BONSAI_TEST_ARGS env-var fallback to runpytest.py
PowerShell and some wrapper scripts on Windows occasionally strip
or reorder the `--` separator before Blender sees it, dropping the
pytest args into Blender's positional file-load slot ("File format
is not supported"). The env var carries the same args via a
shell-evaluation-free channel. Default `--` path is byte-identical
to the pre-change behaviour.

Generated with the assistance of an AI coding tool.
2026-06-11 18:30:10 +02:00
Gorgious56 872dd26e1c Sweep docstrings for rot-prone references
Docstrings naming sibling methods, private helpers, test files, or
historical symbols silently go wrong on rename. Strip Sphinx :meth:
/ :class: / :func: / :attr: markup that mostly added noise (no
Sphinx in this project), and rewrite five docstrings that cited
specific test paths or private hooks to describe the behaviour
instead.

Generated with the assistance of an AI coding tool.
2026-06-11 18:30:10 +02:00
Gorgious56 4df946be71 Drop save-time parametric-edit confirm dialog
The dialog's only outcomes were "Apply & Save" (same as silent save)
or "Cancel" (same as not saving) — net friction with no actual choice.
Auto-commit stays as the safety net; the count now suffixes the
existing save-success report so it isn't immediately overwritten.

Generated with the assistance of an AI coding tool.
2026-06-11 18:30:10 +02:00
Gorgious56 74906ac9fe Prioritize smaller distance gizmos in selection
When two GizmoDimension hit regions overlap (a short dimension
nested inside a longer one along the same axis), the larger one
used to win because hit boxes are scaled by world-space length —
the long box fully contains the short one, leaving the short
gizmo unreachable. The larger gizmo stays clickable at its
exposed ends, so smaller-wins is the right UX default.

Sets self.select_bias = -self._dimension_length inside
GizmoDimension.set_dimension_length. The smaller gizmo writes a
less-negative depth value in the GPU select buffer and wins the
tie-break. select_bias is unused elsewhere in the codebase, so
icon and arrow gizmos keep bias=0 and are unaffected (icons
correctly still win against dimensions, since 0 > -length).

Adds test/bim/module/drawing/test_dimension_gizmo_priority.py
with 5 cases: direct ordering, monotonicity across length ranges,
abs() handling for signed dimensions, and NaN/Inf safety.

Generated with the assistance of an AI coding tool.
2026-06-11 18:30:10 +02:00
Gorgious56 ddd9b4fa23 Simplify pending edit popup text 2026-06-11 18:30:09 +02:00
Gorgious56 5d6878c321 Fix set_icon_gizmo_position so billboard ignores object rotation
set_icon_gizmo_position computed
``mw @ (Translation @ billboard_rot @ Scale)`` — the object's world
matrix was applied AFTER the billboard rotation, so any non-trivial
object rotation (e.g. a wall rotated in plan, a stair rotated to
match a corridor) carried over into the icon's transform and tilted
it edge-on to the camera instead of facing it.

Switch to ``billboarded_at(world_pos, billboard_rot, scale)`` where
``world_pos = mw @ local_pos``: translate to world space first, then
apply the billboard rotation independently of the object's rotation.
This matches the manual pattern the base class's
``update_editing_gizmos`` already uses for validate/cancel/cycle for
exactly this reason.

Drops the now-stale workaround docstring on
``GizmoWallEdition._update_icon_row_extras`` that documented why it
bypassed ``set_icon_gizmo_position`` — the helper does the right
thing now.

Adds ``test/bim/module/model/test_stair_gizmos.py`` as the regression
guard: parametrised over six rotation angles, asserts that the rotation
part of the resulting matrix equals ``billboard_rot`` (no contribution
from ``mw``'s rotation) and that the translation lands at
``world_pos``. Also exercises ``set_icon_gizmo_position`` end-to-end via
a stub gizmo to catch the exact shape of the previously-broken call
site.

Generated with the assistance of an AI coding tool.
2026-06-11 18:30:09 +02:00
Gorgious56 95a31b49ec Add wall parametric editing and gizmos
Walls gain in-viewport parametric editing matching the door/window/stair
UX: drag handles for length, height, slope (x-angle), layer baseline
cycle, plus cursor-anchored quality-of-life operators (split at cursor,
extend to cursor, extend height, rotate 90, toggle openings) and
two-object state-machine gizmos (unjoin / merge / join-corner /
extend-to-wall / extend-vertically / add-opening).

Wall enters tool.Parametric.EDIT_TYPES, so save-time auto-commit,
GizmoPreferencesWall registration, and the in-progress-edit predicates
all light up automatically through the registry plumbing landed two
commits back.

The three-layer commit model (drag -> BIMWallProperties -> bmesh
preview -> Finish -> single ifc.run) means dragging a handle through
hundreds of intermediate values produces zero extra IFC entities. A
no-op enable->finish round-trip is byte-identical. The snapshot diff
in FinishEditingWall skips unchanged params.
_commit_active_wall_edit_if_any ensures cursor-anchored operators see
committed geometry, not the draft preview box.

Also lands the `prompt_auto_commit_parametric_edits` BoolProperty on
BIM_ADDON_preferences (consumed by the auto-commit dialog landed in
the framework commit) and refactors
`draw_{door,window,stair}_gizmo_parameters` into a shared
`_draw_parametric_gizmo_parameters` helper that the new
`draw_wall_gizmo_parameters` reuses. This commit and the framework
commit are stacked - the framework commit references the BoolProperty
defined here, so they must land together.

Tests cover pure math (core/test_model.py), DimensionGizmoConfig text
formatter, GizmoWallExtendVertically.poll() preconditions, and the
refresh_post_commit cache-invalidation regression. BDD scenarios in
model.feature cover the edit triad, auto-commit on save, and the
two-object gizmos. Documentation added to creating_walls.rst.

Generated with the assistance of an AI coding tool.
2026-06-11 18:30:09 +02:00
Gorgious56 b36bdf4130 Fix dead duplicates and misleading import comments
Three small post-landing cleanups against the parametric framework commit:

* core/model.py had `are_axes_collinear` and `closest_endpoint_midpoint`
  each defined twice — Python silently kept the second copy, the first
  was dead code. Removed the dead copies; runtime behavior unchanged
  (the live versions were already the kept ones).
* bim/__init__.py's `_parametric_gizmo_preference_classes` docstring
  named the wrong link in the import chain (`tool.blender → bim.ifc`).
  The real chain is `tool/ifc.py` (and ~6 other tool/* modules) which
  import `from bonsai.bim.ifc import IfcStore` at module load. Updated
  docstring to cite that root cause and the architectural fix (move
  `IfcStore` out of `bim/`).
* tool/blender.py's `from bonsai.bim.ifc import IFC_CONNECTED_TYPE`
  carried a 5-line comment claiming it was "lazy" to avoid a circular
  load. The import sits inside an `if TYPE_CHECKING:` block with
  `from __future__ import annotations` — it never runs at runtime
  regardless. Comment removed; the TYPE_CHECKING guard is
  self-explanatory.

Generated with the assistance of an AI coding tool.
2026-06-11 18:30:09 +02:00
Gorgious56 fb70c64138 Add tool.Parametric registry and lifecycle mixins
Establish a single source of truth for parametric element types (door,
window, stair, railing, roof). tool.Parametric.EDIT_TYPES drives:
- BIM<Name>Properties PointerProperty attachment via the registry
- GizmoPreferences<Name> class registration in bim/__init__.py
- save-time auto-commit of pending draft edits
- the refresh_post_commit epilogue called from IfcStore after every IFC
  mutation, which fixes the stale-header bug where in-place hotkey
  mutations (S_E / C_E) left BIMModelProperties and the gizmo cache
  pointing at obsolete values.

Refactors door/window/railing/roof onto shared mixins from
bim/parametric_lifecycle.py (FeatureModifierEditMixin and
PathPreservingEditMixin); stair gets the lock-gizmo refactor and
frame-cache integration. Behavior preserved.

Adds BaseParametricGizmoGroup._prime_frame_caches so the parametric
gizmos stop re-deriving preferences, view direction, and billboard
rotation per frame; reorders poll() to short-circuit on the cheapest
predicate first. Adds the icon library + BillboardingGizmoGroupMixin
that the wall feature in the next commit will consume.

Generated with the assistance of an AI coding tool.
2026-06-11 18:30:09 +02:00
Gorgious56 0413be2c3f Fix 8077 : Fix SHIFT + D with non-ifc object selection
When a project has a ifc file associated, selecting non-ifc objects and duplicating them with SHIFT + D now correctly both duplicate them, keep the new objects selected and starts the transform modal. IFC objects behaviour is unaffected.
2026-06-11 18:30:09 +02:00
Geert Hesselink 69ae113434 Fix lint failures and add missing pyparsing dependency (#8048)
* unblock voxel schema loading, add test for express

* Apply black formatting

* Fix lint failures and add missing pyparsing dependency

* align ty -> 0.0.34
2026-06-11 18:30:08 +02:00
Thomas Krijnen 1f6c467c88 Change default value of assume_asset_uniqueness_by_name #8045 2026-06-11 18:29:12 +02:00
Thomas Krijnen 295c7d801c arrange polygons: limit width ratio when merging boxes 2026-06-11 18:29:12 +02:00
Ryan Schultz 1d9df1d90a Fix #8056 - Dimensions with CustomUnit" = "Inches - Fractional" should not show 0. 2026-06-11 18:29:12 +02:00
Thomas Krijnen 13bb8fbb98 arrange polies: don't allow snapped point paths to cross non-containing other rect axes 2026-06-11 18:29:12 +02:00
Thomas Krijnen 55d7c24dc8 Fix temporary solution storage in arrange polygons 2026-06-11 18:29:12 +02:00
Thomas Krijnen 3a14786a5b Calculate box-width as orthogonal distance; aabb code for segment intersection (disabled) 2026-06-11 18:29:12 +02:00
Thomas Krijnen 10f93545da Arrange polies: reorder segment to exterior insertion based on length 2026-06-11 18:29:12 +02:00
Thomas Krijnen 7a901c1fce Reduce log noise on materials without styles #7947 2026-06-11 18:29:12 +02:00
Thomas Krijnen 6fffe33da1 arrange polies, fuse boxes only when obb also overlaps 2026-06-11 18:29:11 +02:00
Ghesselink 2dbb8c59e3 Apply black formatting 2026-06-11 18:29:11 +02:00
Ghesselink aa053bd52c unblock voxel schema loading, add test for express 2026-06-11 18:29:11 +02:00
Thomas Krijnen 57d1feaba8 arrange polies: try connect to closest point when extension and projection both do not work 2026-06-11 18:29:11 +02:00
Thomas Krijnen 98a897dd34 arrange polies performance: retain input poly provenance while subdividing; insert into arrangement_2 in batches 2026-06-11 18:29:11 +02:00
Thomas Krijnen 3b4cff838e arrange polies: only subdivide segments that correspond to input poly segments 2026-06-11 18:29:11 +02:00
Thomas Krijnen b7a329c9bc arrange polies: apply triangle elimination in both algo 1 and 2 2026-06-11 18:29:11 +02:00
Thomas Krijnen 15574f78ac arrange polies: lower iou to 45% 2026-06-11 18:29:11 +02:00
Richard Brice 820077a94b Removes unnecessary operations when combining horizontal and vertical placement matrices for alignment 2026-06-11 18:29:11 +02:00
Thomas Krijnen cd51c3ae85 arrange polygons: debug output point and annotate self intersecting polies; fix snapping distance check and fallback; tweak max snap to exterior distance; accept non-simple polies - likely touching without edge overlap; write representative points to debug output; properly apply algo 1 fallback; correct order for halfedge elimination; 2026-06-11 18:29:11 +02:00
dependabot[bot] faed3e517c Bump actions/checkout from 4 to 6
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-11 18:29:11 +02:00
dependabot[bot] 0d021585cb Bump astral-sh/setup-uv from 3 to 7
Bumps [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) from 3 to 7.
- [Release notes](https://github.com/astral-sh/setup-uv/releases)
- [Commits](https://github.com/astral-sh/setup-uv/compare/v3...v7)

---
updated-dependencies:
- dependency-name: astral-sh/setup-uv
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-11 18:29:11 +02:00
dependabot[bot] a195056a25 Bump hendrikmuhs/ccache-action from 1.2.22 to 1.2.23
Bumps [hendrikmuhs/ccache-action](https://github.com/hendrikmuhs/ccache-action) from 1.2.22 to 1.2.23.
- [Release notes](https://github.com/hendrikmuhs/ccache-action/releases)
- [Commits](https://github.com/hendrikmuhs/ccache-action/compare/v1.2.22...v1.2.23)

---
updated-dependencies:
- dependency-name: hendrikmuhs/ccache-action
  dependency-version: 1.2.23
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-11 18:29:11 +02:00
dependabot[bot] cc77fe2007 Bump ruff from 0.15.10 to 0.15.12
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.15.10 to 0.15.12.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/0.15.10...0.15.12)

---
updated-dependencies:
- dependency-name: ruff
  dependency-version: 0.15.12
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-11 18:29:11 +02:00
dependabot[bot] 4a532c7de7 Bump ty from 0.0.29 to 0.0.32
Bumps [ty](https://github.com/astral-sh/ty) from 0.0.29 to 0.0.32.
- [Release notes](https://github.com/astral-sh/ty/releases)
- [Changelog](https://github.com/astral-sh/ty/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ty/compare/0.0.29...0.0.32)

---
updated-dependencies:
- dependency-name: ty
  dependency-version: 0.0.32
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-11 18:29:11 +02:00
Ryan Schultz 25c2464cd5 Fix #7885: LAYER3 crash on IfcCompositeProfileDef
The x-angle transformation for LAYER3 slabs assumed SweptArea
is always IfcArbitraryClosedProfileDef (which has OuterCurve),
but composite profiles use IfcCompositeProfileDef instead.
Apply the coord scaling to each sub-profile individually.

Generated with the assistance of an AI coding tool.
2026-06-11 18:29:10 +02:00
Ryan Schultz aba5889dec Fix #7927: Fix SECTION annotation for MODEL_VIEW drawings
generate_section_reference_points had no handler for
MODEL_VIEW target view, causing it to silently return
None. Add MODEL_VIEW branch that clips the section line
to XY camera bounds while preserving the Z coordinate
for correct 3D placement.

Generated with the assistance of an AI coding tool.
2026-06-11 18:29:10 +02:00
Ryan Schultz 68ecb97203 Fix #8024 - Fix TypeError when CardinalPoint is None
Guard the int() cast on CardinalPoint in
BIM_OT_edit_assigned_material so a None value (no cardinal
point set) no longer raises a TypeError.

Generated with the assistance of an AI coding tool.
2026-06-11 18:29:10 +02:00
E Shattow 991b41ac52 docs: project_overview: project_info blender tip to change display units after project creation
Link to Blender Manual for tip to change display units
2026-06-11 18:29:10 +02:00
Thomas Krijnen 66328d7fd1 Simple SPF submodule update 2026-06-11 18:28:36 +02:00
falken10vdl f2ddda8f83 Fix IfcSurfaceStyleRendering colour reset on save 2026-06-11 18:27:27 +02:00
Thomas Krijnen 9d1cd6adf6 Update build_pyodide.sh to source emsdk_env.sh conditionally
Add conditional sourcing for emsdk_env.sh
2026-06-11 18:27:26 +02:00
Thomas Krijnen a5cd8d025d arrange_polygons: Revert to unsimplified when big IoU difference; threshold on max snap distance; write most deviating input-output pair to debug output 2026-06-11 18:26:42 +02:00
Richard Brice 24a40625d1 Fixes bug in addRelatedObject<> for IfcRelReferencedInSpatialStructure 2026-06-11 18:26:42 +02:00
Bruno Postle 60cb034df7 Add license for OpenGost font shipped with Bonsai
Extracted from the font file like so:
python3 -c "
  from fontTools.ttLib import TTFont
  tt = TTFont('src/bonsai/bonsai/bim/data/fonts/OpenGost Type B TT.ttf')
  for record in tt['name'].names:
      if record.nameID == 13:
          print(record.toUnicode())
  "
2026-06-11 18:25:47 +02:00
Massimo Fabbro 00f6241417 See #6853. Minor fix for IfcDoor with IFC4x3 quantity calculation with blender engine 2026-06-11 18:25:47 +02:00
Massimo Fabbro 1512947c83 See #7716. Remove_cost_item also delete the assignment
Previously remove_cost_item leaved orphaned relation now it should be fixed
2026-06-11 18:25:46 +02:00
Massimo Fabbro 0ca9fd2773 See #7716. Fix util get_cost_item_for_product
Before there was an error if there weren't assignments now it should be fixed. Add also tests.
2026-06-11 18:25:46 +02:00
Massimo Fabbro 11d6508476 Add tests for cost tool 2026-06-11 18:25:46 +02:00
Massimo Fabbro efbe9a543f fix infinite recursion error
previously there was an almost silent error because the update function was called every time. Now it should be fixed.
2026-06-11 18:25:46 +02:00