Differentiate Append and Import loaders

This commit is contained in:
Simone Barbieri 2022-12-16 11:17:34 +00:00
parent 2a49265ba7
commit c053762fed

View file

@ -16,7 +16,7 @@ class AppendBlendLoader(plugin.AssetLoader):
families = ["*"]
label = "Append Workfile"
order = 10
order = 9
icon = "arrow-circle-down"
color = "#775555"
@ -25,10 +25,37 @@ class AppendBlendLoader(plugin.AssetLoader):
for attr in dir(data_to):
setattr(data_to, attr, getattr(data_from, attr))
# We do not containerize imported content, it remains unmanaged
return
class ImportBlendLoader(plugin.AssetLoader):
"""Import workfile in the current Blender scene (unmanaged)
Warning:
The loaded content will be unmanaged and is *not* visible in the
scene inventory. It's purely intended to merge content into your scene
so you could also use it as a new base.
"""
representations = ["blend"]
families = ["*"]
label = "Import Workfile"
order = 9
icon = "arrow-circle-down"
color = "#775555"
def load(self, context, name=None, namespace=None, data=None):
with bpy.data.libraries.load(self.fname) as (data_from, data_to):
for attr in dir(data_to):
if attr == "scenes":
continue
setattr(data_to, attr, getattr(data_from, attr))
# Add objects to current scene
# scene = bpy.context.scene
# for obj in data_to.objects:
# scene.collection.objects.link(obj)
scene = bpy.context.scene
for obj in data_to.objects:
scene.collection.objects.link(obj)
# We do not containerize imported content, it remains unmanaged
return