From a6d363c542b019f807842672167aed2dbf66277e Mon Sep 17 00:00:00 2001 From: Jesusbill Date: Mon, 4 Oct 2021 21:32:09 +0200 Subject: [PATCH] place structural items in collections for new project --- .../blenderbim/bim/module/root/operator.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/blenderbim/blenderbim/bim/module/root/operator.py b/src/blenderbim/blenderbim/bim/module/root/operator.py index 3470c45cbb..ce375218c8 100644 --- a/src/blenderbim/blenderbim/bim/module/root/operator.py +++ b/src/blenderbim/blenderbim/bim/module/root/operator.py @@ -156,6 +156,11 @@ class AssignClass(bpy.types.Operator): or product.is_a("IfcContext") ): self.place_in_spatial_collection(obj, context) + elif product.is_a("IfcStructuralItem"): + if product.is_a("IfcStructuralMember"): + self.place_in_structural_items_collection(obj, context, structural_collection="Members") + elif product.is_a("IfcStructuralConnection"): + self.place_in_structural_items_collection(obj, context, structural_collection="Connections") else: self.assign_potential_spatial_container(obj) context.view_layer.objects.active = obj @@ -201,6 +206,25 @@ class AssignClass(bpy.types.Operator): else: context.scene.collection.children.link(collection) + def place_in_structural_items_collection(self, obj, context, structural_collection): + for project in [c for c in context.view_layer.layer_collection.children if "IfcProject" in c.name]: + if not [c for c in project.children if "StructuralItems" in c.name]: + members = bpy.data.collections.new("Members") + connections = bpy.data.collections.new("Connections") + items = bpy.data.collections.new("StructuralItems") + items.children.link(members) + items.children.link(connections) + project.collection.children.link(items) + + for coll in [c for c in project.children if "StructuralItems" in c.name]: + for collection in [c for c in coll.children if structural_collection in c.name]: + for user_collection in obj.users_collection: + user_collection.objects.unlink(obj) + collection.collection.objects.link(obj) + break + break + break + def assign_potential_spatial_container(self, obj): for collection in obj.users_collection: if "Ifc" not in collection.name or collection.name == obj.name: