[Bf-extensions-cvs] [f5fbe860] master: Cleanup: trailing space
Campbell Barton
noreply at git.blender.org
Mon Dec 9 11:27:34 CET 2019
Commit: f5fbe860fe1962673de7a7d479287e418152faff
Author: Campbell Barton
Date: Mon Dec 9 21:03:28 2019 +1100
Branches: master
https://developer.blender.org/rBAf5fbe860fe1962673de7a7d479287e418152faff
Cleanup: trailing space
===================================================================
M object_collection_manager/__init__.py
M object_collection_manager/internals.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 75142a35..687f4fc7 100644
--- a/object_collection_manager/__init__.py
+++ b/object_collection_manager/__init__.py
@@ -33,7 +33,7 @@ bl_info = {
if "bpy" in locals():
import importlib
-
+
importlib.reload(internals)
importlib.reload(operators)
importlib.reload(ui)
@@ -78,16 +78,16 @@ classes = (
def register():
for cls in classes:
bpy.utils.register_class(cls)
-
+
bpy.types.Scene.CMListCollection = CollectionProperty(type=internals.CMListCollection)
bpy.types.Scene.CMListIndex = IntProperty(update=ui.update_selection)
-
+
bpy.types.Scene.show_exclude = BoolProperty(default=True, name="Exclude from View Layer")
bpy.types.Scene.show_selectable = BoolProperty(default=True, name="Selectable")
bpy.types.Scene.show_hideviewport = BoolProperty(default=True, name="Hide in Viewport")
bpy.types.Scene.show_disableviewport = BoolProperty(default=False, name="Disable in Viewports")
bpy.types.Scene.show_render = BoolProperty(default=False, name="Disable in Renders")
-
+
bpy.types.Scene.CM_Phantom_Mode = BoolProperty(default=False)
@@ -96,26 +96,26 @@ def register():
km = wm.keyconfigs.addon.keymaps.new(name='Object Mode')
kmi = km.keymap_items.new('view3d.collection_manager', 'M', 'PRESS')
addon_keymaps.append((km, kmi))
-
+
def unregister():
for cls in classes:
bpy.utils.unregister_class(cls)
-
+
del bpy.types.Scene.CMListCollection
del bpy.types.Scene.CMListIndex
-
+
del bpy.types.Scene.show_exclude
del bpy.types.Scene.show_selectable
del bpy.types.Scene.show_hideviewport
del bpy.types.Scene.show_disableviewport
del bpy.types.Scene.show_render
-
+
del bpy.types.Scene.CM_Phantom_Mode
-
+
# remove keymaps when add-on is deactivated
for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()
-
+
if __name__ == "__main__":
register()
diff --git a/object_collection_manager/internals.py b/object_collection_manager/internals.py
index e898de1c..8b440ce8 100644
--- a/object_collection_manager/internals.py
+++ b/object_collection_manager/internals.py
@@ -18,12 +18,12 @@ def update_col_name(self, context):
if self.name == '':
self.name = self.last_name
return
-
+
if self.last_name != '':
layer_collections[self.last_name]["ptr"].collection.name = self.name
-
+
update_property_group(context)
-
+
self.last_name = self.name
class CMListCollection(PropertyGroup):
@@ -38,9 +38,9 @@ def update_collection_tree(context):
layer_collections.clear()
max_lvl = 0
row_index = 0
-
+
init_laycol_list = context.view_layer.layer_collection.children
-
+
master_laycol = {"id": 0,
"name": context.view_layer.layer_collection.name,
"lvl": -1,
@@ -52,13 +52,13 @@ def update_collection_tree(context):
"children": [],
"ptr": context.view_layer.layer_collection
}
-
+
get_all_collections(context, init_laycol_list, master_laycol, collection_tree, visible=True)
def get_all_collections(context, collections, parent, tree, level=0, visible=False):
global row_index
-
+
for item in collections:
laycol = {"id": len(layer_collections) +1,
"name": item.name,
@@ -71,21 +71,21 @@ def get_all_collections(context, collections, parent, tree, level=0, visible=Fal
"children": [],
"ptr": item
}
-
+
row_index += 1
-
+
layer_collections[item.name] = laycol
tree.append(laycol)
-
+
if len(item.children) > 0:
global max_lvl
max_lvl += 1
laycol["has_children"] = True
-
+
if item.name in expanded and laycol["visible"]:
laycol["expanded"] = True
get_all_collections(context, item.children, laycol, laycol["children"], level+1, visible=True)
-
+
else:
get_all_collections(context, item.children, laycol, laycol["children"], level+1)
@@ -98,10 +98,10 @@ def update_property_group(context):
def create_property_group(context, tree):
global in_filter
-
+
for laycol in tree:
new_cm_listitem = context.scene.CMListCollection.add()
new_cm_listitem.name = laycol["name"]
-
+
if laycol["has_children"]:
create_property_group(context, laycol["children"])
diff --git a/object_collection_manager/operators.py b/object_collection_manager/operators.py
index 84396e7e..85a5a822 100644
--- a/object_collection_manager/operators.py
+++ b/object_collection_manager/operators.py
@@ -25,7 +25,7 @@ class ExpandAllOperator(bpy.types.Operator):
bl_label = "Expand All Items"
bl_idname = "view3d.expand_all_items"
bl_options = {'REGISTER', 'UNDO'}
-
+
def execute(self, context):
if len(expanded) > 0:
expanded.clear()
@@ -33,10 +33,10 @@ class ExpandAllOperator(bpy.types.Operator):
for laycol in layer_collections.values():
if laycol["ptr"].children:
expanded.append(laycol["name"])
-
+
# update tree view
update_property_group(context)
-
+
return {'FINISHED'}
@@ -45,16 +45,16 @@ class ExpandSublevelOperator(bpy.types.Operator):
bl_label = "Expand Sublevel Items"
bl_idname = "view3d.expand_sublevel"
bl_options = {'REGISTER', 'UNDO'}
-
+
expand: BoolProperty()
name: StringProperty()
index: IntProperty()
-
+
def invoke(self, context, event):
if event.shift:
# expand/collapse all subcollections
expand = None
-
+
# check whether to expand or collapse
if self.name in expanded:
expanded.remove(self.name)
@@ -62,7 +62,7 @@ class ExpandSublevelOperator(bpy.types.Operator):
else:
expanded.append(self.name)
expand = True
-
+
# do expanding/collapsing
def loop(laycol):
for item in laycol.children:
@@ -72,24 +72,24 @@ class ExpandSublevelOperator(bpy.types.Operator):
else:
if item.name in expanded:
expanded.remove(item.name)
-
+
if len(item.children) > 0:
loop(item)
-
+
loop(layer_collections[self.name]["ptr"])
-
+
else:
# expand/collapse collection
if self.expand:
expanded.append(self.name)
else:
expanded.remove(self.name)
-
-
+
+
# set selected row to the collection you're expanding/collapsing and update tree view
context.scene.CMListIndex = self.index
update_property_group(context)
-
+
return {'FINISHED'}
@@ -98,42 +98,42 @@ class CMSetCollectionOperator(bpy.types.Operator):
bl_label = "Set Object Collection"
bl_idname = "view3d.set_collection"
bl_options = {'REGISTER', 'UNDO'}
-
+
collection_index: IntProperty()
collection_name: StringProperty()
-
+
def invoke(self, context, event):
collection = layer_collections[self.collection_name]["ptr"].collection
-
+
if event.shift:
# add object to collection
-
+
# check if in collection
in_collection = True
-
+
for obj in context.selected_objects:
if obj.name not in collection.objects:
in_collection = False
-
+
if not in_collection:
# add to collection
bpy.ops.object.link_to_collection(collection_index=self.collection_index)
-
+
else:
# check and disallow removing from all collections
for obj in context.selected_objects:
if len(obj.users_collection) == 1:
send_report("Error removing 1 or more objects from this collection.\nObjects would be left without a collection")
-
+
return {'FINISHED'}
-
+
# remove from collection
bpy.ops.collection.objects_remove(collection=collection.name)
-
+
else:
# move object to collection
bpy.ops.object.move_to_collection(collection_index=self.collection_index)
-
+
return {'FINISHED'}
@@ -142,68 +142,68 @@ class CMExcludeOperator(bpy.types.Operator):
bl_label = "Exclude Collection from View Layer"
bl_idname = "view3d.exclude_collection"
bl_options = {'REGISTER', 'UNDO'}
-
+
name: StringProperty()
-
+
def invoke(self, context, event):
global rto_history
-
+
view_layer = context.view_layer.name
laycol_ptr = layer_collections[self.name]["ptr"]
-
+
if not view_layer in rto_history["exclude"]:
rto_history["exclude"][view_layer] = {"target": "", "history": []}
-
+
rto_history["exclude"][view_layer]["target"] = self.name
exclude_history = rto_history["exclude"][view_layer]["history"]
-
+
if event.shift:
# isolate/de-isolate exclusion of collections
-
+
# get active layer collections
active_layer_collections = [x for x in layer_collections.values() \
if x["ptr"].exclude == False]
-
+
# check if collection isolated
if len(active_layer_collections) == 1 and active_layer_collections[0]["name"] == self.nam
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list