print(blend_filepath) collections = enable_collections() try: for obj in bpy.data.objects: if obj.parent or not obj.children: continue if obj.muproperties.modelType == 'UTILITY': continue object_queue.append(obj) while object_queue: obj = object_queue.pop(0) name = strip_nnn(obj.name)+".mu" filepath = os.path.join(blend_filepath, name) print(name, filepath) mu = export_object (obj, filepath) if mu.internals: object_queue.extend(mu.internals) for m in mu.messages: print(m) for tex in mu.textures: textures.add(tex.name) finally: restore_collections(collections) for tex in textures: if tex not in bpy.data.images: continue image = bpy.data.images[tex] if image.packed_files: name = tex + ".png"
import bpy import os from io_object_mu.export_mu import export_object, strip_nnn textures = set() blend_filepath = bpy.context.blend_data.filepath blend_filepath = os.path.dirname(blend_filepath) print(blend_filepath) for obj in bpy.data.objects: if not obj.hide_render and not obj.parent and obj.children: name = strip_nnn(obj.name)+".mu" filepath = os.path.join(blend_filepath, name) print(name, filepath) mu = export_object (obj, filepath) for m in mu.messages: print(m) for tex in mu.textures: textures.add(tex.name) for tex in textures: if tex not in bpy.data.images: continue image = bpy.data.images[tex] if image.packed_files: name = tex + ".png" path = os.path.join(blend_filepath, name) print(tex, image.type, path) image.filepath_raw = "//" + name image.packed_files[0].filepath = path