diff --git a/openpype/hosts/blender/plugins/load/import_workfile.py b/openpype/hosts/blender/plugins/load/import_workfile.py index 244eefe936..2849031f7e 100644 --- a/openpype/hosts/blender/plugins/load/import_workfile.py +++ b/openpype/hosts/blender/plugins/load/import_workfile.py @@ -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