Links to windows folders w/ numbers


I’m very new to pyRevit and Python in general, so please excuse a silly question. I am making a very simple script that opens a windows explorer folder. From what I’m seeing, if there is a number in the folder structure, the script does not work. What am I doing wrong? Am I using the wrong command?


Does not work:

The backslash character in python is a special character that can cause undesired things to happen if you don’t account for it. If you have a backslash in a string, you can either put an “r” before it, like this:


or you can add an extra backslash behind each backslash, like this:


Thanks! That was it.

If I may hijack my own thread, I’m thinking about taking this one step further and having it open a revit file. I can’t find documentation for opening files, is this possible?

I think you are looking for this:

1 Like

Many Thanks! That is very helpful.

Perhaps I spoke to soon…I used the terminology for opening a Revit file, but recieved the following error:

AttributeError: ‘module’ object has no attribute ‘OpenAndActivateDocument’

I am loading these at the start of the script:

from pyrevit import revit, DB, UI
from pyrevit import forms
from pyrevit import script

If you post your code I can try to help see what went wrong, but here is a little test I did that worked for me.

You need to call the OpenAndActivateDocument method on your UIApplication. You can get that a number of ways. Here are a couple:

uiapp  = __revit__
from pyrevit import HOST_APP
uiapp = HOST_APP.uiapp

Then you just call your method on that!

uiapp.OpenAndActivateDocument(r"YOUR DOCUMENT PATH")