Since then the thread has had over 2,400 hits and numerous users have contributed to the ideas and solutions of this script. Today I finished version 2 and decided to post about it here. If you like what you see, go to the thread above (or click here) and download the script. I hope it will be as useful to you as it has been to me and a lot of AUGI members. All you need to do is to place a copy of the exe file (compiled version of the AHK script) in the central file folder and have team members create shortcuts to this file on their local drives (the Desktop is ideal). Then just double click the shortcut and wait until it's finished doing it's magic!
The script will do the following:
1) Check if the Central file exists. Filename is assumed to be XXXXX #VV central.rvt, where XXXXX can be anything of any length, # is the discipline (A, S or MEP, where the 3 letters in MEP can be expressed in any order) and VV is the version number (since we’re on 2008, we would use 08, but the script doesn’t care about this and you could in theory type anything). The spaces shown in the filename can be any character you want, including a space. So 123456789 Project_A08-Central.rvt would work the same as 123456789-Project-A08_Central.rvt (you get the idea).
2) If no Central is found or more than one exists, dialog warnings will be issued. The Central file folder will open in Explorer so you can investigate the problem immediately.
3) The discipline is evaluated (from # above) and if the input is not as expected, you will be warned and the script will terminate. The Central file folder is opened in Explorer so you can investigate the problem immediately.
4) Local files will be created in C:\Revit Local Files\XXXXX #VV\ so if the folder does not exist, the script will create it. It will also automatically create backups of your local files just in case you might need one (like if the Central becomes corrupt). So first it will delete the last backup and place it in the Recycle bin (it will stay there until you empty your trash). Then it renames your local file and appends “_BAK” to the filename, copies the Central file to this folder, and removes “central” from the name and replaces it with your Windows username (Ex: 123456789-Project-A08_DBaldacchino.rvt).
5) Check if the required Revit flavor is installed. If not, it will give you the option to open the file with the Revit flavor you have installed on your PC (Ex: it will use Revit Structure 2008 to open an Architectural file). If no Revit is installed, it will let you know and ask you to contact IT (niiiiiice!), after which the script will terminate.
6) The username in the Revit.ini is deleted to prevent problems down the line (you've all experienced having two people working on a project with the same username and one of them complaining they cannot STC, right?!). This ensures that when Revit opens, the username will be set to your Windows username. If multiple flavors of Revit are installed, only the ini file of the discipline that you’re trying to use will be edited.
7) The script will now evaluate what command line/switch was sent through the shortcut. It recognizes "detach" or "worksets" (not case sensitive). In the "Target" field of your shortcut, leave a space at the end and type "detach" or "worksets". If you type anything else, the script ignores it and opens the local file as if no command was sent. So for example your shortcut target would look like this: "\\servername\Projects\ABC\Central\test_A08-Central.rvt" worksets. In this case, the script will write a custom journal called "select_ws.txt" in your journal folder and fire it up in a new instance of Revit. If the command line parameter was detach, a journal called "detach.txt" would be written and used. The script still makes a copy of the central file as a precaution when detaching. Note that currently there is no way to run a journal in an already running Revit session through AHK, so using one of the two switches will cause a new instance of Revit to open.
8) If there is no command line parameter (or an unrecognized one) in the shortcut, the script proceeds as before. First it checks if Revit is already running. If it is, the session will be activated and the local file will start opening. If not, a new session is fired up and the local file starts to open.
9) When the annoying dialog shows up (that this Central has been copied….), it is automatically dismissed, thus rendering the whole process entirely transparent.