Compare commits

...

1 Commits
master ... gpv2

Author SHA1 Message Date
pullusb
365bd93408 fix missing camera collection when importing 2025-05-26 15:46:06 +02:00
2 changed files with 16 additions and 9 deletions

View File

@ -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
View File

@ -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