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.)...
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user