X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=blender%2Fio_mspgl%2Fexport_mesh.py;h=974685b3d1fa8cf0ae579bea292dd7676a8e47a3;hp=0bf7b83af6fb6be4581f0dcfcbebd04674ddc17b;hb=b35fe097720395c09332cf0813ef6218acb551b6;hpb=46752f789ea3d23928e96ce451ea96c78c694b93 diff --git a/blender/io_mspgl/export_mesh.py b/blender/io_mspgl/export_mesh.py index 0bf7b83a..974685b3 100644 --- a/blender/io_mspgl/export_mesh.py +++ b/blender/io_mspgl/export_mesh.py @@ -1,4 +1,5 @@ import itertools +import os import bpy import mathutils @@ -7,6 +8,7 @@ class MeshExporter: self.show_progress = True self.use_strips = True self.use_degen_tris = False + self.export_all = False def join_strips(self, strips): big_strip = [] @@ -26,15 +28,26 @@ class MeshExporter: return big_strip def export_to_file(self, context, out_fn): - obj = context.active_object + if self.export_all: + objs = [o for o in context.selected_objects if o.type=="MESH"] + else: + objs = [context.active_object] from .util import Progress + path, base = os.path.split(out_fn) + base, ext = os.path.splitext(base) + progress = Progress(self.show_progress and context) - progress.push_task("", 0.0, 0.95) - resource = self.export_mesh(context, obj, progress) + for i, obj in enumerate(objs): + if self.export_all: + out_fn = os.path.join(path, obj.data.name+ext) - resource.write_to_file(out_fn) + progress.push_task_slice(obj.data.name, i, len(objs)) + resource = self.export_mesh(context, obj, progress) + + resource.write_to_file(out_fn) + progress.pop_task() def export_mesh(self, context, mesh_or_obj, progress): from .mesh import Mesh, create_mesh_from_object