How to get the view hierarchy

How to get the view hierarchy

ottosson_mathias
Advocate Advocate
399 Views
1 Reply
Message 1 of 2

How to get the view hierarchy

ottosson_mathias
Advocate
Advocate

Is it possible to get the view hierarchy like the one in the project browser?

ottossonmathias_0-1670061949945.png

 

I've looked but couldn't find any posts about it.

 

Thanks!

0 Likes
400 Views
1 Reply
Reply (1)
Message 2 of 2

jeremy_tammik
Alumni
Alumni

Have you looked at the BrowserOrganization class?

  

https://www.revitapidocs.com/2023/4fd57c3f-6127-efd9-f79e-70ad3e5dc1cc.htm

  

It provides some access to the project browser info.

  

Also, here is a sample code snippet of using it from a previous thread in this forum:

  

https://forums.autodesk.com/t5/revit-api-forum/change-the-sheet-issue-date-on-sheets-filtered-by-pro... 

   

        /// <summary>
        ///     Filter for sheets based on browser organisation
        /// </summary>
        private IEnumerable<ElementId> FilterForSheetsByBrowserOrganisation(
            Document doc,
            string folder_name)
        {
            // Dim Els As List(Of ElementId) = FEC.WherePasses(ECF).ToElementIds _
            //   .Where( Function( k ) bOrg.GetFolderItems( k )( 1 ).Name = "Type 1" ) _
            //   .ToList

            var bOrg = BrowserOrganization
                .GetCurrentBrowserOrganizationForSheets(doc);

            var ids
                = new FilteredElementCollector(doc)
                    .OfClass(typeof(ViewSheet))
                    .Where(s => bOrg.GetFolderItems(s.Id).First().Name.Equals(
                        folder_name))
                    .Select(e => e.Id);

            return ids;
        }

  

I am pretty sure that this topic has been discussed in other threads here in the forum as well, by the way...

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes