Test get file path.gh (4.7 KB)
Trying to make a simple python module in grasshopper that prompts the user for a filepath using the standard windows filepicker dialog and then returns that filepath to grasshopper. This is what I have so far. The open file dialog runs and seems to work, but no value is returned and after running, the grasshopper environment hangs and stops processing inputs.
from System.Windows import Forms
def get_file_path():
dialog = Forms.OpenFileDialog()
dialog.Filter = "All files (*.*)|*.*"
dialog.RestoreDirectory = True
dialog.Title = "Open"
dialog.FileName = "Test get file path"
return dialog.FileName if dialog.ShowDialog() == Forms.DialogResult.OK else None
if Run:
FilePath = get_file_path()