Selecting types and instances now show a helpful tooltip when the object is not selectable (due to being hidden or in a hidden collection)

This commit is contained in:
Gorgious
2023-05-13 20:34:44 +02:00
parent 9d9d1660ff
commit 62f2144245
@@ -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"}