From 1b63d9e88f2e4a6be0309e0c3cd6365a0cbd94e4 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 10 Jun 2024 16:13:00 +1000 Subject: [PATCH] Railing/roof/stair/window now use default collection. Continue removing old "active collection" code. --- .../blenderbim/bim/module/model/railing.py | 2 -- .../blenderbim/bim/module/model/roof.py | 2 -- .../blenderbim/bim/module/model/stair.py | 2 -- .../blenderbim/bim/module/model/window.py | 2 -- src/blenderbim/blenderbim/core/tool.py | 1 - src/blenderbim/blenderbim/tool/project.py | 16 ---------------- src/blenderbim/test/core/test_project.py | 3 --- src/blenderbim/test/tool/test_project.py | 15 --------------- 8 files changed, 43 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/model/railing.py b/src/blenderbim/blenderbim/bim/module/model/railing.py index f3d20b5031..6d7bca3ad4 100644 --- a/src/blenderbim/blenderbim/bim/module/model/railing.py +++ b/src/blenderbim/blenderbim/bim/module/model/railing.py @@ -299,8 +299,6 @@ class BIM_OT_add_railing(bpy.types.Operator, tool.Ifc.Operator): mesh = bpy.data.meshes.new("IfcRailing") obj = bpy.data.objects.new("IfcRailing", mesh) obj.location = spawn_location - collection = context.view_layer.active_layer_collection.collection - collection.objects.link(obj) body_context = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Body", "MODEL_VIEW") blenderbim.core.root.assign_class( diff --git a/src/blenderbim/blenderbim/bim/module/model/roof.py b/src/blenderbim/blenderbim/bim/module/model/roof.py index e33e819c0c..92a7d2347e 100644 --- a/src/blenderbim/blenderbim/bim/module/model/roof.py +++ b/src/blenderbim/blenderbim/bim/module/model/roof.py @@ -515,8 +515,6 @@ class BIM_OT_add_roof(bpy.types.Operator, tool.Ifc.Operator): mesh = bpy.data.meshes.new("IfcRoof") obj = bpy.data.objects.new("IfcRoof", mesh) obj.location = spawn_location - collection = context.view_layer.active_layer_collection.collection - collection.objects.link(obj) body_context = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Body", "MODEL_VIEW") blenderbim.core.root.assign_class( diff --git a/src/blenderbim/blenderbim/bim/module/model/stair.py b/src/blenderbim/blenderbim/bim/module/model/stair.py index c58685db53..4bfb01ea65 100644 --- a/src/blenderbim/blenderbim/bim/module/model/stair.py +++ b/src/blenderbim/blenderbim/bim/module/model/stair.py @@ -218,8 +218,6 @@ class BIM_OT_add_clever_stair(bpy.types.Operator, tool.Ifc.Operator): mesh = bpy.data.meshes.new("IfcStairFlight") obj = bpy.data.objects.new("StairFlight", mesh) obj.location = spawn_location - collection = context.view_layer.active_layer_collection.collection - collection.objects.link(obj) element = blenderbim.core.root.assign_class( tool.Ifc, diff --git a/src/blenderbim/blenderbim/bim/module/model/window.py b/src/blenderbim/blenderbim/bim/module/model/window.py index 64a5658435..f519dea941 100644 --- a/src/blenderbim/blenderbim/bim/module/model/window.py +++ b/src/blenderbim/blenderbim/bim/module/model/window.py @@ -402,8 +402,6 @@ class BIM_OT_add_window(bpy.types.Operator, tool.Ifc.Operator): mesh = bpy.data.meshes.new("IfcWindow") obj = bpy.data.objects.new("IfcWindow", mesh) obj.location = spawn_location - collection = context.view_layer.active_layer_collection.collection - collection.objects.link(obj) element = blenderbim.core.root.assign_class( tool.Ifc, tool.Collector, tool.Root, obj=obj, ifc_class="IfcWindow", should_add_representation=False diff --git a/src/blenderbim/blenderbim/core/tool.py b/src/blenderbim/blenderbim/core/tool.py index a379bbfda6..8a4952eab1 100644 --- a/src/blenderbim/blenderbim/core/tool.py +++ b/src/blenderbim/blenderbim/core/tool.py @@ -602,7 +602,6 @@ class Project: def run_owner_set_user(cls, user=None): pass def run_root_assign_class(cls, obj=None, ifc_class=None, predefined_type=None, should_add_representation=True, context=None, ifc_representation_class=None): pass def run_unit_assign_scene_units(cls): pass - def set_active_spatial_element(cls, obj): pass def set_context(cls, context): pass def set_default_context(cls): pass def set_default_modeling_dimensions(cls): pass diff --git a/src/blenderbim/blenderbim/tool/project.py b/src/blenderbim/blenderbim/tool/project.py index 3066990923..6b1e8cd695 100644 --- a/src/blenderbim/blenderbim/tool/project.py +++ b/src/blenderbim/blenderbim/tool/project.py @@ -120,22 +120,6 @@ class Project(blenderbim.core.tool.Project): def run_unit_assign_scene_units(cls): return blenderbim.core.unit.assign_scene_units(tool.Ifc, tool.Unit) - @classmethod - def set_active_spatial_element(cls, obj): - collection = obj.BIMObjectProperties.collection - queue = [bpy.context.view_layer.layer_collection] - layer_collection = None - - while queue: - layer = queue.pop() - if layer.collection == collection: - layer_collection = layer - break - queue.extend(list(layer.children)) - - if layer_collection: - bpy.context.view_layer.active_layer_collection = layer_collection - @classmethod def set_context(cls, context): blenderbim.bim.handler.refresh_ui_data() diff --git a/src/blenderbim/test/core/test_project.py b/src/blenderbim/test/core/test_project.py index af88dd18a3..0cfa3295c4 100644 --- a/src/blenderbim/test/core/test_project.py +++ b/src/blenderbim/test/core/test_project.py @@ -92,7 +92,6 @@ class TestCreateProject: project.run_aggregate_assign_object(relating_obj="building", related_obj="storey").should_be_called() project.set_context("body").should_be_called() - project.set_active_spatial_element("storey").should_be_called() project.load_default_thumbnails().should_be_called() project.set_default_context().should_be_called() @@ -125,7 +124,6 @@ class TestCreateProject: project.run_aggregate_assign_object(relating_obj="building", related_obj="storey").should_be_called() project.set_context("body").should_be_called() - project.set_active_spatial_element("storey").should_be_called() project.append_all_types_from_template("template").should_be_called() @@ -167,7 +165,6 @@ class TestCreateProject: project.run_aggregate_assign_object(relating_obj="building", related_obj="storey").should_be_called() project.set_context("body").should_be_called() - project.set_active_spatial_element("storey").should_be_called() project.load_default_thumbnails().should_be_called() project.set_default_context().should_be_called() diff --git a/src/blenderbim/test/tool/test_project.py b/src/blenderbim/test/tool/test_project.py index 043d251616..59086d811b 100644 --- a/src/blenderbim/test/tool/test_project.py +++ b/src/blenderbim/test/tool/test_project.py @@ -87,21 +87,6 @@ class TestRunUnitAssignSceneUnits(NewFile): pass -class TestSetActiveSpatialElement(NewFile): - def test_run(self): - obj = bpy.data.objects.new("Foo", None) - collection = bpy.data.collections.new("Foo") - bpy.context.scene.collection.children.link(collection) - collection.objects.link(obj) - obj.BIMObjectProperties.collection = collection - collection.BIMCollectionProperties.obj = obj - - layer = bpy.context.view_layer.layer_collection.children["Foo"] - assert bpy.context.view_layer.active_layer_collection != layer - subject.set_active_spatial_element(obj) - assert bpy.context.view_layer.active_layer_collection == layer - - class TestSetContext(NewFile): def test_run(self): ifc = ifcopenshell.file()