mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 01:31:00 +00:00
539066a58b
Bonsai's Pset/Qto editor could display a property or quantity's own Unit override, but had no UI to author one -- only the project-level Project Units panel existed, which sets defaults, not per-instance overrides. Builds on the edit_pset/edit_qto Unit-wrapping support and the get_unit_scale/get_candidate_units helpers added in the previous commit. - bim/prop.py: Attribute gains unit_id (the STEP id of the property's own override, 0 = project default) and unit_id_enum (the dropdown-driving dynamic enum, "Default (<symbol>)" plus every candidate unit for the attribute's measure type). update_attribute_unit_id converts the stored value live when a different unit is picked, so the physical quantity is preserved rather than the number being silently relabeled. - tool/pset.py: is_measurable_special_type/get_candidate_units_for_special_type/ resolve_effective_unit/convert_attribute_unit support the picker and the live conversion. get_special_type_for_prop classifies a property by its value's own declared measure type, falling back to an explicitly-attached Unit for generic numeric types (e.g. IfcReal) whose spec carries no unit semantics of its own but which may still legitimately carry one. Seeding in import_pset_from_existing ignores a stray Unit attached to a property whose value has no numeric/measure semantics at all (e.g. text), which used to crash trying to select an identifier the picker's enum items never include. - bim/module/pset/ui.py: the picker widget itself, next to the value field in edit mode, gated on the attribute being measurable. - bim/module/pset/operator.py: EditPset wraps measurable values with their chosen Unit on save, for both properties and quantities. The qto rounding-loop fix reaches into the wrapped dict instead of assuming a bare float/int, which would otherwise zero out every unit-overridden quantity. Adds regression tests across all of the above, including conversion correctness, explicit-clear/default round-trips, an unrelated sibling property's override surviving untouched, and the stray-Unit crash guard.