5 self.collection = False
6 self.shared_resources = True
8 def export_to_file(self, context, out_fn):
9 from .util import Progress
10 progress = Progress(context)
12 objects = context.selected_objects
17 dummy_res = self.export_resources(context, objects, resources, material_atlases, progress)
19 path, base = os.path.split(out_fn)
20 base, ext = os.path.splitext(base)
22 refs = dummy_res.collect_references()
23 if not self.shared_resources:
26 res_ext = os.path.splitext(r.name)[1]
27 n = numbers.get(res_ext, 0)
29 r.name = "{}_{}{}".format(base, n, res_ext)
32 numbers[res_ext] = n+1
35 dummy_res.write_collection(out_fn, exclude_self=True)
38 r.write_to_file(os.path.join(path, r.name))
40 def export_resources(self, context, objects, resources, material_atlases, progress):
41 if material_atlases is None:
44 object_exporter = None
45 camera_exporter = None
46 armature_exporter = None
48 from .datafile import Resource
49 dummy_res = Resource("dummy", "dummy")
51 for i, obj in enumerate(objects):
52 progress.push_task_slice(obj.name, i, len(objects))
56 res_name = obj.name+".object"
57 if res_name not in resources:
58 if not object_exporter:
59 from .export_object import ObjectExporter
60 object_exporter = ObjectExporter()
61 object_exporter.export_object_resources(context, obj, resources, material_atlases, progress)
62 res = object_exporter.export_object(obj, resources, progress)
63 elif obj.type=='CAMERA':
64 res_name = obj.name+".camera"
65 if res_name not in resources:
66 if not camera_exporter:
67 from .export_camera import CameraExporter
68 camera_exporter = CameraExporter()
69 res = camera_exporter.export_camera(obj)
70 elif obj.type=='ARMATURE':
71 res_name = obj.name+".arma"
72 if res_name not in resources:
73 if not armature_exporter:
74 from .export_armature import ArmatureExporter
75 armature_exporter = ArmatureExporter()
76 res = armature_exporter.export_armature(context, obj)
79 resources[res_name] = res
80 dummy_res.create_reference_statement("ref", res)