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: 

Search and filter the invisible elements in the view range.

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
453 Views, 3 Replies

Search and filter the invisible elements in the view range.

I am trying to find out all elements in a view. Regardless it is hidden or visible.

 

I can get the visible elements by FilteredElementCollector(Document, ElementId) that will search and filter the visible elements in a view,

but there seems to be no way to access the invisible. I try to switch the display mode by using View.EnableRevealHiddenMode().

The problem can be solved, but this process is slow in large projects. There is a better way to do this?

Tags (1)
3 REPLIES 3
Message 2 of 4
ollikat
in reply to: Anonymous
Message 3 of 4
Anonymous
in reply to: Anonymous

Dear ollikat,

Thank you for your reply. I have seen, and he is the same problem.

This gave me some hints,but did not completely solve my problem.

In the absence of a better solution,I do like this:

private IList<Element> GetViewElements(Document doc)
{
    var elemList = new List<Element>();
    var view = doc.ActiveView;
    var ck = view.IsInTemporaryViewMode(TemporaryViewMode.RevealHiddenElements)
    if(!ck)
    {
        var trans = new Transaction(doc,"show invisible");
        tran.Start();
        view.EnableRevealHiddenMode();
        var collector = new FilteredElementCollector(_doc, _doc.ActiveView.Id);
        elemList =collector.WherePasses(PassesFilter).ToElements();
        trans.RollBack();
    }
    else
    {
        var collector = new FilteredElementCollector(_doc, _doc.ActiveView.Id);
        elemList = collector.WherePasses(PassesFilter).ToElements();
    }
    return elemList;
 }

 

 

Message 4 of 4
jeremy_tammik
in reply to: Anonymous

Dear adndeveloper1,

 

Thank you for your query, and ollikat and Arnošt Löbel for their pointer and answers in the thread

 

http://forums.autodesk.com/t5/Revit-API/Determine-if-an-element-is-visible-in-a-view/td-p/4896040

 

Your solution looks good and efficinet to me.

 

If it returns the elements you need, I cannot see anything to improve further.

 

Arnošt's suggestion is presented in more detail here to determine all visible and hidden elements in a view:

 

http://thebuildingcoder.typepad.com/blog/2013/08/determining-absolutely-all-visible-elements.html

 

I hope this helps.

 

Best regards,

 

Jeremy

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open

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