From 4473dbd138114fff17d3080fbf9c03ccc4b9cbce Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 16 Mar 2026 15:17:15 +0500 Subject: [PATCH] bim.generate_uv_map - move to operator.py, fix missing description, add separate row in ui --- .../bonsai/bim/module/project/__init__.py | 2 +- .../bonsai/bim/module/project/operator.py | 16 ++++++++++++++ .../bonsai/bim/module/project/workspace.py | 21 ++----------------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/project/__init__.py b/src/bonsai/bonsai/bim/module/project/__init__.py index 67710db8ba..e83da49c5b 100644 --- a/src/bonsai/bonsai/bim/module/project/__init__.py +++ b/src/bonsai/bonsai/bim/module/project/__init__.py @@ -76,7 +76,7 @@ classes = ( operator.UnlinkIfc, operator.UnloadLink, workspace.ExploreHotkey, - workspace.GenerateUVMap, + operator.GenerateUVMap, prop.LibraryBreadcrumb, prop.LibraryElement, prop.FilterCategory, diff --git a/src/bonsai/bonsai/bim/module/project/operator.py b/src/bonsai/bonsai/bim/module/project/operator.py index c017336cbc..4e11a8ead8 100644 --- a/src/bonsai/bonsai/bim/module/project/operator.py +++ b/src/bonsai/bonsai/bim/module/project/operator.py @@ -3413,3 +3413,19 @@ class LoadBlendMetadataAndIFC(bpy.types.Operator): bpy.app.handlers.load_post.append(load_handler) bpy.ops.wm.open_mainfile(filepath=metadata_path) return {"FINISHED"} + + +class GenerateUVMap(bpy.types.Operator): + bl_idname = "bim.generate_uv_map" + bl_label = "Generate UV Map" + bl_description = "Generate UV map for selected mesh." + bl_options = {"REGISTER", "UNDO", "INTERNAL"} + + def execute(self, context): + obj = context.active_object + if not obj or not isinstance(obj.data, bpy.types.Mesh): + self.report({"ERROR"}, "No valid mesh selected.") + return {"CANCELLED"} + tool.Loader.load_generated_uv_map(obj.data) + self.report({"INFO"}, "Generated UV map for selected mesh.") + return {"FINISHED"} diff --git a/src/bonsai/bonsai/bim/module/project/workspace.py b/src/bonsai/bonsai/bim/module/project/workspace.py index 1adb2045c2..850fdc6531 100644 --- a/src/bonsai/bonsai/bim/module/project/workspace.py +++ b/src/bonsai/bonsai/bim/module/project/workspace.py @@ -87,8 +87,8 @@ class ExploreTool(bpy.types.WorkSpaceTool): op.hotkey = "S_S" op.description = "Scale Image Annotation. Allows to scale an IfcReferenceImage. Select image, select tool. Check lower left corner instructions to select two points and provide real distance between them" - op = row.operator("bim.generate_uv_map", text="Generate UV Map", icon="UV") - op.description = "Generate UV map for selected mesh." + row = layout.row(align=True) + row.operator("bim.generate_uv_map", icon="UV") class ExploreHotkey(bpy.types.Operator): @@ -156,20 +156,3 @@ class ExploreHotkey(bpy.types.Operator): def hotkey_A_H(self) -> None: bpy.ops.bim.hide_queried_linked_element(unhide_all=True) - - -class GenerateUVMap(bpy.types.Operator): - bl_idname = "bim.generate_uv_map" - bl_label = "Generate UV Map" - bl_options = {"REGISTER", "UNDO", "INTERNAL"} - - description: bpy.props.StringProperty() - - def execute(self, context): - obj = context.active_object - if not obj or not hasattr(obj, "data") or not hasattr(obj.data, "polygons"): - self.report({"ERROR"}, "No valid mesh selected.") - return {"CANCELLED"} - tool.Loader.load_generated_uv_map(obj.data) - self.report({"INFO"}, "Generated UV map for selected mesh.") - return {"FINISHED"}