import itertools
class DataExporter:
- def __init__(self):
- self.collection = False
- self.shared_resources = True
-
- def export_to_file(self, context, out_fn):
+ def export_to_file(self, context, out_fn, *, collection=False, shared_resources=False):
from .util import Progress
progress = Progress(context)
base, ext = os.path.splitext(base)
refs = dummy_res.collect_references()
- if not self.shared_resources:
+ if not shared_resources:
numbers = {}
for r in refs:
res_ext = os.path.splitext(r.name)[1]
r.name = base+res_ext
numbers[res_ext] = n+1
- if self.collection:
+ if collection:
dummy_res.write_collection(out_fn, exclude_self=True)
else:
for r in refs:
import os
class AnimationExporter:
- def __init__(self):
- self.export_all = False
- self.collection = True
- self.looping_threshold = 0.001
-
- def export_to_file(self, context, out_fn):
- if self.export_all:
+ def export_to_file(self, context, out_fn, *, export_all=False, collection=True, looping_threshold=0.001):
+ if export_all:
actions = []
for o in context.selected_objects:
if not o.animation_data:
resources = {}
for a in actions:
- resources[a.name+".anim"] = self.export_animation(context, a)
+ resources[a.name+".anim"] = self.export_animation(context, a, looping_threshold=looping_threshold)
path, base = os.path.split(out_fn)
base, ext = os.path.splitext(base)
- if self.collection:
+ if collection:
from .datafile import Resource
dummy = Resource("dummy", "dummy")
dummy.references = list(sorted(resources.values(), key=lambda r: r.name))
resource.write_to_file(out_fn)
- def export_animation(self, context, action):
+ def export_animation(self, context, action, *, looping_threshold=0.001):
from .animation import create_animation_from_action
- anim = create_animation_from_action(context, action, looping_threshold=self.looping_threshold)
+ anim = create_animation_from_action(context, action, looping_threshold=looping_threshold)
from .datafile import Resource, Statement
resource = Resource(action.name+".anim", "animation")
import os
class SceneExporter:
- def __init__(self):
- self.selected_only = False
- self.visible_only = True
- self.collection = True
- self.skip_existing = True
-
- def export_to_file(self, context, out_fn):
+ def export_to_file(self, context, out_fn, *, selected_only=False, visible_only=True, collection=True, skip_existing=True):
from .util import Progress
progress = Progress(context)
from .scene import create_scene_from_current
- scene = create_scene_from_current(context, selected_only=self.selected_only, visible_only=self.visible_only)
+ scene = create_scene_from_current(context, selected_only=selected_only, visible_only=visible_only)
resources = {}
self.export_scene_resources(context, scene, resources, progress)
path, base = os.path.split(out_fn)
base, ext = os.path.splitext(base)
- if self.collection:
+ if collection:
existing = None
- if self.skip_existing:
+ if skip_existing:
existing = lambda r: not os.path.exists(os.path.join(path, r.name))
scene_res.write_collection(out_fn, filter=existing)
else:
def execute(self, context):
from .export import DataExporter
exporter = DataExporter()
- exporter.collection = self.collection
- exporter.shared_resources = self.shared_resources
- exporter.export_to_file(context, self.filepath)
+ exporter.export_to_file(context, self.filepath,
+ collection=self.collection,
+ shared_resources=self.shared_resources)
return {'FINISHED'}
def draw(self, context):
def execute(self, context):
from .export_animation import AnimationExporter
exporter = AnimationExporter()
- exporter.export_all = self.export_all
- exporter.collection = self.collection
- exporter.looping_threshold = self.looping_threshold
- exporter.export_to_file(context, self.filepath)
+ exporter.export_to_file(context, self.filepath,
+ export_all=self.export_all,
+ collection=self.collection,
+ looping_threshold=looping_threshold)
return {'FINISHED'}
def draw(self, context):
def execute(self, context):
from .export_scene import SceneExporter
exporter = SceneExporter()
- exporter.selected_only = self.selected_only
- exporter.visible_only = self.visible_only
- exporter.collection = self.collection
- exporter.skip_existing = self.skip_existing
- exporter.export_to_file(context, self.filepath)
+ exporter.export_to_file(context, self.filepath,
+ selected_only=self.selected_only,
+ visible_only=self.visible_only,
+ collection=self.collection,
+ skip_existing=self.skip_existing)
return {'FINISHED'}
def draw(self, context):