0
$\begingroup$

I'm trying to script an Add-on that lets user to choose .txt file from some directory by pressing a button from panel and read data in that .txt file. This is what I tried

bl_info = {
    "name": "Simple Add-on Template",
    "author": "Chris Conlan",
    "location": "View3D > Tools > Simple Addon",
    "version": (1, 0, 0),
    "blender": (2, 8, 0),
    "description": "Starting point for new add-ons.",
    "wiki_url": "http://example.com",
    "category": "Development"
}

import bpy
class ImportPanel(bpy.types.Panel):
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "Import"
    bl_label = "File Import"
    def draw(self, context):
        layout = self.layout
        row = layout.row()
        row.label(text="Import", icon='HAND')
        row.operator("file.filepath_drop", text = "Imp")
def register():
    bpy.utils.register_class(ImportPanel)
    
    
def unregister():
    bpy.utils.unregister_class(ImportPanel)
    
if __name__ == "__main__":
    register()

But this is not working as though. Output I expected from above code is It should create a 'choose file' button that lets me to choose a txt file from file system.

$\endgroup$
3
  • $\begingroup$ Hello, what's not working ? What is the displayed message in the console ? $\endgroup$
    – Gorgious
    Sep 1, 2020 at 14:31
  • $\begingroup$ shouldn't you add that option to TOPBAR_MT_file instead of the 3D view? $\endgroup$
    – pevinkinel
    Sep 1, 2020 at 14:33
  • 2
    $\begingroup$ Also, you should look into the template named operator_file_import.py $\endgroup$
    – Gorgious
    Sep 1, 2020 at 14:34

0

You must log in to answer this question.

Browse other questions tagged .