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