[Bf-extensions-cvs] [f149e0a4] master: Collection Manager: Add swap RTOs feature. Task: T69577
Ryan Inch
noreply at git.blender.org
Wed Mar 18 05:49:11 CET 2020
Commit: f149e0a4442e2503e9910ff91c43105856a83387
Author: Ryan Inch
Date: Tue Mar 17 17:45:54 2020 -0400
Branches: master
https://developer.blender.org/rBAf149e0a4442e2503e9910ff91c43105856a83387
Collection Manager: Add swap RTOs feature. Task: T69577
===================================================================
M object_collection_manager/__init__.py
M object_collection_manager/operators.py
M object_collection_manager/ui.py
===================================================================
diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py
index c473e6c7..bf3959af 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,0,2),
+ "version": (2,1,0),
"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 067a5277..27b5a032 100644
--- a/object_collection_manager/operators.py
+++ b/object_collection_manager/operators.py
@@ -54,6 +54,8 @@ rto_history = {
"render_all": {}
}
+swap_buffer = {"A": {"RTO": "", "values": []}, "B": {"RTO": "", "values": []}}
+
class ExpandAllOperator(Operator):
'''Expand/Collapse all collections'''
bl_label = "Expand All Items"
@@ -405,7 +407,7 @@ class CMExcludeOperator(Operator):
class CMUnExcludeAllOperator(Operator):
- ''' * Click to toggle between current excluded state and all included.\n * Shift-Click to invert excluded status of all collections'''
+ ''' * Click to toggle between current excluded state and all included.\n * Shift-Click to invert excluded status of all collections\n * Ctrl-Alt-Click to swap RTOs'''
bl_label = "Toggle Excluded Status Of All Collections"
bl_idname = "view3d.un_exclude_all_collections"
bl_options = {'REGISTER', 'UNDO'}
@@ -420,6 +422,51 @@ class CMUnExcludeAllOperator(Operator):
exclude_all_history = rto_history["exclude_all"][view_layer]
+ if event.ctrl and event.alt:
+ global swap_buffer
+
+ if not swap_buffer["A"]["values"]:
+ # get A
+ swap_buffer["A"]["RTO"] = "exclude"
+ for laycol in layer_collections.values():
+ swap_buffer["A"]["values"].append(laycol["ptr"].exclude)
+
+ else:
+ if len(swap_buffer["A"]["values"]) != len(layer_collections):
+ return {'CANCELLED'}
+
+ # get B
+ swap_buffer["B"]["RTO"] = "exclude"
+ for laycol in layer_collections.values():
+ swap_buffer["B"]["values"].append(laycol["ptr"].exclude)
+
+ # swap A with B
+ for x, laycol in enumerate(layer_collections.values()):
+ attr_A = attr_B = laycol["ptr"]
+
+ # get attributes
+ RTO_A = swap_buffer["A"]["RTO"].split(".")
+ RTO_B = swap_buffer["B"]["RTO"].split(".")
+
+ if RTO_A[0] == "collection":
+ attr_A = getattr(attr_A, RTO_A[0])
+
+ if RTO_B[0] == "collection":
+ attr_B = getattr(attr_B, RTO_B[0])
+
+
+ # swap values
+ setattr(attr_A, RTO_A[-1], swap_buffer["B"]["values"][x])
+ setattr(attr_B, RTO_B[-1], swap_buffer["A"]["values"][x])
+
+ # clear swap buffer
+ swap_buffer["A"]["RTO"] = ""
+ swap_buffer["A"]["values"].clear()
+ swap_buffer["B"]["RTO"] = ""
+ swap_buffer["B"]["values"].clear()
+
+ return {'FINISHED'}
+
if len(exclude_all_history) == 0:
exclude_all_history.clear()
keep_history = False
@@ -648,7 +695,7 @@ class CMRestrictSelectOperator(Operator):
class CMUnRestrictSelectAllOperator(Operator):
- ''' * Click to toggle between current selectable state and all selectable.\n * Shift-Click to invert selectable status of all collections'''
+ ''' * Click to toggle between current selectable state and all selectable.\n * Shift-Click to invert selectable status of all collections\n * Ctrl-Alt-Click to swap RTOs'''
bl_label = "Toggle Selectable Status Of All Collections"
bl_idname = "view3d.un_restrict_select_all_collections"
bl_options = {'REGISTER', 'UNDO'}
@@ -663,6 +710,51 @@ class CMUnRestrictSelectAllOperator(Operator):
select_all_history = rto_history["select_all"][view_layer]
+ if event.ctrl and event.alt:
+ global swap_buffer
+
+ if not swap_buffer["A"]["values"]:
+ # get A
+ swap_buffer["A"]["RTO"] = "collection.hide_select"
+ for laycol in layer_collections.values():
+ swap_buffer["A"]["values"].append(laycol["ptr"].collection.hide_select)
+
+ else:
+ if len(swap_buffer["A"]["values"]) != len(layer_collections):
+ return {'CANCELLED'}
+
+ # get B
+ swap_buffer["B"]["RTO"] = "collection.hide_select"
+ for laycol in layer_collections.values():
+ swap_buffer["B"]["values"].append(laycol["ptr"].collection.hide_select)
+
+ # swap A with B
+ for x, laycol in enumerate(layer_collections.values()):
+ attr_A = attr_B = laycol["ptr"]
+
+ # get attributes
+ RTO_A = swap_buffer["A"]["RTO"].split(".")
+ RTO_B = swap_buffer["B"]["RTO"].split(".")
+
+ if RTO_A[0] == "collection":
+ attr_A = getattr(attr_A, RTO_A[0])
+
+ if RTO_B[0] == "collection":
+ attr_B = getattr(attr_B, RTO_B[0])
+
+
+ # swap values
+ setattr(attr_A, RTO_A[-1], swap_buffer["B"]["values"][x])
+ setattr(attr_B, RTO_B[-1], swap_buffer["A"]["values"][x])
+
+ # clear swap buffer
+ swap_buffer["A"]["RTO"] = ""
+ swap_buffer["A"]["values"].clear()
+ swap_buffer["B"]["RTO"] = ""
+ swap_buffer["B"]["values"].clear()
+
+ return {'FINISHED'}
+
if len(select_all_history) == 0:
select_all_history.clear()
keep_history = False
@@ -887,7 +979,7 @@ class CMHideOperator(Operator):
class CMUnHideAllOperator(Operator):
- ''' * Click to toggle between current visibility state and all visible.\n * Shift-Click to invert visibility status of all collections'''
+ ''' * Click to toggle between current visibility state and all visible.\n * Shift-Click to invert visibility status of all collections\n * Ctrl-Alt-Click to swap RTOs'''
bl_label = "Toggle Hidden Status Of All Collections"
bl_idname = "view3d.un_hide_all_collections"
bl_options = {'REGISTER', 'UNDO'}
@@ -902,6 +994,51 @@ class CMUnHideAllOperator(Operator):
hide_all_history = rto_history["hide_all"][view_layer]
+ if event.ctrl and event.alt:
+ global swap_buffer
+
+ if not swap_buffer["A"]["values"]:
+ # get A
+ swap_buffer["A"]["RTO"] = "hide_viewport"
+ for laycol in layer_collections.values():
+ swap_buffer["A"]["values"].append(laycol["ptr"].hide_viewport)
+
+ else:
+ if len(swap_buffer["A"]["values"]) != len(layer_collections):
+ return {'CANCELLED'}
+
+ # get B
+ swap_buffer["B"]["RTO"] = "hide_viewport"
+ for laycol in layer_collections.values():
+ swap_buffer["B"]["values"].append(laycol["ptr"].hide_viewport)
+
+ # swap A with B
+ for x, laycol in enumerate(layer_collections.values()):
+ attr_A = attr_B = laycol["ptr"]
+
+ # get attributes
+ RTO_A = swap_buffer["A"]["RTO"].split(".")
+ RTO_B = swap_buffer["B"]["RTO"].split(".")
+
+ if RTO_A[0] == "collection":
+ attr_A = getattr(attr_A, RTO_A[0])
+
+ if RTO_B[0] == "collection":
+ attr_B = getattr(attr_B, RTO_B[0])
+
+
+ # swap values
+ setattr(attr_A, RTO_A[-1], swap_buffer["B"]["values"][x])
+ setattr(attr_B, RTO_B[-1], swap_buffer["A"]["values"][x])
+
+ # clear swap buffer
+ swap_buffer["A"]["RTO"] = ""
+ swap_buffer["A"]["values"].clear()
+ swap_buffer["B"]["RTO"] = ""
+ swap_buffer["B"]["values"].clear()
+
+ return {'FINISHED'}
+
if len(hide_all_history) == 0:
hide_all_history.clear()
keep_history = False
@@ -1124,7 +1261,7 @@ class CMDisableViewportOperator(Operator):
class CMUnDisableViewportAllOperator(Operator):
- ''' * Click to toggle between current viewport display and all enabled.\n * Shift-Click to invert viewport display of all collections'''
+ ''' * Click to toggle between current viewport display and all enabled.\n * Shift-Click to invert viewport display of all collections\n * Ctrl-Alt-Click to swap RTOs'''
bl_label = "Toggle Viewport Display of All Collections"
bl_idname = "view3d.un_disable_viewport_all_collections"
bl_options = {'REGISTER', 'UNDO'}
@@ -1139,6 +1276,51 @@ class CMUnDisableViewportAllOperator(Operator):
disable_all_history = rto_history["disable_all"][view_layer]
+ if event.ctrl and event.alt:
+ global swap_buffer
+
+ if not swap_buffer["A"]["values"]:
+ # get A
+ swap_buffer["A"]["RTO"] = "collection.hide_viewport"
+ for laycol in layer_collections.values():
+ swap_buffer["A"]["values"].append(laycol["ptr"].collection.hide_viewport)
+
+ else:
+ if len(swap_buffer["A"]["values"]) != len(layer_collections):
+ return {'CANCELLED'}
+
+ # get B
+ swap_buffer["B"]["RTO"] = "collection.hide_viewport"
+ for laycol in layer_collections.values():
+ swap_buffer["B"]["values"].append(laycol["ptr"].c
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list