Get Linked View of Linked Document

Get Linked View of Linked Document

nicolas.calvi
Participant Participant
2,303 Views
8 Replies
Message 1 of 9

Get Linked View of Linked Document

nicolas.calvi
Participant
Participant

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.

 

Sans titre.png

 

Anyone can help me for this point ?

 

Thanks 🙂

 

@Anonymous

0 Likes
2,304 Views
8 Replies
Replies (8)
Message 2 of 9

Sean_Page
Collaborator
Collaborator

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);
    }
}

 

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
0 Likes
Message 3 of 9

nicolas.calvi
Participant
Participant

@Sean_Page 

 

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.

Message 4 of 9

AndrewButenko
Advocate
Advocate

Have you found a solution?

0 Likes
Message 5 of 9

nicolas.calvi
Participant
Participant

Hi,

 

No we don't find any solution for that. Generaly, Revit API is very poor and not usefull for many scenario.

0 Likes
Message 6 of 9

AndrewButenko
Advocate
Advocate

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?

 

зображення_2021-10-26_083325.png

0 Likes
Message 7 of 9

Sean_Page
Collaborator
Collaborator

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.

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
0 Likes
Message 8 of 9

AndrewButenko
Advocate
Advocate
Maybe somebody will come in handy. I was solving the problem of getting visible elements from a linked file.  This  article helped me.
0 Likes
Message 9 of 9

g_sicre
Contributor
Contributor

Hi All,

 

this functionality is avialable from Revit 2024 onwards. There is a new class called "RevitLinkGraphicsSettingsto override display of a Revit link in a view. You can access these settings from a view using the method ".GetLinkOverrides()".

 

I hope this helps.

 

Cheers,

German