Skip to main content
1 of 3
batFINGER
  • 85.1k
  • 10
  • 114
  • 244

Its running modal

The file browser as noted in question code when invoked is running modally.

print("execute", self.filepath)

in your execute method where you set the class property, will notice in output

No file selected
execute some/file/path

because the filebrowser has been invoked and is running modally.

If however we change test call to

bpy.ops.open.file(filepath="wink")
print(OpenBrowser.selected_file)

we get

execute wink
No file selected

Which reminds us that it is a slippery slope to set a class property from an instance, ie it doesn't work so instead

self.__class__.selected_file = self.filepath

outputs:

execute wink
wink

or perhaps better still, make a class method to set it.

batFINGER
  • 85.1k
  • 10
  • 114
  • 244