fix missing camera collection when importing
This commit is contained in:
parent
6d64d6df7f
commit
365bd93408
@ -4,7 +4,7 @@ bl_info = {
|
||||
"name": "Background plane manager",
|
||||
"description": "Manage the background image planes and grease pencil object relative to a camera",
|
||||
"author": "Samuel Bernou",
|
||||
"version": (0, 5, 3),
|
||||
"version": (0, 5, 4),
|
||||
"blender": (3, 5, 0),
|
||||
"location": "View3D",
|
||||
"warning": "",
|
||||
|
23
core.py
23
core.py
@ -296,28 +296,35 @@ def set_collection(ob, collection, unlink=True) :
|
||||
|
||||
# check if collection exist or create it
|
||||
for c in bpy.data.collections :
|
||||
if c.name == collection : col = c
|
||||
if c.name == collection :
|
||||
col = c
|
||||
if not col :
|
||||
col = bpy.data.collections.new(name=collection)
|
||||
|
||||
# link the collection to the scene's collection if necessary
|
||||
# for c in scn.collection.children :
|
||||
# if c.name == col.name : visible = True
|
||||
# if not visible : scn.collection.children.link(col)
|
||||
for c in scn.collection.children :
|
||||
if c.name == col.name :
|
||||
visible = True
|
||||
if not visible :
|
||||
scn.collection.children.link(col)
|
||||
|
||||
# check if the object is already in the collection and link it if necessary
|
||||
for o in col.objects :
|
||||
if o == ob : linked = True
|
||||
if not linked : col.objects.link(ob)
|
||||
if o == ob :
|
||||
linked = True
|
||||
if not linked :
|
||||
col.objects.link(ob)
|
||||
|
||||
# remove object from scene's collection
|
||||
for o in scn.collection.objects :
|
||||
if o == ob : scn.collection.objects.unlink(ob)
|
||||
if o == ob :
|
||||
scn.collection.objects.unlink(ob)
|
||||
|
||||
# if unlink flag we remove the object from other collections
|
||||
if unlink :
|
||||
for c in ob.users_collection :
|
||||
if c.name != collection : c.objects.unlink(ob)
|
||||
if c.name != collection :
|
||||
c.objects.unlink(ob)
|
||||
|
||||
return col
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user