Is there a way to get the name of the file containing the linked element?
Can you show what your input would be? How would you select an element from a linked instance?
From Springs.Collector.LinkedInstanceElements
I have several linked files and I filter these elements by different conditions, however finally I want to know the file name of which the element is contained in
You could try API, using .Document. Not sure if it will work, it might just return the current doc since the RevitLinkedInstance is considered inside the current doc.
You can try this python for it:
# Enable Python support and load DesignScript library
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
# The inputs to this node will be stored as a list in the IN variables.
if isinstance(IN[0], list):
elements = UnwrapElement(IN[0])
else:
elements = [UnwrapElement(IN[0])]
docs = []
for elem in elements:
doc = elem.Document
docs.append(doc.Title)
# Assign your output to the OUT variable.
OUT = docs
Edit: Actually you might need to use the LinkElementId class if you can get the elementid. From there you can find the linked element + its name (the file name).
Edit #2: Nevermind, the above python works. Just be careful of the levels, as the Springs node will give you a nested list even if it is just one category, so you may need to flatten it first or add in for loops:
Thank you, I did flatten the the list.
Works Perfectly.
Hello!
Just thought i’d pop in here and say thank you for the above Python!
but that i also altered it so it can work with some more complex list structures being input (You don’t need to flatten it)
Enable Python support and load DesignScript library
import clr
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *
clr.AddReference(‘RevitServices’)
import RevitServices
from RevitServices.Persistence import DocumentManager
def extract_document_title(element):
if element is not None and hasattr(element, ‘Document’):
return element.Document.Title
else:
return “Invalid element”
def process_nested_list(input_list):
output_list =
for item in input_list:
if isinstance(item, list):
output_list.append(process_nested_list(item))
else:
unwrapped_element = UnwrapElement(item)
output_list.append(extract_document_title(unwrapped_element))
return output_list
The inputs to this node will be stored as a list in the IN variables.
input_elements = IN[0]
Process the nested list
docs = process_nested_list(input_elements)
Assign your output to the OUT variable.
OUT = docs
I Hope this helps someone in the future