Hello All,
I am new to Python scripting and would like to create a script that reads the name of the architectural model that I have linked into my project in Revit. The “Links” node from Rhythm is what I am trying to achieve but I want to have the name of the linked model be part of the input and not just a drop down of the links that are linked in my model. Any help is greatly appreciated and please provide some good links for me to start learning Python in Revit.
Thank you!
I don’t fully understand what you are trying to do that isn’t already achieved by the Rhythm node, but this might provide some direction:
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import FilteredElementCollector, RevitLinkInstance
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
links = FilteredElementCollector(doc)\
.OfClass(RevitLinkInstance)\
.ToElements()
link_docs = [link.GetLinkDocument() for link in links]
names = [link_doc.Title for link_doc in link_docs]
OUT = names, links
Note: If there are multiple instances of the same link, a List.GroupByKey node will have to be used before making the dictionary. Also, if a link is unloaded, the above python script will throw an exception as the GetLinkDocument method won’t return a document.
Thank you for the reply. I would like to have some assistance on creating graphical user interface that opens so that the user can type in the name of the linked model that they are trying to read in lieu of opening dynamo and using the drop down menu that is provided with the “Links” node.
Take a look at Data-Shapes for creating UI elements.
1 Like
And keep in mind that a single missed letter would likely spell a failed run. Might be best to use a drop down selection from the DataShapes UI instead of a ‘type it out’ as a result.