Collection Manager: Fix active object bug. Task: T69577
Fixes losing the active object sometimes when performing actions with the exclude checkbox.
This commit is contained in:
parent
bf176041da
commit
975f81d2bc
|
@ -22,7 +22,7 @@ bl_info = {
|
|||
"name": "Collection Manager",
|
||||
"description": "Manage collections and their objects",
|
||||
"author": "Ryan Inch",
|
||||
"version": (2, 15, 0),
|
||||
"version": (2, 15, 1),
|
||||
"blender": (2, 80, 0),
|
||||
"location": "View3D - Object Mode (Shortcut - M)",
|
||||
"warning": '', # used for warning icon and text in addons panel
|
||||
|
|
|
@ -399,6 +399,7 @@ class CMExcludeOperator(Operator):
|
|||
modifiers = get_modifiers(event)
|
||||
view_layer = context.view_layer.name
|
||||
orig_active_collection = context.view_layer.active_layer_collection
|
||||
orig_active_object = context.view_layer.objects.active
|
||||
laycol_ptr = layer_collections[self.name]["ptr"]
|
||||
|
||||
if not view_layer in rto_history["exclude"]:
|
||||
|
@ -429,9 +430,14 @@ class CMExcludeOperator(Operator):
|
|||
|
||||
cls.isolated = False
|
||||
|
||||
# reset active collection
|
||||
# restore active collection
|
||||
context.view_layer.active_layer_collection = orig_active_collection
|
||||
|
||||
# restore active object if possible
|
||||
if orig_active_object:
|
||||
if orig_active_object.name in context.view_layer.objects:
|
||||
context.view_layer.objects.active = orig_active_object
|
||||
|
||||
# reset exclude all history
|
||||
if view_layer in rto_history["exclude_all"]:
|
||||
del rto_history["exclude_all"][view_layer]
|
||||
|
@ -455,6 +461,7 @@ class CMUnExcludeAllOperator(Operator):
|
|||
global rto_history
|
||||
|
||||
orig_active_collection = context.view_layer.active_layer_collection
|
||||
orig_active_object = context.view_layer.objects.active
|
||||
view_layer = context.view_layer.name
|
||||
modifiers = get_modifiers(event)
|
||||
|
||||
|
@ -479,9 +486,14 @@ class CMUnExcludeAllOperator(Operator):
|
|||
else:
|
||||
activate_all_rtos(view_layer, "exclude")
|
||||
|
||||
# reset active collection
|
||||
# restore active collection
|
||||
context.view_layer.active_layer_collection = orig_active_collection
|
||||
|
||||
# restore active object if possible
|
||||
if orig_active_object:
|
||||
if orig_active_object.name in context.view_layer.objects:
|
||||
context.view_layer.objects.active = orig_active_object
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue