Find the "Types" Collection regardless of the IfcProject.Name

This commit is contained in:
Ryan Schultz
2024-05-05 20:46:07 -05:00
parent 34bbc8f1ea
commit 10f894e2ea
@@ -157,8 +157,9 @@ class SelectType(bpy.types.Operator):
selected_objs.append(active_obj) #update selected_objs so the active_obj is at the end of the list selected_objs.append(active_obj) #update selected_objs so the active_obj is at the end of the list
last_relating_type_obj = None last_relating_type_obj = None
types_collection_in_view_layer = self.find_collection_in_ifcproject(context, collection_name = "Types")
types_collection_in_view_layer.hide_viewport = False
types_collection = bpy.data.collections.get("Types") types_collection = bpy.data.collections.get("Types")
context.view_layer.layer_collection.children['IfcProject/My Project'].children["Types"].hide_viewport = False
for type_obj in types_collection.objects: for type_obj in types_collection.objects:
type_obj.hide_set(True) type_obj.hide_set(True)
for obj in selected_objs: for obj in selected_objs:
@@ -178,6 +179,18 @@ class SelectType(bpy.types.Operator):
return {"FINISHED"} return {"FINISHED"}
def find_collection_in_ifcproject(self, context, collection_name):
ifc_project_collection = None
for child in context.view_layer.layer_collection.children:
if "IfcProject" in child.name:
ifc_project_collection = child
break
if ifc_project_collection:
collection_in_view_layer = ifc_project_collection.children.get(collection_name)
return collection_in_view_layer
class SelectSimilarType(bpy.types.Operator): class SelectSimilarType(bpy.types.Operator):
bl_idname = "bim.select_similar_type" bl_idname = "bim.select_similar_type"