From 823b10e3232d7d3a6b4fb1c60634cec3c79f0ca9 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 1 Dec 2020 21:37:47 +1100 Subject: [PATCH] Dumb grids are auto placed in an IfcSite if it can be detected for convenience --- .../blenderbim/bim/module/model/grid.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ifcblenderexport/blenderbim/bim/module/model/grid.py b/src/ifcblenderexport/blenderbim/bim/module/model/grid.py index 503d44a785..bc99dff616 100644 --- a/src/ifcblenderexport/blenderbim/bim/module/model/grid.py +++ b/src/ifcblenderexport/blenderbim/bim/module/model/grid.py @@ -14,7 +14,18 @@ def add_object(self, context): default_collection.objects.unlink(obj) collection = bpy.data.collections.new("IfcGrid/" + name) - bpy.context.view_layer.active_layer_collection.collection.children.link(collection) + has_site_collection = False + for child in bpy.context.view_layer.layer_collection.children: + if "IfcProject/" not in child.name: + continue + for grandchild in child.children: + if "IfcSite/" not in grandchild.name: + continue + has_site_collection = True + grandchild.collection.children.link(collection) + break + if not has_site_collection: + bpy.context.view_layer.active_layer_collection.collection.children.link(collection) collection.objects.link(obj) axes_collection = bpy.data.collections.new("UAxes")