diff --git a/src/bonsai/bonsai/bim/module/project/__init__.py b/src/bonsai/bonsai/bim/module/project/__init__.py index db642c18c2..67710db8ba 100644 --- a/src/bonsai/bonsai/bim/module/project/__init__.py +++ b/src/bonsai/bonsai/bim/module/project/__init__.py @@ -76,6 +76,7 @@ classes = ( operator.UnlinkIfc, operator.UnloadLink, workspace.ExploreHotkey, + workspace.GenerateUVMap, prop.LibraryBreadcrumb, prop.LibraryElement, prop.FilterCategory, diff --git a/src/bonsai/bonsai/bim/module/project/workspace.py b/src/bonsai/bonsai/bim/module/project/workspace.py index a01a144b31..89467cbbee 100644 --- a/src/bonsai/bonsai/bim/module/project/workspace.py +++ b/src/bonsai/bonsai/bim/module/project/workspace.py @@ -87,6 +87,9 @@ 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." + class ExploreHotkey(bpy.types.Operator): bl_idname = "bim.explore_hotkey" @@ -153,3 +156,20 @@ 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"} \ No newline at end of file