No announcement yet.

How to get elements by view

  • Filter
  • Time
  • Show
Clear All
new posts

    How to get elements by view

    Normally get elements by view should write as follow:
    FilteredElementCollector coll = new FilteredElementCollector(m_document, view.Id).WhereElementIsNotElementType();
    But I found if invoke this statement will consume so much memory as a result if loop every views to get elements will consume so much memory. But if I get elements by document as follow:
    FilteredElementCollector coll = new FilteredElementCollector(m_document).WhereElementI sNotElementType();
    it will consume almost no memory even I invoke it at every views. Anybody know why.

    if it is bug. and I think I should get all elements by document firstly. then classify those elements by views. But now I don't know how to know which elements belong to (or are visibly to ) which views. It sees no method to classify it. Can anyone help me. thx

    If you want to start with the big list, you can use the Linq namespace

    See Enumerable.GroupBy(TSource, TKey, TElement) Method (IEnumerable(TSource), Func(TSource, TKey), Func(TSource, TElement)) (System.Linq)

    After you get the list of Elements, try something like this:

    IEnumerable<IGrouping<View, Element>> query = list.GroupBy(e=> doc.get_Element(e.OwnerViewId) as View, e => e);
    PS: I haven´t tested it
    Gonçalo Feio
    "Ignorance, ignorance, sheer ignorance - you know there's no confidence to equal it. It's only when you know something about a profession, I think, that you're timid and careful." George Orson Welles


    Related Topics