-from bpy_extras.io_utils import ExportHelper
-
-class ExportMspGLBase(ExportHelper):
- show_progress = bpy.props.BoolProperty(name="Show progress", description="Display progress indicator while exporting", default=True)
+import bpy_extras
+
+class ExportHelper(bpy_extras.io_utils.ExportHelper):
+ def set_extension(self, ext):
+ ext_changed = (ext!=self.filename_ext)
+ if ext_changed:
+ if self.filepath.endswith(self.filename_ext):
+ self.filepath = self.filepath[:-len(self.filename_ext)]
+ self.filename_ext = ext
+ return ext_changed
+
+class ExportMspGLData(bpy.types.Operator):
+ bl_idname = "export.mspgl_data"
+ bl_label = "Export Msp GL data"
+ bl_description = "Export object data in Msp GL format"
+
+ filepath: bpy.props.StringProperty(name="File path", description="File path for exporting the data", subtype='FILE_PATH')
+ collection: bpy.props.BoolProperty(name="As a collection", description="Export all data as a single collection file", default=False)
+ shared_resources: bpy.props.BoolProperty(name="Shared resources", description="Use global names for resource files to enable sharing", default=True)
+
+ @classmethod
+ def poll(cls, context):
+ return len(context.selected_objects)>0
+
+ def invoke(self, context, event):
+ blend_filepath = context.blend_data.filepath
+ if blend_filepath:
+ self.filepath = os.path.splitext(blend_filepath)[0]+".mdc"
+ else:
+ self.filepath = "data.mdc"
+ context.window_manager.fileselect_add(self)
+ return {'RUNNING_MODAL'}