Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get Linked View of Linked Document

7 REPLIES 7
Reply
Message 1 of 8
nicolas.calvi
1271 Views, 7 Replies

Get Linked View of Linked Document

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

7 REPLIES 7
Message 2 of 8
Sean_Page
in reply to: nicolas.calvi

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

 

Message 3 of 8
nicolas.calvi
in reply to: Sean_Page

@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 8

Have you found a solution?

Message 5 of 8

Hi,

 

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

Message 6 of 8

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

Message 7 of 8
Sean_Page
in reply to: AndrewButenko

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.

Message 8 of 8

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community