From 475c45e4b1c3052885c222bd42afd4d78343b74a Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Wed, 14 Jul 2010 11:59:08 +0000 Subject: [PATCH] bugfix [#22843] Cannot export to folder with ".blend" on the end. --- io_anim_camera.py | 3 ++- io_export_directx_x.py | 4 +--- io_export_unreal_psk_psa.py | 10 +++++----- io_mesh_raw/__init__.py | 3 ++- io_mesh_stl/__init__.py | 3 ++- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/io_anim_camera.py b/io_anim_camera.py index d50fce1fa..1f1b51ab1 100644 --- a/io_anim_camera.py +++ b/io_anim_camera.py @@ -146,7 +146,8 @@ class CameraExporter(bpy.types.Operator): def menu_export(self, context): - default_path = bpy.data.filepath.replace(".blend", ".py") + import os + default_path = os.path.splitext(bpy.data.filepath)[0] + ".py" self.layout.operator(CameraExporter.bl_idname, text="Cameras & Markers (.py)").filepath = default_path diff --git a/io_export_directx_x.py b/io_export_directx_x.py index 8b41f01cd..40c1c931b 100644 --- a/io_export_directx_x.py +++ b/io_export_directx_x.py @@ -1038,9 +1038,7 @@ class DirectXExporter(bpy.types.Operator): def menu_func(self, context): - DefaultPath = bpy.data.filepath - if DefaultPath.endswith(".blend"): - DefaultPath = DefaultPath[:-6] + ".x" + DefaultPath = os.path.splitext(bpy.data.filepath)[0] + ".x" self.layout.operator(DirectXExporter.bl_idname, text="DirectX (.x)").filepath = DefaultPath diff --git a/io_export_unreal_psk_psa.py b/io_export_unreal_psk_psa.py index 81cdcf028..a49ad5216 100644 --- a/io_export_unreal_psk_psa.py +++ b/io_export_unreal_psk_psa.py @@ -1510,7 +1510,7 @@ class ExportUDKAnimData(bpy.types.Operator): def menu_func(self, context): bpy.context.scene.unrealexportpsk = True bpy.context.scene.unrealexportpsa = True - default_path = bpy.data.filepath.replace(".blend", ".psk") + default_path = os.path.splitext(bpy.data.filepath)[0] + ".psk" self.layout.operator("export.udk_anim_data", text="Skeleton Mesh / Animation Data (.psk/.psa)").filepath = default_path @@ -1521,7 +1521,7 @@ class VIEW3D_PT_unrealtools_objectmode(bpy.types.Panel): def poll(self, context): return context.active_object - + def draw(self, context): layout = self.layout #layout.label(text="Unreal Tools") @@ -1575,8 +1575,8 @@ class OBJECT_OT_UnrealExport(bpy.types.Operator): bpy.context.scene.unrealexportpsk = True bpy.context.scene.unrealexportpsa = True print("Exporting ALL...") - default_path = bpy.data.filepath.replace(".blend", ".psk") - print(dir(bpy.data.filepath)) + + default_path = os.path.splitext(bpy.data.filepath)[0] + ".psk" fs_callback(default_path, bpy.context, False) #self.report({'WARNING', 'INFO'}, exportmessage) @@ -1590,7 +1590,7 @@ def register(): bpy.types.register(VIEW3D_PT_unrealtools_objectmode) bpy.types.register(ExportUDKAnimData) bpy.types.INFO_MT_file_export.append(menu_func) - + def unregister(): global MENUPANELBOOL if MENUPANELBOOL: diff --git a/io_mesh_raw/__init__.py b/io_mesh_raw/__init__.py index 8a1569bca..1af09c9fe 100644 --- a/io_mesh_raw/__init__.py +++ b/io_mesh_raw/__init__.py @@ -40,7 +40,8 @@ def menu_import(self, context): def menu_export(self, context): from io_mesh_raw import export_raw - default_path = bpy.data.filepath.replace(".blend", ".raw") + import os + default_path = os.path.splitext(bpy.data.filepath)[0] + ".raw" self.layout.operator(export_raw.RawExporter.bl_idname, text="Raw Faces (.raw)").filepath = default_path diff --git a/io_mesh_stl/__init__.py b/io_mesh_stl/__init__.py index b671dd9ec..1858c17bc 100644 --- a/io_mesh_stl/__init__.py +++ b/io_mesh_stl/__init__.py @@ -128,7 +128,8 @@ def menu_import(self, context): def menu_export(self, context): - default_path = bpy.data.filepath.replace(".blend", ".stl") + import os + default_path = os.path.splitext(bpy.data.filepath)[0] + ".stl" self.layout.operator(StlExporter.bl_idname, text="Stl (.stl)").filepath = default_path -- GitLab