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.
This commit is contained in:
parent
e1f331e0af
commit
eba3a31f8b
|
@ -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
|
||||
|
|
|
@ -99,6 +99,7 @@ classes = (
|
|||
operators.CMRemoveCollectionOperator,
|
||||
operators.CMRemoveEmptyCollectionsOperator,
|
||||
operators.CMSelectCollectionObjectsOperator,
|
||||
operators.SelectAllCumulativeObjectsOperator,
|
||||
operators.CMSetCollectionOperator,
|
||||
operators.CMPhantomModeOperator,
|
||||
operators.CMApplyPhantomModeOperator,
|
||||
|
|
|
@ -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 = (
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue