I'm trying to get the filename and directory of the currently selected files in the file browser. When I hover over the directory with the cursor I see "FileSelectParams.directory", and this is what I find in the docs: https://docs.blender.org/api/current/bpy.types.FileSelectParams.html
Says bpy.types.FileSelectParams.filename is "the active file in the file browser"
So here's what I tried:
bl_info = {
"name": "Image Putter Simple",
"blender": (2, 90, 0),
"category": "Object",
}
import bpy
def main(context):
filename = bpy.types.FileSelectParams.filename
directory = bpy.types.FileSelectParams.directory
# Do things with the file
class ImagePutterSimple(bpy.types.Operator):
"""Image Putter Simple"""
bl_idname = "object.browser_image_putter_simple"
bl_label = "Image Putter Simple"
def execute(self, context):
main(context)
return {'FINISHED'}
def register():
bpy.utils.register_class(ImagePutterSimple)
def unregister():
bpy.utils.unregister_class(ImagePutterSimple)
if __name__ == "__main__":
register()
I get the error message:
Python: Traceback (most recent call last):
File "/home/johne/.config/blender/2.93/scripts/addons/image_putter_simple.py", line 36, in execute
main(context)
File "/home/johne/.config/blender/2.93/scripts/addons/image_putter_simple.py", line 14, in main
filename = bpy.types.FileSelectParams.filename
AttributeError: type object 'FileSelectParams' has no attribute 'filename'
location: <unknown location>:-1
What's going on? And if this doesn't work, is there another way to do what I'm trying to?