[Bf-extensions-cvs] [f14a0237] master: Collection Manager: Fix exclusion toggle/isolation. Task: T69577

Ryan Inch noreply at git.blender.org
Sun Nov 3 06:45:08 CET 2019


Commit: f14a0237875ecf19b801e549573f6d52c68c9d35
Author: Ryan Inch
Date:   Sun Nov 3 01:43:21 2019 -0400
Branches: master
https://developer.blender.org/rBACf14a0237875ecf19b801e549573f6d52c68c9d35

Collection Manager: Fix exclusion toggle/isolation.  Task: T69577

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

M	collection_manager/__init__.py
M	collection_manager/operators.py

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

diff --git a/collection_manager/__init__.py b/collection_manager/__init__.py
index 3406def1..4da954d9 100644
--- a/collection_manager/__init__.py
+++ b/collection_manager/__init__.py
@@ -23,7 +23,7 @@ bl_info = {
     "name": "Collection Manager",
     "description": "Manage collections and their objects",
     "author": "Ryan Inch",
-    "version": (1,1,1),
+    "version": (1,1,2),
     "blender": (2, 80, 0),
     "location": "View3D - Object Mode",
     "warning": '',  # used for warning icon and text in addons panel
diff --git a/collection_manager/operators.py b/collection_manager/operators.py
index 9ece24a2..6f8ba5ae 100644
--- a/collection_manager/operators.py
+++ b/collection_manager/operators.py
@@ -138,6 +138,8 @@ class CMExcludeOperator(bpy.types.Operator):
         
         if event.shift:
             # isolate/de-isolate exclusion of collections
+            
+            # get active layer collections
             active_layer_collections = [x for x in layer_collections.values() \
                                           if x["ptr"].exclude == False]
             
@@ -145,8 +147,8 @@ class CMExcludeOperator(bpy.types.Operator):
             if len(active_layer_collections) == 1 and active_layer_collections[0]["name"] == self.name:
                 if len(exclude_history) > 1:
                     # restore previous state
-                    for item in exclude_history:
-                        item["ptr"].exclude = False
+                    for x, item in enumerate(layer_collections.values()):
+                        item["ptr"].exclude = exclude_history[x]
                 
                 else:
                     # enable all collections
@@ -154,8 +156,21 @@ class CMExcludeOperator(bpy.types.Operator):
                         item["ptr"].exclude = False
             
             else:
+                # isolate collection
+                
+                # reset exclude history
+                exclude_history.clear()
+                
                 # save state
-                exclude_history = active_layer_collections
+                keep_history = -1
+                for item in layer_collections.values():
+                    exclude_history.append(item["ptr"].exclude)
+                    if item["ptr"].exclude == False:
+                        keep_history += 1
+                
+                if not keep_history:
+                    exclude_history.clear()
+                
                 
                 # isolate collection
                 for item in layer_collections.values():
@@ -178,12 +193,35 @@ class CMExcludeOperator(bpy.types.Operator):
                             
         
         else:
+            # toggle exclusion
+            
             # reset exclude history
             exclude_history.clear()
             
+            
+            # get current child exclusion state
+            child_exclusion = []
+            
+            laycol_iter_list = [laycol_ptr.children]
+            while len(laycol_iter_list) > 0:
+                new_laycol_iter_list = []
+                for laycol_iter in laycol_iter_list:
+                    for layer_collection in laycol_iter:
+                        child_exclusion.append([layer_collection, layer_collection.exclude])
+                        if len(layer_collection.children) > 0:
+                            new_laycol_iter_list.append(layer_collection.children)
+                
+                laycol_iter_list = new_laycol_iter_list
+            
+            
             # toggle exclusion of collection
             laycol_ptr.exclude = not laycol_ptr.exclude
             
+            
+            # set correct state for all children
+            for laycol in child_exclusion:
+                laycol[0].exclude = laycol[1]
+            
         
         # reset exclude all history
         excludeall_history.clear()



More information about the Bf-extensions-cvs mailing list