[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2085] trunk/py/scripts/addons/ io_export_directx_x.py: use nicer api functions for adding extension, and define enum items as static tuples.

Campbell Barton ideasman42 at gmail.com
Sun Jul 3 05:12:13 CEST 2011


Revision: 2085
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2085
Author:   campbellbarton
Date:     2011-07-03 03:12:09 +0000 (Sun, 03 Jul 2011)
Log Message:
-----------
use nicer api functions for adding extension, and define enum items as static tuples.

Modified Paths:
--------------
    trunk/py/scripts/addons/io_export_directx_x.py

Modified: trunk/py/scripts/addons/io_export_directx_x.py
===================================================================
--- trunk/py/scripts/addons/io_export_directx_x.py	2011-07-03 00:56:42 UTC (rev 2084)
+++ trunk/py/scripts/addons/io_export_directx_x.py	2011-07-03 03:12:09 UTC (rev 2085)
@@ -1164,22 +1164,28 @@
     if Config.Verbose:
         print("Done")
 
-CoordinateSystems = []
-CoordinateSystems.append(("1", "Left-Handed", ""))
-CoordinateSystems.append(("2", "Right-Handed", ""))
 
-AnimationModes = []
-AnimationModes.append(("0", "None", ""))
-AnimationModes.append(("1", "Keyframes Only", ""))
-AnimationModes.append(("2", "Full Animation", ""))
+CoordinateSystems = (
+    ("1", "Left-Handed", ""),
+    ("2", "Right-Handed", ""),
+    )
 
-ExportModes = []
-ExportModes.append(("1", "All Objects", ""))
-ExportModes.append(("2", "Selected Objects", ""))
 
-from bpy.props import *
+AnimationModes = (
+    ("0", "None", ""),
+    ("1", "Keyframes Only", ""),
+    ("2", "Full Animation", ""),
+    )
 
+ExportModes = (
+    ("1", "All Objects", ""),
+    ("2", "Selected Objects", ""),
+    )
 
+
+from bpy.props import StringProperty, EnumProperty, BoolProperty
+
+
 class DirectXExporter(bpy.types.Operator):
     """Export to the DirectX model format (.x)"""
 
@@ -1207,7 +1213,7 @@
 
     def execute(self, context):
         #Append .x
-        FilePath = os.path.splitext(self.filepath)[0] + ".x"
+        FilePath = bpy.path.ensure_ext(self.filepath, ".x")
 
         Config = DirectXExporterSettings(context,
                                          FilePath,
@@ -1221,18 +1227,20 @@
                                          ExportAnimation=self.ExportAnimation,
                                          ExportMode=self.ExportMode,
                                          Verbose=self.Verbose)
+
         ExportDirectX(Config)
         return {"FINISHED"}
 
     def invoke(self, context, event):
+        if not self.filepath:
+            self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ".x")
         WindowManager = context.window_manager
         WindowManager.fileselect_add(self)
         return {"RUNNING_MODAL"}
 
 
 def menu_func(self, context):
-    default_path = os.path.splitext(bpy.data.filepath)[0] + ".x"
-    self.layout.operator(DirectXExporter.bl_idname, text="DirectX (.x)").filepath = default_path
+    self.layout.operator(DirectXExporter.bl_idname, text="DirectX (.x)")
 
 
 def register():



More information about the Bf-extensions-cvs mailing list