import itertools
+import os
import bpy
import mathutils
self.show_progress = True
self.use_strips = True
self.use_degen_tris = False
+ self.export_all = False
def join_strips(self, strips):
big_strip = []
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)
- with open(out_fn, "w") as out_file:
- for s in resource.statements:
- s.write_to_file(out_file)
+ 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
progress.pop_task()
from .datafile import Resource, Statement, Token
- resource = Resource(mesh.name+".mesh")
+ resource = Resource(mesh.name+".mesh", "mesh")
statements = resource.statements
st = Statement("vertices", Token("NORMAL3"))