How to get the Revit Links file path (local in Autodesk Desktop Connector), type, instance?
I usually give input of file path to get the links in the files but I want to do the reverse, so I got a file opened with linked Revit files and I would like to know the file path of the linked Revit files.
currently I am using this python script to get the revit links types and instances in separate lists, but I would like to add the file path of those. The difficulty is that the saved path is a cloud path, but I would like to get the path of the Autodesk Desktop of BIM360 in my local drive instead.
For this, I tried to get the File info with clockwork package but the central path indicated is in other server which is not my local drive, cloud path, I do not have access because it is a Clarity server.
Also I tried to find Revit files paths in the local drive with the Revit file names.
# Load the Python Standard and DesignScript Libraries
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
paths = []
def GetExtFileRefPath(item):
try :
dirRefs = item.GetExternalResourceReferences()
for i,v in enumerate(dirRefs):
paths.append(v.Value.InSessionPath)
return paths
except Exception as e: return e.ToString()
doc = DocumentManager.Instance.CurrentDBDocument
items = FilteredElementCollector(doc).OfClass(RevitLinkType).ToElements()
OUT = [GetExtFileRefPath(x) for x in items]
hello @chuongmep many thanks, I tried and result is same list of path of the revit linked files in current project, but if I got 20 links this list is repeated 20 times, I just need one path by Revit file
# Load the Python Standard and DesignScript Libraries
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
paths = []
def GetExtFileRefPath(item):
try :
dirRefs = item.GetExternalResourceReferences()
for i,v in enumerate(dirRefs):
return v.Value.InSessionPath
except Exception as e: return e.ToString()
doc = DocumentManager.Instance.CurrentDBDocument
items = FilteredElementCollector(doc).OfClass(RevitLinkType).ToElements()
OUT = [GetExtFileRefPath(x) for x in items]
it looks great, I am looking the result of the last script, aparently the list of link paths are sorted alphabetically but it is not the case in some file paths. Would it be possible to give to the python script an input of revit link types/instances?
I noticed file directories appear as β/β instead of β\β
I donβt understand what you want because it similar, you can see some example like that in case you want try check for types and instances of rvtlinked
I agree it is very similar but how to know what Revit link type or instance is part of the script output? I would create a sublist first of revit link type/instances and other sublist of revit link paths, so I can create a dictionary. Following your last script screenshot would be something like: OUT=[instances,types,linkInstancePath,linkTypePath]