"pyrevit run" can't open model with non ASCII symbol in path

Just an update. I did managed to fix the issue using a workaround.
I don’t think the problem was with the pyrevit itself but rather with the Revit API.

Pyrevit will launch Revit and it will launch the script on a selected model.
And then Revit API itself will throw this exception:
Autodesk.Revit.Exceptions.FileNotFoundException: The document to be opened does not exist.

Because it for some reason can’t work with path that has non ASCII character like “ě”.


The way I got around this is, I converted the path to a Revit model into 8.3 adress format using this function.

def get_short_path(long_path):
buffer_size = 512
buffer = ctypes.create_unicode_buffer(buffer_size)

if ctypes.windll.kernel32.GetShortPathNameW(long_path, buffer, buffer_size):
    return buffer.value
else:
    return None 

When launching my pyrevit script I convert all my file paths using the function above.

Then script launches normally, even if path to the file contains symbols like these: RBá+ěščéřížýáůú.rvt

1 Like