diff options
author | Ryan Inch <mythologylover75@gmail.com> | 2021-07-12 07:35:19 +0300 |
---|---|---|
committer | Ryan Inch <mythologylover75@gmail.com> | 2021-07-12 07:35:19 +0300 |
commit | eba3a31f8bed7087db9a026514ffe85bea0a64c0 (patch) | |
tree | c842f61dae6a7e8447e01ebbcdd5064346b13bcc | |
parent | e1f331e0af4461dbf80e03e76d9576fa748a0460 (diff) |
Collection Manager: Select cumulative objects. Task: T69577
Add operator to select all objects that are present in more than one collection.
The operator can be accessed from the specials menu in the CM popup.
-rw-r--r-- | object_collection_manager/__init__.py | 2 | ||||
-rw-r--r-- | object_collection_manager/cm_init.py | 1 | ||||
-rw-r--r-- | object_collection_manager/operators.py | 25 | ||||
-rw-r--r-- | object_collection_manager/ui.py | 4 |
4 files changed, 31 insertions, 1 deletions
diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py index ff8f8b60..fab811cd 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, 21, 4), + "version": (2, 22, 2), "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/cm_init.py b/object_collection_manager/cm_init.py index 61ff75e7..94301753 100644 --- a/object_collection_manager/cm_init.py +++ b/object_collection_manager/cm_init.py @@ -99,6 +99,7 @@ classes = ( operators.CMRemoveCollectionOperator, operators.CMRemoveEmptyCollectionsOperator, operators.CMSelectCollectionObjectsOperator, + operators.SelectAllCumulativeObjectsOperator, operators.CMSetCollectionOperator, operators.CMPhantomModeOperator, operators.CMApplyPhantomModeOperator, diff --git a/object_collection_manager/operators.py b/object_collection_manager/operators.py index cfa4146c..afcfb266 100644 --- a/object_collection_manager/operators.py +++ b/object_collection_manager/operators.py @@ -265,6 +265,31 @@ class CMSelectCollectionObjectsOperator(Operator): return {'FINISHED'} +class SelectAllCumulativeObjectsOperator(Operator): + '''Select all objects that are present in more than one collection''' + bl_label = "Select All Cumulative Objects" + bl_idname = "view3d.select_all_cumulative_objects" + + def execute(self, context): + selected_cumulative_objects = 0 + total_cumulative_objects = 0 + + bpy.ops.object.select_all(action='DESELECT') + + for obj in bpy.data.objects: + if len(obj.users_collection) > 1: + if obj.visible_get(): + obj.select_set(True) + if obj.select_get() == True: # needed because obj.select_set can fail silently + selected_cumulative_objects +=1 + + total_cumulative_objects += 1 + + self.report({'INFO'}, f"{selected_cumulative_objects}/{total_cumulative_objects} Cumulative Objects Selected") + + return {'FINISHED'} + + class CMSetCollectionOperator(Operator): bl_label = "Set Object Collection" bl_description = ( diff --git a/object_collection_manager/ui.py b/object_collection_manager/ui.py index 82f5f6e2..68da7323 100644 --- a/object_collection_manager/ui.py +++ b/object_collection_manager/ui.py @@ -1006,6 +1006,10 @@ class SpecialsMenu(Menu): text="Purge All Collections Without Objects") prop.without_objects = True + layout.separator() + + layout.operator("view3d.select_all_cumulative_objects") + class EnableAllQCDSlotsMenu(Menu): bl_label = "Global QCD Slot Actions" |