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-01-07 10:58:56 +0300
committerRyan Inch <mythologylover75@gmail.com>2020-01-07 10:58:56 +0300
commit8b202fb6dccb9dc67ea78bc525e2875f7b1f6345 (patch)
treef3162b7a5695f3364db4eeae0895b2436ce51054
parentdc0def220d6f1dccc5fb3dae079fbed548026d00 (diff)
Collection Manager: Improve remove collection operator. Task: T69577
-rw-r--r--object_collection_manager/__init__.py2
-rw-r--r--object_collection_manager/operators.py64
2 files changed, 7 insertions, 59 deletions
diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py
index e624083c..e5ca072f 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": (1,8,5),
+ "version": (1,8,6),
"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 ce1c4178..7e65c9cb 100644
--- a/object_collection_manager/operators.py
+++ b/object_collection_manager/operators.py
@@ -993,78 +993,26 @@ class CMRemoveCollectionOperator(Operator):
laycol = layer_collections[self.collection_name]
collection = laycol["ptr"].collection
- laycol_parent = laycol["parent"]
-
- # save state and remove all hiding properties of parent collection
- orig_parent_hide_select = False
- orig_parent_exclude = False
- orig_parent_hide_viewport = False
-
- if laycol_parent["ptr"].collection.hide_select:
- orig_parent_hide_select = True
-
- if laycol_parent["ptr"].exclude:
- orig_parent_exclude = True
-
- if laycol_parent["ptr"].hide_viewport:
- orig_parent_hide_viewport = True
-
- laycol_parent["ptr"].collection.hide_select = False
- laycol_parent["ptr"].exclude = False
- laycol_parent["ptr"].hide_viewport = False
-
-
- # remove all hiding properties of this collection
- collection.hide_select = False
- laycol["ptr"].exclude = False
- laycol["ptr"].hide_viewport = False
+ parent_collection = laycol["parent"]["ptr"].collection
# shift all objects in this collection to the parent collection
- if collection.objects:
- orig_selected_objs = context.selected_objects
- orig_active_obj = context.active_object
-
- # select all objects in collection
- bpy.ops.object.select_same_collection(collection=collection.name)
- context.view_layer.objects.active = context.selected_objects[0]
-
- # remove any objects already in parent collection from selection
- for obj in context.selected_objects:
- if obj in laycol["parent"]["ptr"].collection.objects.values():
- obj.select_set(False)
-
- # link selected objects to parent collection
- bpy.ops.object.link_to_collection(collection_index=laycol_parent["id"])
-
- # remove objects from collection
- bpy.ops.collection.objects_remove(collection=collection.name)
-
- # reset selection original values
- bpy.ops.object.select_all(action='DESELECT')
-
- for obj in orig_selected_objs:
- obj.select_set(True)
- context.view_layer.objects.active = orig_active_obj
+ for obj in collection.objects:
+ if obj.name not in parent_collection.objects:
+ parent_collection.objects.link(obj)
# shift all child collections to the parent collection
if collection.children:
for subcollection in collection.children:
- laycol_parent["ptr"].collection.children.link(subcollection)
-
- # reset hiding properties of parent collection
- laycol_parent["ptr"].collection.hide_select = orig_parent_hide_select
- laycol_parent["ptr"].exclude = orig_parent_exclude
- laycol_parent["ptr"].hide_viewport = orig_parent_hide_viewport
+ parent_collection.children.link(subcollection)
# remove collection and update tree view
bpy.data.collections.remove(collection)
-
-
update_property_group(context)
+
if len(context.scene.CMListCollection) == context.scene.CMListIndex:
context.scene.CMListIndex = len(context.scene.CMListCollection) - 1
update_property_group(context)