mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +00:00
Fix Assign Container operator loses active object (#1601)
* Fix Assign Container operator loses active object * Fix bad indentation for restoring active object
This commit is contained in:
@@ -17,6 +17,9 @@ class AssignContainer(bpy.types.Operator):
|
|||||||
return IfcStore.execute_ifc_operator(self, context)
|
return IfcStore.execute_ifc_operator(self, context)
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
|
# The active object pointer is lost when the object is unlinked from all collections in the view layer
|
||||||
|
# We need to store it first, then restore it at the end
|
||||||
|
active_object = context.active_object
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
related_elements = (
|
related_elements = (
|
||||||
[bpy.data.objects.get(self.related_element)] if self.related_element else bpy.context.selected_objects
|
[bpy.data.objects.get(self.related_element)] if self.related_element else bpy.context.selected_objects
|
||||||
@@ -57,6 +60,8 @@ class AssignContainer(bpy.types.Operator):
|
|||||||
for collection in related_element.users_collection:
|
for collection in related_element.users_collection:
|
||||||
collection.objects.unlink(related_element)
|
collection.objects.unlink(related_element)
|
||||||
relating_collection.objects.link(related_element)
|
relating_collection.objects.link(related_element)
|
||||||
|
# Restore the active object :
|
||||||
|
context.view_layer.objects.active = active_object
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
def remove_collection(self, parent, child):
|
def remove_collection(self, parent, child):
|
||||||
|
|||||||
Reference in New Issue
Block a user