File Paths of Revit Links Inside of Revit Links

I’ve been banging my head against a wall these last two days. I’m hopeful that the hive will have answers for me.

I have a library of scripts that check for various model health issues and conformance to standards.

For this one, I’m trying to see the file path of the Revit Links inside of Revit Links. I’m checking to see that everyone is linking to the correct Revit Models in the Cloud Worksharing environment.

It’s easy enough to grab all of the Revit Links in the file I’m evaluating. From there, I can get the documents of the Revit Links, and then their File Paths. Win!

The next steps are where it falls apart. With Python I can collect the RevitLinkInstances from every Revit Link. I want to repeat the process above by getting the RevitLinkType from the RevitLinkInstances. Fail. Then get the Document of the RevitLinkTypes, and then the file path.

The nested RevitLinkInstances aren’t behaving as I expect them to. First, when I try to get the Type of the Instance object, the error talks about wrapping an Appearance Asset, which

Second, the script I use for getting Type and File Paths previously produces an error because it’s treating my RevitLinkInstances as string data, and I have no idea why.

Third, I can see parameters of the RevitLinkInstances but I cannot see get their values. I can’t select the element by ID, and most bewildering is that using Object.Type reports an “UnknownElement”

Halp?!


I’ll clean up the script ann post that in an hour or so. Hoping somebody spots something obvious. Thanks!

Instead of looking at linked elements, you might want to look into the TransmissionData class and the ExternalFileReference class which you can read from there. This allows not just reading but also updating paths to new locations, however I have not experimented with using cloud paths.

Thanks @jacob.small,

I’ve tried out your suggestion this week, and I hit another wall.

TransmissionData and ExternalFileReference classes work great on non-cloud models:

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import TransmissionData, ExternalFileReference, ModelPath, ModelPathUtils, FilePath

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

links = UnwrapElement(IN[0])

doc = DocumentManager.Instance.CurrentDBDocument
pathList = []

for l in links:
    
    if l.IsWorkshared == True:
        filePath = l.GetWorksharingCentralModelPath()
        transData = TransmissionData.ReadTransmissionData(filePath)
        exRefIds = transData.GetAllExternalFileReferenceIds()

        for refId in exRefIds:
            exRef = transData.GetLastSavedReferenceData(refId)
            mPath = exRef.GetAbsolutePath()
            vPath = ModelPathUtils.ConvertModelPathToUserVisiblePath(mPath)
            pathList.append(vPath)

OUT = pathList

I used the same strategy on Cloud Models, but it always gets stuck on TransmissionData.

The error reads:

Warning: RevitServerInternalException : An internal error happened on the server, please contact the server administrator at Autodesk.Revit.DB.TransmissionData.ReadTransmissionData(ModelPath path) [’ File “”, line 22, in \n’]

This is my code for Cloud Models:

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import TransmissionData, ExternalFileReference, ModelPath, ModelPathUtils, FilePath

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

links = UnwrapElement(IN[0])

doc = DocumentManager.Instance.CurrentDBDocument
pathlist = []

filePath = doc.GetCloudModelPath()

#Breaks here at TransmissionData
transData = TransmissionData.ReadTransmissionData(filePath)

exRefIds = transData.GetAllExternalFileReferenceIds()

for refId in exRefIds:
    exRef = transData.GetLastSavedReferenceData(refId)
    mPath = exRef.GetAbsolutePath()
    vPath = ModelPathUtils.ConvertModelPathToUserVisiblePath(mPath)
    pathList.append(vPath)

OUT = pathList

In my debugging, I decided to disconnect the list of Revit Links to iterate through, and focused on getting link paths of the current document. No matter what I do, it gets stuck on TransmissionData.ReadTransmissionData

Unless I’m missing something, I don’t think this method will work for cloud paths. I hope I’m wrong though.

I’m going to take what I learned from this and go back to my first method looking for any breakthroughs.

I’d love to hear more suggestions if you or anyone else has any!

Is the document saved to disc already? The error hints at not yet having file access, which would occur if you tried to read the file at the cloud path rather than off the local disc.

After much research and trial and error, I can’t accomplish what I want. I can access the name, guide, and type of link (attached v. overlay), but not the cloud path and other properties of Revit Links inside of Revit Links to my model.

I read somewhere that unless the Revit Link was opened, either through the links in my model, or directly loading the nested links, I won’t be able to access that information.

I suppose opening the Revit links could be part of the code, but that’s more than I’m willing to do at this point.

We’ve had problems with consultants linking to the wrong models in ACC; I was trying to check this automatically.