from .datafile import Resource
dummy_res = Resource("dummy", "dummy")
+ orig_scene = ctx.context.window.scene
+
ctx.set_slices(len(objects))
- for obj in objects:
- task = ctx.next_slice(obj)
- res_name = None
- res = None
- if obj.type=='MESH':
- res_name = obj.name+".object"
- if res_name not in resources:
- if not object_exporter:
- from .export_object import ObjectExporter
- object_exporter = ObjectExporter()
- object_exporter.export_object_resources(task, obj, resources)
- res = object_exporter.export_object(obj, resources)
- elif obj.type=='CAMERA':
- res_name = obj.name+".camera"
- if res_name not in resources:
- if not camera_exporter:
- from .export_camera import CameraExporter
- camera_exporter = CameraExporter()
- res = camera_exporter.export_camera(obj)
- elif obj.type=='ARMATURE':
- res_name = obj.name+".arma"
- if res_name not in resources:
- if not armature_exporter:
- from .export_armature import ArmatureExporter
- armature_exporter = ArmatureExporter()
- res = armature_exporter.export_armature(obj)
- elif obj.type=='LIGHT':
- res_name = obj.name+".light"
- if res_name not in resources:
- if not light_exporter:
- from .export_light import LightExporter
- light_exporter = LightExporter()
- res = light_exporter.export_light(obj)
-
- if res:
- resources[res_name] = res
- dummy_res.create_reference_statement("ref", res)
+ for s in ctx.context.blend_data.scenes:
+ scene_objects = set(s.collection.all_objects)
+
+ first = True
+ remaining_objects = []
+ for obj in objects:
+ if not obj in scene_objects:
+ remaining_objects.append(obj)
+ continue
+
+ if first:
+ ctx.context.window.scene = s
+ first = False
+
+ task = ctx.next_slice(obj)
+ res_name = None
+ res = None
+ if obj.type=='MESH':
+ res_name = obj.name+".object"
+ if res_name not in resources:
+ if not object_exporter:
+ from .export_object import ObjectExporter
+ object_exporter = ObjectExporter()
+ object_exporter.export_object_resources(task, obj, resources)
+ res = object_exporter.export_object(obj, resources)
+ elif obj.type=='CAMERA':
+ res_name = obj.name+".camera"
+ if res_name not in resources:
+ if not camera_exporter:
+ from .export_camera import CameraExporter
+ camera_exporter = CameraExporter()
+ res = camera_exporter.export_camera(obj)
+ elif obj.type=='ARMATURE':
+ res_name = obj.name+".arma"
+ if res_name not in resources:
+ if not armature_exporter:
+ from .export_armature import ArmatureExporter
+ armature_exporter = ArmatureExporter()
+ res = armature_exporter.export_armature(obj)
+ elif obj.type=='LIGHT':
+ res_name = obj.name+".light"
+ if res_name not in resources:
+ if not light_exporter:
+ from .export_light import LightExporter
+ light_exporter = LightExporter()
+ res = light_exporter.export_light(obj)
+
+ if res:
+ resources[res_name] = res
+ dummy_res.create_reference_statement("ref", res)
+
+ if not remaining_objects:
+ break
+ objects = remaining_objects
+
+ ctx.context.window.scene = orig_scene
return dummy_res