Use a context override dictionary when calling the export operator.
authorLukas Tönne <lukas.toenne@gmail.com>
Thu, 5 Feb 2015 16:53:49 +0000 (17:53 +0100)
committerLukas Tönne <lukas.toenne@gmail.com>
Thu, 5 Feb 2015 16:53:49 +0000 (17:53 +0100)
This enables the operator to work with linked data as well.

cacharanth/meshcache.py

index 69f4104..ef6417b 100644 (file)
@@ -34,9 +34,18 @@ def meshcache_export(context, objects):
                 if mo.type == 'SUBSURF':
                     mo.show_viewport = False
 
-        context.scene.objects.active = ob
-
-        bpy.ops.export_shape.mdd(filepath=filename,
+        override = {
+            'blend_data' : context.blend_data,
+            'window' : context.window,
+            'screen' : context.screen,
+            'area' : context.area,
+            'region' : context.region,
+            'scene' : scene,
+            'active_object' : ob,
+            'object' : ob,
+            }
+        bpy.ops.export_shape.mdd(override,
+                                 filepath=filename,
                                  frame_start=scene.meshcache_frame_start,
                                  frame_end=scene.meshcache_frame_end,
                                  fps=scene.meshcache_frame_rate)