From 5dc7513de086247294f7275d3b99ee7ca50b954f Mon Sep 17 00:00:00 2001 From: Gorgious56 Date: Wed, 27 May 2026 09:23:29 +0200 Subject: [PATCH] Add tool.Blender.Modifier backward-compat shims MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous commit moved is_ predicates off tool.Blender.Modifier onto tool.Parametric, and earlier C4 moved the Array helper bag off tool.Blender.Modifier.Array onto tool.Array. PR4 will migrate every caller; this commit keeps the OLD entry points alive as thin delegates so PR2 ships without breaking ~30 caller sites that still spell the old API in v0.8.0: * tool.Blender.Modifier.is_door / is_railing / is_roof / is_stair / is_wall / is_window — delegate to tool.Parametric.is_. * tool.Blender.Modifier.Array.bake_children_transform / constrain_ children_to_parent / get_all_children_objects / get_all_objects / get_children_objects / get_modifiers_data / remove_constraints / set_children_lock_state — delegate to tool.Array.. These shims are removed in PR5's cleanup commit once PR4 has rewritten the call sites in bim/import_ifc.py, bim/module/geometry/operator.py, bim/module/geometry/data.py, bim/module/model/array.py + the per-feature operators (door, wall, window, railing, roof, stair, ui). Generated with the assistance of an AI coding tool. --- src/bonsai/bonsai/tool/blender.py | 68 +++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/src/bonsai/bonsai/tool/blender.py b/src/bonsai/bonsai/tool/blender.py index 0c73d58599..40c5059563 100644 --- a/src/bonsai/bonsai/tool/blender.py +++ b/src/bonsai/bonsai/tool/blender.py @@ -1328,6 +1328,74 @@ class Blender(bonsai.core.tool.Blender): return True class Modifier: + # ---------------------------------------------------------------------- + # Backward-compat shims for callers still using the pre-refactor API. + # The is_ predicates now live on tool.Parametric; the Array helper + # bag now lives on tool.Array. PR4 migrates each caller; these shims + # are removed in PR5's cleanup. + # ---------------------------------------------------------------------- + + @classmethod + def is_door(cls, element: entity_instance) -> bool: + return tool.Parametric.is_door(element) + + @classmethod + def is_railing(cls, element: entity_instance) -> bool: + return tool.Parametric.is_railing(element) + + @classmethod + def is_roof(cls, element: entity_instance) -> bool: + return tool.Parametric.is_roof(element) + + @classmethod + def is_stair(cls, element: entity_instance) -> bool: + return tool.Parametric.is_stair(element) + + @classmethod + def is_wall(cls, element: entity_instance) -> bool: + return tool.Parametric.is_wall(element) + + @classmethod + def is_window(cls, element: entity_instance) -> bool: + return tool.Parametric.is_window(element) + + class Array: + @classmethod + def bake_children_transform(cls, parent_element: ifcopenshell.entity_instance, item: int) -> None: + tool.Array.bake_children_transform(parent_element, item) + + @classmethod + def constrain_children_to_parent(cls, parent_element: ifcopenshell.entity_instance) -> None: + tool.Array.constrain_children_to_parent(parent_element) + + @classmethod + def get_all_children_objects(cls, parent_element: ifcopenshell.entity_instance) -> list: + return tool.Array.get_all_children_objects(parent_element) + + @classmethod + def get_all_objects(cls, parent_element: ifcopenshell.entity_instance) -> list: + return tool.Array.get_all_objects(parent_element) + + @classmethod + def get_children_objects(cls, modifier_data: dict) -> list: + return tool.Array.get_children_objects(modifier_data) + + @classmethod + def get_modifiers_data(cls, parent_element: ifcopenshell.entity_instance): + return tool.Array.get_modifiers_data(parent_element) + + @classmethod + def remove_constraints(cls, parent_element: ifcopenshell.entity_instance) -> None: + tool.Array.remove_constraints(parent_element) + + @classmethod + def set_children_lock_state( + cls, parent_element: ifcopenshell.entity_instance, item: int, lock: bool + ) -> None: + tool.Array.set_children_lock_state(parent_element, item, lock) + + # ---------------------------------------------------------------------- + @classmethod def try_applying_edit_mode(cls, obj: bpy.types.Object, element: entity_instance) -> bool: """Tries to validate the current BIM modifier parameters for the active object