diff --git a/__init__.py b/__init__.py index 496528b..bdf2c5b 100644 --- a/__init__.py +++ b/__init__.py @@ -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": "", diff --git a/core.py b/core.py index 074b2a4..c6b477e 100644 --- a/core.py +++ b/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