Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2018-11-06 19:20:49 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-11-06 19:20:49 +0300
commit7b38df41ae8b2903eb65dc72e506ba0b0c58453d (patch)
tree61b841a5f634a1b6806688c1fb4b563b92b7e99a /release/scripts/modules/bpy_extras
parentaa9912ec045e3209bc87c48801fd955c59bd0908 (diff)
Fix/cleanup RNA viewlayer API.
RNA's ViewLayer would present 'first level' of layer collection as a list (collection property), when it is actually now only a single item, same as the scene's master collection. Note: did not try to update view_layer python tests, those are already fully broken for quiet some time I guess (they still assume view_layer.collections to be mutable e.g.)...
Diffstat (limited to 'release/scripts/modules/bpy_extras')
-rw-r--r--release/scripts/modules/bpy_extras/object_utils.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/release/scripts/modules/bpy_extras/object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py
index ab32daa9d67..dbb4a376099 100644
--- a/release/scripts/modules/bpy_extras/object_utils.py
+++ b/release/scripts/modules/bpy_extras/object_utils.py
@@ -121,18 +121,12 @@ def object_data_add(context, obdata, operator=None, name=None):
"""
scene = context.scene
layer = context.view_layer
- layer_collection = context.layer_collection
+ layer_collection = context.layer_collection or layer.active_layer_collection
+ scene_collection = layer_collection.collection
for ob in layer.objects:
ob.select_set(action='DESELECT')
- if not layer_collection:
- # when there is no collection linked to this view_layer create one
- scene_collection = scene.master_collection.collections.new("")
- layer_collection = layer.collections.link(scene_collection)
- else:
- scene_collection = layer_collection.collection
-
if name is None:
name = "Object" if obdata is None else obdata.name