Hi,
I would like get the "Linked View" name of a "Linked Revit Document" with Revit API (2020). I success to get the RevitLinkInstance of docuements, but in this instance I don't find the "Linked View" name.
Anyone can help me for this point ?
Thanks 🙂
@Anonymous
Once you have the LinkInstance you'll need to get the LinkType, then call GetLinkDocument().
Document linkDoc;
using (FilteredElementCollector rvtLinks = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_RvtLinks).OfClass(typeof(RevitLinkType)))
{
if (rvtLinks.ToElements().Count > 0)
{
foreach (RevitLinkType rvtLink in rvtLinks.ToElements())
{
if (rvtLink.GetLinkedFileStatus() == LinkedFileStatus.Loaded)
{
RevitLinkInstance link = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_RvtLinks).OfClass(typeof(RevitLinkInstance)).Where(x => x.GetTypeId() == rvtLink.Id).First() as RevitLinkInstance;
linkDoc = link.GetLinkDocument();
}
}
}
}
Then get the views:
using(FilteredElementCollector linkViews = new FilteredElementCollector(linkDoc).OfCategory(BuiltInCategoris.OST_Views)
{
foreach(View view in linkViews.ToElements())
{
TaskDialog.Show("View Name",view.Name);
}
}
Thanks for the answer, but the result is not what I search to do.
I want to get the ACTIVE linked view selected, the red square on my capture.
My point is to list all active linked view, no all of them.
Hi,
No we don't find any solution for that. Generaly, Revit API is very poor and not usefull for many scenario.
Hi!
Maybe I'm solving a slightly different problem, but it's enough for me to get the view that is stored in the settings as in the screenshot. Maybe someone knows how to get it?
Looking into this further now that I better understand the request, I do not believe this functionality is exposed in the current API and therefore you won't be able to get the value programmatically.