Hide edit mode for locked elements #5371

This commit is contained in:
Andrej730
2024-09-12 18:32:44 +05:00
parent d34d3312ba
commit e3c23072a5
2 changed files with 8 additions and 1 deletions
@@ -52,7 +52,11 @@ class ViewportData:
("OBJECT", "IFC Object Mode", "", "OBJECT_DATAMODE", 0), ("OBJECT", "IFC Object Mode", "", "OBJECT_DATAMODE", 0),
("EDIT", "IFC Edit Mode", "", "EDITMODE_HLT", 1), ("EDIT", "IFC Edit Mode", "", "EDITMODE_HLT", 1),
] ]
if not obj or not tool.Blender.is_editable(obj): if (
not obj
or not tool.Blender.is_editable(obj)
or ((element := tool.Ifc.get_entity(obj)) and tool.Geometry.is_locked(element))
):
return obj_mode return obj_mode
return mesh_modes return mesh_modes
@@ -31,6 +31,7 @@ from bpy.props import (
CollectionProperty, CollectionProperty,
) )
import bonsai.tool as tool import bonsai.tool as tool
import bonsai.bim.handler
import bonsai.core.geometry import bonsai.core.geometry
import ifcopenshell import ifcopenshell
import ifcopenshell.util.element import ifcopenshell.util.element
@@ -125,6 +126,8 @@ def update_spatial_is_locked(self, context):
tool.Geometry.lock_object(obj) tool.Geometry.lock_object(obj)
else: else:
tool.Geometry.unlock_object(obj) tool.Geometry.unlock_object(obj)
# Need to update ViewportData.mode.
bonsai.bim.handler.refresh_ui_data()
def update_spatial_is_visible(self: "BIMSpatialDecompositionProperties", context: bpy.types.Context) -> None: def update_spatial_is_visible(self: "BIMSpatialDecompositionProperties", context: bpy.types.Context) -> None: