fix issues toggling EDIT mode

1) it was throwing errors if object was linked

2) bim.override_mode_set_edit wasn't considering that toggle_edit_mode might not work out and was changing BIMGeometryProperties.mode though it wasn't needed.
This commit is contained in:
Andrej730
2024-08-08 12:50:41 +05:00
parent f9c4b6a98f
commit 3c0103b4da
2 changed files with 4 additions and 1 deletions
@@ -1669,7 +1669,8 @@ class OverrideModeSetEdit(bpy.types.Operator):
# The active object is non-mesh-like. Set a valid object (or None) as active
context.view_layer.objects.active = context.selected_objects[0] if context.selected_objects else None
if context.active_object:
tool.Blender.toggle_edit_mode(context)
if tool.Blender.toggle_edit_mode(context) == {"CANCELLED"}:
return {"CANCELLED"}
context.scene.BIMGeometryProperties.is_changing_mode = True
if context.scene.BIMGeometryProperties.mode != "EDIT":
context.scene.BIMGeometryProperties.mode = "EDIT"
@@ -694,6 +694,8 @@ class Blender(blenderbim.core.tool.Blender):
ao = context.active_object
if not ao:
return {"CANCELLED"}
if ao.library:
return {"CANCELLED"}
if ao.type in cls.OBJECT_TYPES_THAT_SUPPORT_EDIT_MODE:
return bpy.ops.object.mode_set(mode="EDIT", toggle=True)
elif ao.type in cls.OBJECT_TYPES_THAT_SUPPORT_EDIT_GPENCIL_MODE: