When I use the following script:
import bpy
import os
from bpy_extras.io_utils import ExportHelper
from bpy.props import (StringProperty, CollectionProperty)
from bpy.types import (Operator, OperatorFileListElement,)
class OT_ExportTest(Operator, ExportHelper):
bl_label = 'Export'
bl_idname = 'test.export_test'
bl_options = {'PRESET', 'UNDO', 'REGISTER'}
files: CollectionProperty(name = 'File Path',
type = OperatorFileListElement,)
directory: StringProperty(subtype = 'DIR_PATH',)
filter_glob: StringProperty(default = "*.fbx;", options={'HIDDEN'})
filename_ext = ''
def execute(self, context):
folder_path = os.path.dirname(self.filepath)
selection = bpy.context.selected_objects
for sel in selection:
filename_ext = '.fbx'
bpy.ops.export_scene.fbx(
filepath = folder_path + os.sep + sel.name + filename_ext)
def register():
bpy.utils.register_class(OT_ExportTest)
def unregister():
bpy.utils.unregister_class(OT_ExportTest)
if name == 'main':
register()
bpy.ops.test.export_test('INVOKE_DEFAULT')
The object always get exported as the name of the object, because of sel.name.
But I want the object to be exported as what you type into the text field.
How do I do that?
