From 1ce254cc9af0c0fbba1dec375f0e06e2778d2a0f Mon Sep 17 00:00:00 2001 From: Gorgious Date: Sat, 13 May 2023 20:34:44 +0200 Subject: [PATCH] Selecting types and instances now show a helpful tooltip when the object is not selectable (due to being hidden or in a hidden collection) --- .../blenderbim/bim/module/type/operator.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/type/operator.py b/src/blenderbim/blenderbim/bim/module/type/operator.py index dc41a89912..7889ab4bfe 100644 --- a/src/blenderbim/blenderbim/bim/module/type/operator.py +++ b/src/blenderbim/blenderbim/bim/module/type/operator.py @@ -143,8 +143,10 @@ class SelectType(bpy.types.Operator): element = tool.Ifc.get().by_id(self.relating_type) obj = tool.Ifc.get_object(element) if obj: - context.view_layer.objects.active = obj - obj.select_set(True) + if obj in context.selectable_objects: + tool.Blender.select_and_activate_single_object(context, obj) + else: + self.report({"INFO"}, "Type object can't be selected : It may be hidden or in an excluded collection.") return {"FINISHED"} @@ -177,10 +179,17 @@ class SelectTypeObjects(bpy.types.Operator): def execute(self, context): self.file = IfcStore.get_file() relating_type = bpy.data.objects.get(self.relating_type) if self.relating_type else context.active_object + at_least_one_selectable_typed_object = False for element in ifcopenshell.util.element.get_types(tool.Ifc.get_entity(relating_type)): obj = tool.Ifc.get_object(element) - if obj: + if obj and obj in context.selectable_objects: obj.select_set(True) + at_least_one_selectable_typed_object = True + if at_least_one_selectable_typed_object: + context.active_object.select_set(False) + context.view_layer.objects.active = context.selected_objects[0] + else: + self.report({"INFO"}, "Typed objects can't be selected : They may be hidden or in an excluded collection.") return {"FINISHED"} @@ -451,6 +460,10 @@ class DuplicateType(bpy.types.Operator, tool.Ifc.Operator): new = blenderbim.core.root.copy_class(tool.Ifc, tool.Collector, tool.Geometry, tool.Root, obj=new_obj) new.Name += " Copy" bpy.ops.bim.load_type_thumbnails(ifc_class=new.is_a()) + if obj in context.selectable_objects: + tool.Blender.select_and_activate_single_object(context, new_obj) + else: + self.report({"INFO"}, "Type object can't be selected : It may be hidden or in an excluded collection.") return {"FINISHED"}