My mesh exporter opens up a file dialog, allowing the user to choose a folder.

It then creates the folder if necessary, and populate it with data files.

My problem is that there is default text in the text box:

enter image description here

Is there any way to clear it from Python?

It is a trivial problem as it is just a few keystrokes to do it manually, but if there is some way to do it I would like to.

  • $\begingroup$ Even though your question asks about removing the default filename, it sounds like you are really wanting a directory-only file selector, you could clarify this in your question. $\endgroup$
    – ideasman42
    Commented Jan 11, 2014 at 2:48

2 Answers 2


It's actually a feature of the ExportHelper mixin:

class ExportHelper:
    filepath = StringProperty(
            name="File Path",
            description="Filepath used for exporting the file",
    # subclasses can override with decorator
    # True == use ext, False == no ext, None == do nothing.
    check_extension = True

    def invoke(self, context, event):
        import os
        if not self.filepath:
            blend_filepath = context.blend_data.filepath
            if not blend_filepath:
                blend_filepath = "untitled"
                blend_filepath = os.path.splitext(blend_filepath)[0]

            self.filepath = blend_filepath + self.filename_ext

        return {'RUNNING_MODAL'}

    def check(self, context):
        # code that uses check_extension and adds it if True
        # ...

Add this to your export operator to overwrite the invoke() method:

    def invoke(self, context, event):
        self.filepath = ""
        return {'RUNNING_MODAL'}

It won't use a default name for the export, clears the filepath from a previous run of the operator (so always starts empty), but still adds the file extension if you enter a file name (you can disable it if you want).


From the question it sounds like want a directory-only file-selector (you don't want to use the filename component of the path at all?).

In this case remove filepath and a property and add...

directory = StringProperty(subtype='DIR_PATH')

Now the file selector won't show the text field for entering the file name, this saves the confusion of showing the user a filename that has to be ignored/stripped by the script later.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .