[Bf-extensions-cvs] [eba3a31f] master: Collection Manager: Select cumulative objects. Task: T69577
Ryan Inch
noreply at git.blender.org
Mon Jul 12 06:39:03 CEST 2021
Commit: eba3a31f8bed7087db9a026514ffe85bea0a64c0
Author: Ryan Inch
Date: Mon Jul 12 00:35:19 2021 -0400
Branches: master
https://developer.blender.org/rBAeba3a31f8bed7087db9a026514ffe85bea0a64c0
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.
===================================================================
M object_collection_manager/__init__.py
M object_collection_manager/cm_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 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"
More information about the Bf-extensions-cvs
mailing list