import bpy class TestImport(bpy.types.Operator): bl_idname = "import.test" bl_label = "Test Import" filepath: bpy.props.StringProperty(subtype='FILE_PATH', options={'SKIP_SAVE', 'HIDDEN'}) directory: bpy.props.StringProperty(subtype='FILE_PATH', options={'SKIP_SAVE', 'HIDDEN'}) files: bpy.props.CollectionProperty(type=bpy.types.OperatorFileListElement, options={'SKIP_SAVE', 'HIDDEN'}) test_prop: bpy.props.BoolProperty(name="Test Prop", default=False) @classmethod def poll(cls, context): return (context.region and context.region.type == 'WINDOW') def execute(self, context): return {'FINISHED'} def invoke(self, context, event): if self.properties.is_property_set("filepath") or self.properties.is_property_set("directory"): return context.window_manager.invoke_props_dialog(self) context.window_manager.fileselect_add(self) return {'RUNNING_MODAL'} class TEST_FH_import(bpy.types.FileHandler): bl_idname = "TEST_FH_import" bl_label = "File handler test" bl_import_operator = "import.test" bl_file_extensions = ".txt" @classmethod def poll_drop(cls, context): return (context.region and context.region.type == 'WINDOW') bpy.utils.register_class(TestImport) bpy.utils.register_class(TEST_FH_import)