How do I export material preview scene data so I can render it with my own engine? I am implementing RenderEngine.render_preview(self, scene) and want to export the scene data, to then render it with my engine. I wrote the export script myself, so modifying it is an option, if that helps.

Any ideas are greatly appreciated!

PS: I tried:


Overriding the context for the operator: seems not to be an option, since it needs to contain active_object from the scene the material preview scene was created for. Results in a Blender crash, actually.
Adding a scene attribute to my exporter: cannot be passed to bpy.ops.export_scene.foo as blender properties would be.
bpy.props.PointerProperty: not an option, since you cannot point to Scenes. Usually you would pass the scene index, but in this case the material preview scene is special enough to not show up in bpy.data.
Two options:


If you really wanted to go the route of exporting the material preview scene, which would allow for forward compatibility in case the preview scene should ever change in blender, the only option would probably be to create a temporary scene, copy all the data from the scene received in the render_preview function and then export that. 


But this is probably not worth the hassle, so I recommend to anybody who needs something like this:


Get the material preview scene as a .blend from the blender code repository and export that once. Finally in the render_preview method, just manually serialize the material properties to get those into your custom engine.


I hope this helps somebody else struggling with this.