I'm currently writing an import script and I have the following problem:
I have to select two files: one for the mesh and one for the skin.
My current solution (lame!) kind of looks like this:
Code: Select all
bl_idname = "import.test"
bl_label = "TEST"
# the two files we want to select
filepath = bpy.props.StringProperty(subtype='FILE_PATH')
skinpath = bpy.props.StringProperty(subtype='FILE_PATH')
def execute(self, context):
def invoke(self, context, event):
The problem is, that with "fileselect_add()" I only select "filepath", having a small field on the left, where I can enter the path for "skinpath". But if I klick the button for browsing that file (so I wouldn't have to enter it manually, which is not a solution!) it says "cannot activate file selector, one already open"
I thought the solution would be to use "invoke_props_dialog()" instead of "fileselect_add()". Then, when I invoke my import script, a dialog opens (as expected) where I can enter the filepath and the skinpath.
But the "browse file" buttons right next to the corresponding input fields just do nothing!
Do I have to bind to them another operator which uses "fileselect_add()" or maybe "bpy.ops.buttons.file_browse()"? And if so, how can I do that?
Having spent hours of searching through the net I didn't find any (useful) documentation on that matter. There is one related post:
Blender 2.6 Browse File.
But it didn't really tell me anything new... Except that I learned how to put a button into a panel, which opens a file browser (as explained there in the end). But I have no idea, how to return the selected filepath, so I can actually do something with it...
I would be very grateful for some hints (preferably on how to get those buttons working in the "invoke_props_dialog()") !
Thanks in advance!