The Revit API is actually something pretty special. People will go on and on about how Revit needs this feature or that feature, but the fact is that you can build almost any feature you like with the API. Recently, I have been running quite a few batch operations from the scope of a federated Revit model: so I will have one RVT file, with hundreds of Revit links, and I will process them from that main federated model.

On one recent project, we had to deliver to a Client a linked dataset, with Revit link file paths resolving correctly. As you know, people work in many different IT environments, and the pathing of Revit links may vary widely.

I set up an ‘approved’ list of Revit file paths, that looked something like this:

I knew that in Dynamo with Python I could get a lot of information about linked files using the ExternalFileReference class. What I discovered during this process is that there is a TransmissionData API class that let’s you do some pretty interesting things…

You see, I was thinking I would have to set up a batch method to open this files, change the file paths, and close them. But the TransmissionData class is basically what is implemented in eTransmit for Revit – it allows you to ‘lightly touch’ the Revit file and simply change the Revit link paths, and also set a switch saying ‘this file has been transmitted’. This puts the file in an appropriate state for re-opening in the new path environment. Pretty cool huh?

Once I figured out how to implement those TransmissionData actions in Python, I just had to build a node that, running from the federated model:

  • examines each link for the links inside of it
  • replaces erroneous paths with the correct file path
  • sets the new paths to the file

I did this in the hacky way of a “counter with List.Map” in Dynamo. In the future I’ll probably fix it up to be a ‘proper’ Python script but this works for now. In about an hour it fixed the linked file paths of 600 Revit links, all with the click of a single button 🙂

You can download the main definition here:

External References FINAL

You can get the supporting nodes from GitHub here:

As usual, please use with care. And it is probably worth backing up your files before running something like this.

It is kinda more Python than Dynamo but hey, you get the picture 🙂

In fact, here is the Python code:

import clr
from Autodesk.DesignScript.Geometry import *

# Import RevitAPI
import Autodesk
from Autodesk.Revit.DB import *

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

from System.Collections.Generic import *

import Revit

from System import Guid

import System

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'

import os.path

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

tempvalue = IN[0]
approvedFilenames = IN[1]
approvedFilepaths = IN[2]
targetfilepath = IN[5]

def stripquotes(string):
	string = string[1:-1]
	return string

transData = TransmissionData.ReadTransmissionData(tempvalue)
erefids = transData.GetAllExternalFileReferenceIds()
refdata = []
for x in erefids:

currentpaths, currenterefType, currenterefPath, pstr = [], [], [], []

for e in refdata:
for s in currentpaths:
filenames = []
for p in pstr:
	templist = os.path.split(p)
newpath = []
indices = []
failpath = []
origcounter = 0
matchrefs = []
newpathtypes, newbools = [], []
pathtypevar = IN[3]
for f in filenames:
	tempindex = approvedFilenames.index(f) if f in approvedFilenames else -1
	if tempindex == -1:
	origcounter = origcounter + 1

elementcount = len(erefids)
hostfile = currentfilepathstring * elementcount
currentdata = []

newdata = []

setlength = len(newpath)
setcounter = range(setlength)
successreport = []
setdata = IN[4]
if setdata:
	for s in setcounter:
			transData.SetDesiredReferenceData(matchrefs[s], newpath[s], newpathtypes[s], newbools[s])
			successreport.append("Success setting data")
			successreport.append("Failure setting data")
	successreport.append("You need to set the switch to True")

if setdata:
		transData.IsTransmitted = True
		transData.WriteTransmissionData(targetfilepath, transData)
		successreport.append("Success WRITING data")
		successreport.append("Failure WRITING data")
#Assign your output to the OUT variable.
OUT = successreport, currentdata, newdata

If you want to read more about the API methods used:




Whenever you are looking to implement a new technology in your firm, you typically go through a few steps:

  1. Figure out what is out there in the marketplace – What products are available?
  2. Collect data about all of the technologies that may suit your use case
  3. Rigorously compare and analyse all the data
  4. Make a decision and go for it

There are some excellent content management tools out there for Revit now, so how can you choose? I went through a very comprehensive research analysis of a number of Revit CMS platforms, and I posted about the process here.

Then I caught up with Steve Germano over at Unifi to talk about the results. You can view (or just listen) to it here:

Feel free to comment here with your thoughts and we can keep the conversation going!

In Windows, you will often use either Map Network Drive dialog or net use command to map a network drive. You can use that method with a shared folder trick to map a local folder as a drive too, as described here.

But there is an even easier way, that is more flexible in some ways. It is the subst command, and it basically tells your Windows system to refer to a folder as a drive letter. Its usage is very simple, for example:

subst J: "E:\some folder\J_DRIVE"

If you want that to show up as a ‘drive’ at each reboot, just put the above command into a CMD file and point to it from your Windows startup folder.

For your assistance, here is the path to your typical User Startup folder in Windows: