Blender 2.6 Browse File

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Posts: 6
Joined: Sun Feb 19, 2012 8:03 pm
Location: Slovakia

Blender 2.6 Browse File

Postby kapucko » Mon Apr 30, 2012 11:52 am

is there any way in blender how to add to interface a button to browse files?
I want to let user choose the input .xml file.

Thnaks for advice

Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Postby CoDEmanX » Mon Apr 30, 2012 10:01 pm


1. you can create an operator class (derived from bpy.types.Operator) which would have to call to fileselect_add: ... select_add

2. or you could make use of file_browse: ... ile_browse
(dunno how this works...)

3. or you use the Template "Operator File Import", which uses the ImportHelper class, which calls to fileselect_add. This is actually for data import, but you can use it for file picking as well i guess.

in case of 1 and 3, you'd have a class derived from bpy.types.Operator:

Code: Select all

class ImportSomeData(Operator):
    bl_idname = "import_test.some_data"

when registered, it will be available via Blender API like:
for example: bpy.ops.import_test.some_data()

and it can be added as button to UI scripts like:

Code: Select all


(in the appropriate place in the draw() function)
I'm sitting, waiting, wishing, building Blender in superstition...

Posts: 6
Joined: Sun Feb 19, 2012 8:03 pm
Location: Slovakia

Postby kapucko » Mon Apr 30, 2012 10:14 pm

Thanks, it works:)

Return to “Python”

Who is online

Users browsing this forum: No registered users and 0 guests