Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Inch <mythologylover75@gmail.com>2020-08-11 07:02:52 +0300
committerRyan Inch <mythologylover75@gmail.com>2020-08-11 07:02:52 +0300
commit1d1bb1a707554ce51696d85d2feb9718e34a0220 (patch)
treed17b7d663e1eb2ad9c41b36412148fc15dfe4a4a /object_collection_manager/operator_utils.py
parent8db46434a4b25569372a7172f83733ec14dffb31 (diff)
Collection Manager: Object selection. Task: T69577
Adds the ability to select all object in a QCD slot. Alt+LMB deselects everything and selects all objects in the QCD slot. Alt+Shift+LMB adds/removes objects in the QCD slot to/from the selection. Added a selection operator for use in the Collection Manager popup. (currently unused)
Diffstat (limited to 'object_collection_manager/operator_utils.py')
-rw-r--r--object_collection_manager/operator_utils.py48
1 files changed, 38 insertions, 10 deletions
diff --git a/object_collection_manager/operator_utils.py b/object_collection_manager/operator_utils.py
index d86a534f..ed7fce09 100644
--- a/object_collection_manager/operator_utils.py
+++ b/object_collection_manager/operator_utils.py
@@ -28,6 +28,7 @@ from .internals import (
copy_buffer,
swap_buffer,
update_property_group,
+ get_move_selection,
)
rto_path = {
@@ -57,20 +58,21 @@ def set_rto(layer_collection, rto, value):
setattr(collection, rto_path[rto].split(".")[1], value)
-def apply_to_children(laycol, apply_function):
- laycol_iter_list = [laycol.children]
+def apply_to_children(parent, apply_function):
+ # works for both Collections & LayerCollections
+ child_lists = [parent.children]
- while len(laycol_iter_list) > 0:
- new_laycol_iter_list = []
+ while child_lists:
+ new_child_lists = []
- for laycol_iter in laycol_iter_list:
- for layer_collection in laycol_iter:
- apply_function(layer_collection)
+ for child_list in child_lists:
+ for child in child_list:
+ apply_function(child)
- if len(layer_collection.children) > 0:
- new_laycol_iter_list.append(layer_collection.children)
+ if child.children:
+ new_child_lists.append(child.children)
- laycol_iter_list = new_laycol_iter_list
+ child_lists = new_child_lists
def isolate_rto(cls, self, view_layer, rto, *, children=False):
@@ -371,3 +373,29 @@ def remove_collection(laycol, collection, context):
laycol = laycol["parent"]
cm.cm_list_index = laycol["row_index"]
+
+
+def select_collection_objects(collection_index, collection_name, replace, nested):
+ if collection_index == 0:
+ target_collection = bpy.context.view_layer.layer_collection.collection
+
+ else:
+ laycol = layer_collections[collection_name]
+ target_collection = laycol["ptr"].collection
+
+ if replace:
+ bpy.ops.object.select_all(action='DESELECT')
+
+ selection_state = get_move_selection().isdisjoint(target_collection.objects)
+
+ def select_objects(collection):
+ for obj in collection.objects:
+ try:
+ obj.select_set(selection_state)
+ except RuntimeError:
+ pass
+
+ select_objects(target_collection)
+
+ if nested:
+ apply_to_children(target_collection, select_objects)