[Bf-extensions-cvs] [975f81d2] master: Collection Manager: Fix active object bug. Task: T69577

Ryan Inch noreply at git.blender.org
Sat Sep 26 09:43:26 CEST 2020


Commit: 975f81d2bc5b446b144f0ecd8ed5be06b111073f
Author: Ryan Inch
Date:   Sat Sep 26 03:40:03 2020 -0400
Branches: master
https://developer.blender.org/rBA975f81d2bc5b446b144f0ecd8ed5be06b111073f

Collection Manager: Fix active object bug. Task: T69577

Fixes losing the active object sometimes when performing actions
with the exclude checkbox.

===================================================================

M	object_collection_manager/__init__.py
M	object_collection_manager/operators.py

===================================================================

diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py
index 792f5d1c..49ec349f 100644
--- a/object_collection_manager/__init__.py
+++ b/object_collection_manager/__init__.py
@@ -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
diff --git a/object_collection_manager/operators.py b/object_collection_manager/operators.py
index b18fc44a..e2412419 100644
--- a/object_collection_manager/operators.py
+++ b/object_collection_manager/operators.py
@@ -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'}



More information about the Bf-extensions-cvs mailing list