diff --git a/src/bonsai/bonsai/bim/module/model/data.py b/src/bonsai/bonsai/bim/module/model/data.py index c19e21a6dc..d67d198ff3 100644 --- a/src/bonsai/bonsai/bim/module/model/data.py +++ b/src/bonsai/bonsai/bim/module/model/data.py @@ -107,13 +107,7 @@ class AuthoringData: @classmethod def type_thumbnail(cls): - if not cls.data["relating_type_id"]: - return 0 - relating_type_id = tool.Blender.get_enum_safe(cls.props, "relating_type_id") - if relating_type_id is None: - return 0 - element = tool.Ifc.get().by_id(int(relating_type_id)) - return cls.type_thumbnails.get(element.id(), None) or 0 + return cls.type_thumbnails.get(int(cls.data["relating_type_id_current"] or 0), 0) @classmethod def total_types(cls): diff --git a/src/bonsai/bonsai/bim/module/model/product.py b/src/bonsai/bonsai/bim/module/model/product.py index 7d76e47d4a..b888353cd9 100644 --- a/src/bonsai/bonsai/bim/module/model/product.py +++ b/src/bonsai/bonsai/bim/module/model/product.py @@ -563,7 +563,6 @@ class LoadTypeThumbnails(bpy.types.Operator, tool.Ifc.Operator): return props = bpy.context.scene.BIMModelProperties - processing = set() # Only process at most one paginated class at a time. # Large projects have hundreds of types which can lead to unnecessary lag. if not AuthoringData.is_loaded: @@ -577,6 +576,12 @@ class LoadTypeThumbnails(bpy.types.Operator, tool.Ifc.Operator): offset = 0 queue = queue[offset : offset + 9] + # The active type may be in another page than the active one : + if relating_type_id_current := AuthoringData.data["relating_type_id_current"]: + active_element = tool.Ifc.get_entity_by_id(int(relating_type_id_current)) + if active_element and active_element not in queue: + queue.append(active_element) + while queue: # if bpy.app.is_job_running("RENDER_PREVIEW") does not seem to reflect asset preview generation element = queue.pop() diff --git a/src/bonsai/bonsai/bim/module/model/ui.py b/src/bonsai/bonsai/bim/module/model/ui.py index 0534aa6b55..8cf01f0012 100644 --- a/src/bonsai/bonsai/bim/module/model/ui.py +++ b/src/bonsai/bonsai/bim/module/model/ui.py @@ -84,7 +84,7 @@ class LaunchTypeManager(bpy.types.Operator): bl_idname = "bim.launch_type_manager" bl_label = "Launch Type Manager" bl_options = {"REGISTER", "UNDO"} - bl_description = "Display all available Construction Types to add new occurrences" + bl_description = "Browse, Edit and Manage Types" def execute(self, context): return {"FINISHED"} diff --git a/src/bonsai/bonsai/bim/module/model/workspace.py b/src/bonsai/bonsai/bim/module/model/workspace.py index 0e6e3bf4e9..c8611beab4 100644 --- a/src/bonsai/bonsai/bim/module/model/workspace.py +++ b/src/bonsai/bonsai/bim/module/model/workspace.py @@ -504,54 +504,58 @@ class CreateObjectUI: row = cls.layout.row(align=True) if not AuthoringData.data["ifc_element_type"]: prop_with_search(row, cls.props, "ifc_class", text="Type Class" if ui_context != "TOOL_HEADER" else "") - if AuthoringData.data["ifc_classes"]: - ifc_class = AuthoringData.data["ifc_class_current"] - if ifc_class: - box = cls.layout.box() - row = box.row(align=True) - if ui_context == "TOOL_HEADER": - row.template_icon(icon_value=AuthoringData.data.get("type_thumbnail", 0)) - row.operator("bim.launch_type_manager", text=AuthoringData.data["relating_type_name"], emboss=False) - row.operator( - "bim.launch_type_manager", - icon=tool.Blender.TYPE_MANAGER_ICON, - text="", - emboss=False, - ) + if not AuthoringData.data["ifc_classes"]: + return + if not (ifc_class := AuthoringData.data["ifc_class_current"]): + return - if ui_context != "TOOL_HEADER": - row = box.row(align=True) - row.alignment = "CENTER" - row.operator( - "bim.launch_type_manager", - text=AuthoringData.data["relating_type_description"], - emboss=False, - ) + box = cls.layout.box() - if AuthoringData.data["type_thumbnail"]: - row1 = box.row() - row1.ui_units_y = 0.01 - row1.template_icon(icon_value=AuthoringData.data["type_thumbnail"], scale=4) - row2 = box.column(align=True) - row2.ui_units_y = 4 - for _ in range(4): - row2.operator("bim.launch_type_manager", text="", emboss=False) - else: - op = box.operator( - "bim.load_type_thumbnails", - text="", - icon="FILE_REFRESH", - emboss=False, - ) - op.ifc_class = ifc_class + row = box.row(align=True) + thumbnail: int = AuthoringData.data["type_thumbnail"] + row.template_icon(icon_value=thumbnail) + row.operator("bim.launch_type_manager", text=AuthoringData.data["relating_type_name"], emboss=False) + row.operator( + "bim.launch_type_manager", + icon=tool.Blender.TYPE_MANAGER_ICON, + text="", + emboss=False, + ) - row = box.row(align=True) - row.alignment = "CENTER" - row.operator( - "bim.launch_type_manager", - text=AuthoringData.data["predefined_type"], - emboss=False, - ) + if ui_context == "TOOL_HEADER": + return + row = box.row(align=True) + row.alignment = "CENTER" + row.operator( + "bim.launch_type_manager", + text=AuthoringData.data["relating_type_description"], + emboss=False, + ) + + if thumbnail != 0: + row1 = box.row() + row1.ui_units_y = 0.01 + row1.template_icon(icon_value=thumbnail, scale=4) + row2 = box.column(align=True) + row2.ui_units_y = 4 + for _ in range(4): + row2.operator("bim.launch_type_manager", text="", emboss=False) + else: + op = box.operator( + "bim.load_type_thumbnails", + text="", + icon="FILE_REFRESH", + emboss=False, + ) + op.ifc_class = ifc_class + + row = box.row(align=True) + row.alignment = "CENTER" + row.operator( + "bim.launch_type_manager", + text=AuthoringData.data["predefined_type"], + emboss=False, + ) class EditObjectUI: