From 41614333968a199aabc270bc760bc8a9a9ae8b04 Mon Sep 17 00:00:00 2001
From: Chris Foster <cdbfoster@gmail.com>
Date: Tue, 3 May 2011 09:26:37 +0000
Subject: [PATCH] - Punctuation characters are now stripped from symbol names
 and replaced with underscores.

---
 io_export_directx_x.py | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/io_export_directx_x.py b/io_export_directx_x.py
index c1e52f7e7..64c25990c 100644
--- a/io_export_directx_x.py
+++ b/io_export_directx_x.py
@@ -66,8 +66,15 @@ class DirectXExporterSettings:
 
 
 def LegalName(Name):
-    NewName = Name.replace(".", "_")
-    NewName = NewName.replace(" ", "_")
+    
+    def ReplaceSet(String, OldSet, NewChar):
+        for OldChar in OldSet:
+            String = String.replace(OldChar, NewChar)
+        return String
+    
+    import string
+    
+    NewName = ReplaceSet(Name, string.punctuation, "_")
     if NewName[0].isdigit() or NewName in ["ARRAY",
                                            "DWORD",
                                            "UCHAR",
@@ -1199,10 +1206,8 @@ class DirectXExporter(bpy.types.Operator):
     Verbose = BoolProperty(name="Verbose", description="Run the exporter in debug mode.  Check the console for output.", default=False)
 
     def execute(self, context):
-        #Append .x if needed
-        FilePath = self.filepath
-        if not FilePath.lower().endswith(".x"):
-            FilePath += ".x"
+        #Append .x
+        FilePath = os.path.splitext(self.filepath)[0] + ".x"
 
         Config = DirectXExporterSettings(context,
                                          FilePath,
@@ -1243,4 +1248,4 @@ def unregister():
 
 
 if __name__ == "__main__":
-    register()
+    register()
\ No newline at end of file
-- 
GitLab