← All ideas
  • Published 16 Feb 2024

python handler for files being dropped onto the Blender UI

I'd like to give my addon the ability to respond to a user dragging a file onto the Blender UI, so that the addon can do certain things dependant on the file type:

handler could be something like this:

bpy.app.handlers.file_dropped_onto_ui

then I could use it like this:

def my_function(scene,dropped_file):
    if dropped_file.extension == fbx:
        bpy.ops.import_scene.fbx(filepath= dropped_file.filepath, open_options = True)

def register_handler():
    if user_dropped_something not in bpy.app.handlers.file_dropped_onto_ui:
        bpy.app.handlers.file_dropped_onto_ui.append(my_function)
100%

Development Status: Open

Upvote 8 Downvote 0
3di
16 Feb 2024

1 Comment

guishe

With FileHandler you can set operator to run with file drops (4.1)

docs.blender.org/api/master/bpy.types.FileHandler.html

1