Fix #5941. Context override when adding objects should only have one object. This is a temporary fix.

The proper fix is to refactor add_door and friends into core. That way
it can be properly reused instead of this hacky context override.
This commit is contained in:
Dion Moult
2025-01-12 22:39:32 +11:00
parent 2d38d8520c
commit 8364c87777
2 changed files with 6 additions and 6 deletions
@@ -532,19 +532,19 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator):
"material.assign_profile", tool.Ifc.get(), material_profile=material_profile, profile=profile
)
elif representation_template == "WINDOW":
with context.temp_override(active_object=obj):
with context.temp_override(active_object=obj, selected_objects=[]):
bpy.ops.bim.add_window()
elif representation_template == "DOOR":
with context.temp_override(active_object=obj):
with context.temp_override(active_object=obj, selected_objects=[]):
bpy.ops.bim.add_door()
elif representation_template == "STAIR":
with context.temp_override(active_object=obj):
with context.temp_override(active_object=obj, selected_objects=[]):
bpy.ops.bim.add_stair()
elif representation_template == "RAILING":
with context.temp_override(active_object=obj):
with context.temp_override(active_object=obj, selected_objects=[]):
bpy.ops.bim.add_railing()
elif representation_template == "ROOF":
with context.temp_override(active_object=obj):
with context.temp_override(active_object=obj, selected_objects=[]):
bpy.ops.bim.add_roof()
def draw(self, context):
+1 -1
View File
@@ -144,7 +144,7 @@ class Blender(bonsai.core.tool.Blender):
@classmethod
def get_active_object(cls) -> bpy.types.Object:
return bpy.context.view_layer.objects.active or getattr(bpy.context, "active_object", None)
return getattr(bpy.context, "active_object", None) or bpy.context.view_layer.objects.active
@classmethod
def get_selected_objects(cls) -> set[bpy.types.Object]: