From 9a46920945a98a3fe87020b1c8eb576ce18c0590 Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Tue, 28 Sep 2021 13:12:19 +0100 Subject: [PATCH] Packs images used by meshes in the blend file --- .../hosts/blender/plugins/publish/extract_blend.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/openpype/hosts/blender/plugins/publish/extract_blend.py b/openpype/hosts/blender/plugins/publish/extract_blend.py index 6687c9fe76..e880b1bde0 100644 --- a/openpype/hosts/blender/plugins/publish/extract_blend.py +++ b/openpype/hosts/blender/plugins/publish/extract_blend.py @@ -28,6 +28,16 @@ class ExtractBlend(openpype.api.Extractor): for obj in instance: data_blocks.add(obj) + # Pack used images in the blend files. + if obj.type == 'MESH': + for material_slot in obj.material_slots: + mat = material_slot.material + if mat and mat.use_nodes: + tree = mat.node_tree + if tree.type == 'SHADER': + for node in tree.nodes: + if node.bl_idname == 'ShaderNodeTexImage': + node.image.pack() bpy.data.libraries.write(filepath, data_blocks)