<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Traverse all model elements in a project - top-down approach in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5536820#M73464</link>
    <description>&lt;P&gt;Dear Chintan,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Aaron is absolutely right.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically, the filtered element collector is the one and only channel to retrieve elements from the Revit database.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before it was 'filtered', it was just an element collector and really slow. Back then, you definitely wanted to retrieve everything of interest in one single call, and then structure it yourself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, you could potantially set up numerous filtered element collectors in loops to achieve the kind of hierarchical query you describe.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could start like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  FilteredElementCollector levels
    = new FilteredElementCollector( doc )
      .OfClass( typeof( Level ) );

  foreach( Level level in levels )
  {
    // Now what?
    // We could set up new filtered element 
    // collectors for each level, but it would
    // get complex and we would start repeating
    // ourselves...
  }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think it would still be better to get all elements at once, and then sort them into the structure yourself, something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  // Get all family instances and use those to
  // set up dictionaries for all the required
  // mappings in one fell sweep. In the end, we
  // will need the following mappings:
  // - level to all categories it hosts instances of
  // - for each level and category, all families
  // - family to its types
  // - family type to instances

  FilteredElementCollector instances
    = new FilteredElementCollector( doc )
      .OfClass( typeof( FamilyInstance ) );

  // Top level map.

  Dictionary&amp;lt;ElementId, // level
    List&amp;lt;ElementId&amp;gt;&amp;gt; // categories
      mapLevelToCategories = new
      Dictionary&amp;lt;ElementId,
        List&amp;lt;ElementId&amp;gt;&amp;gt;();

  // What we really need is something like this.
  // It will probably simplify things to implement
  // a custom kind of dictionary for this to add 
  // new entries very simply.

  Dictionary&amp;lt;ElementId, // level
    Dictionary&amp;lt;ElementId, // category
      Dictionary&amp;lt;ElementId, // family
        Dictionary&amp;lt;ElementId, // type
          ElementId&amp;gt;&amp;gt;&amp;gt;&amp;gt; // instance
            map = new Dictionary&amp;lt;ElementId,
              Dictionary&amp;lt;ElementId,
                Dictionary&amp;lt;ElementId,
                  Dictionary&amp;lt;ElementId,
                    ElementId&amp;gt;&amp;gt;&amp;gt;&amp;gt;();

  foreach( FamilyInstance inst in instances )
  {
    Category cat = inst.Category;
    Level lev = doc.GetElement( inst.LevelId ) as Level;
    FamilySymbol sym = inst.Symbol;
    Family fam = sym.Family;

    Debug.Assert( null != cat, "expected valid category" );
    Debug.Assert( null != lev, "expected valid level" );
    Debug.Assert( null != sym, "expected valid symbol" );
    Debug.Assert( null != fam, "expected valid family" );

    if( map.ContainsKey( lev.Id ) )
    {
      mapLevelToCategories[lev.Id].Add( cat.Id );
    }
    else
    {
      // First time we encounter this level, 
      // so start a new level.

      List&amp;lt;ElementId&amp;gt; categoriesOnLevel 
        = new List&amp;lt;ElementId&amp;gt;( 1 );

      categoriesOnLevel.Add( cat.Id );

      mapLevelToCategories.Add( lev.Id, 
        categoriesOnLevel );
    }

    // Sort into families and types pere level and category...
  }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
    <pubDate>Wed, 11 Mar 2015 16:40:41 GMT</pubDate>
    <dc:creator>jeremytammik</dc:creator>
    <dc:date>2015-03-11T16:40:41Z</dc:date>
    <item>
      <title>Traverse all model elements in a project - top-down approach</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5536153#M73462</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to find a way to traverse all the model elements in a Revit project in top down manner:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;levels -&amp;gt; categories -&amp;gt; families -&amp;gt; family types -&amp;gt; instances&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Get all levels in current project.&lt;/P&gt;&lt;P&gt;For each level&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Get all the categories in current level.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; For each category&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Get all the families in current category&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; For each family in current category:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Get all the family types in current family&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For each family type in current family:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Get all the Instances&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On exploring internet w.r.t getting all model elements in revit, I found following:&lt;/P&gt;&lt;P&gt;&lt;A target="_blank" href="http://thebuildingcoder.typepad.com/blog/2009/05/selecting-model-elements.html"&gt;http://thebuildingcoder.typepad.com/blog/2009/05/selecting-model-elements.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which is rather a bottom up approach.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to traverse revit model elements in top down manner?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I noticed that using the approach described in above link, the toposurface and entourage elements like RPC car, male, female, etc are missing.&lt;/P&gt;&lt;P&gt;Do these elements require special handling?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Chintan&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2015 08:11:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5536153#M73462</guid>
      <dc:creator>Chintan.Shah</dc:creator>
      <dc:date>2015-03-11T08:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Traverse all model elements in a project - top-down approach</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5536188#M73463</link>
      <description>&lt;P&gt;there is no way to do that directly&lt;BR /&gt;using class filter to get all families, and get category via Family.FamilyCategory&lt;BR /&gt;using Family.GetFamilySymbolIds() to get all family types,&lt;BR /&gt;using FamilyInstanceFilter to get all family instances.&lt;BR /&gt;&lt;BR /&gt;relationship between level and categories is tricky too (but obvious for Revit developers, you should forget all the stuff learned from AutoCAD etc.)&lt;BR /&gt;actually, you are saying: get all the categories of the instances on a specific level. i'm afraid you can only use ElementLevelFilter to get all those instances and see what's the categories of those instances.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2015 09:04:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5536188#M73463</guid>
      <dc:creator>Aaron.Lu</dc:creator>
      <dc:date>2015-03-11T09:04:32Z</dc:date>
    </item>
    <item>
      <title>Re: Traverse all model elements in a project - top-down approach</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5536820#M73464</link>
      <description>&lt;P&gt;Dear Chintan,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Aaron is absolutely right.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically, the filtered element collector is the one and only channel to retrieve elements from the Revit database.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before it was 'filtered', it was just an element collector and really slow. Back then, you definitely wanted to retrieve everything of interest in one single call, and then structure it yourself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, you could potantially set up numerous filtered element collectors in loops to achieve the kind of hierarchical query you describe.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could start like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  FilteredElementCollector levels
    = new FilteredElementCollector( doc )
      .OfClass( typeof( Level ) );

  foreach( Level level in levels )
  {
    // Now what?
    // We could set up new filtered element 
    // collectors for each level, but it would
    // get complex and we would start repeating
    // ourselves...
  }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think it would still be better to get all elements at once, and then sort them into the structure yourself, something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  // Get all family instances and use those to
  // set up dictionaries for all the required
  // mappings in one fell sweep. In the end, we
  // will need the following mappings:
  // - level to all categories it hosts instances of
  // - for each level and category, all families
  // - family to its types
  // - family type to instances

  FilteredElementCollector instances
    = new FilteredElementCollector( doc )
      .OfClass( typeof( FamilyInstance ) );

  // Top level map.

  Dictionary&amp;lt;ElementId, // level
    List&amp;lt;ElementId&amp;gt;&amp;gt; // categories
      mapLevelToCategories = new
      Dictionary&amp;lt;ElementId,
        List&amp;lt;ElementId&amp;gt;&amp;gt;();

  // What we really need is something like this.
  // It will probably simplify things to implement
  // a custom kind of dictionary for this to add 
  // new entries very simply.

  Dictionary&amp;lt;ElementId, // level
    Dictionary&amp;lt;ElementId, // category
      Dictionary&amp;lt;ElementId, // family
        Dictionary&amp;lt;ElementId, // type
          ElementId&amp;gt;&amp;gt;&amp;gt;&amp;gt; // instance
            map = new Dictionary&amp;lt;ElementId,
              Dictionary&amp;lt;ElementId,
                Dictionary&amp;lt;ElementId,
                  Dictionary&amp;lt;ElementId,
                    ElementId&amp;gt;&amp;gt;&amp;gt;&amp;gt;();

  foreach( FamilyInstance inst in instances )
  {
    Category cat = inst.Category;
    Level lev = doc.GetElement( inst.LevelId ) as Level;
    FamilySymbol sym = inst.Symbol;
    Family fam = sym.Family;

    Debug.Assert( null != cat, "expected valid category" );
    Debug.Assert( null != lev, "expected valid level" );
    Debug.Assert( null != sym, "expected valid symbol" );
    Debug.Assert( null != fam, "expected valid family" );

    if( map.ContainsKey( lev.Id ) )
    {
      mapLevelToCategories[lev.Id].Add( cat.Id );
    }
    else
    {
      // First time we encounter this level, 
      // so start a new level.

      List&amp;lt;ElementId&amp;gt; categoriesOnLevel 
        = new List&amp;lt;ElementId&amp;gt;( 1 );

      categoriesOnLevel.Add( cat.Id );

      mapLevelToCategories.Add( lev.Id, 
        categoriesOnLevel );
    }

    // Sort into families and types pere level and category...
  }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2015 16:40:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5536820#M73464</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2015-03-11T16:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: Traverse all model elements in a project - top-down approach</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5539315#M73465</link>
      <description>&lt;P&gt;Hi Jeremy,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is precisely what I needed. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried out your suggestion and created a multilevel nested dictionary right from level to family instances.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I noticed that using the FamilyInstance filter, I am not getting those elements which are of System family for example, System Family: Basic Wall.&lt;/P&gt;&lt;P&gt;I also want to query some elements like topography which don't belong to any category/family/level.&lt;/P&gt;&lt;P&gt;Any idea how to get such elements?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;Chintan&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2015 08:27:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5539315#M73465</guid>
      <dc:creator>Chintan.Shah</dc:creator>
      <dc:date>2015-03-13T08:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: Traverse all model elements in a project - top-down approach</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5539364#M73466</link>
      <description>&lt;P&gt;Dear Chintan,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am very glad that it helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your appreciation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instances of standard families are represented by FamilyInstance elements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instances of system families are represented by native object instances such as Wall, Pipe, Duct, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will have to enhance and expand the filtered element collector criteria to include the elements you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an&amp;nbsp;example to retrieve MEP elements:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2010/06/retrieve-mep-elements-and-connectors.html" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2010/06/retrieve-mep-elements-and-connectors.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, I added the filter that I sketched out for you to The Building Coder samples:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/CmdCollectorPerformance.cs" target="_blank"&gt;https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/CmdCollectorPerformance.cs&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  #region Traverse all model elements top down Levels &amp;gt; Category &amp;gt; Family &amp;gt; Type &amp;gt; Instance&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might want to share your version of this once you are happy with it and I will put that in instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2015 09:11:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5539364#M73466</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2015-03-13T09:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: Traverse all model elements in a project - top-down approach</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5539436#M73467</link>
      <description>&lt;P&gt;Hi Jeremy,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for a quick reply!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I went thru the link you pointed to.&lt;/P&gt;&lt;P&gt;It looks like we need to have the list of system families whose instances we want. (to create an &lt;SPAN class="teal"&gt;ElementClassFilter corresponding to each system family&lt;/SPAN&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I am writing a general addin which should work for any revit project.&lt;/P&gt;&lt;P&gt;So, basically I won't be knowing the list of system families before hand.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any general way to get the instances of all the system families in current project?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Chintan&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2015 10:05:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5539436#M73467</guid>
      <dc:creator>Chintan.Shah</dc:creator>
      <dc:date>2015-03-13T10:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: Traverse all model elements in a project - top-down approach</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5814607#M73468</link>
      <description>&lt;P&gt;Hi Chintan, I also have the same need. I thought it would be simple to return every model object instance&amp;nbsp;(system or component), however I am still to arrive at a satisfactory final solution. An old post of Jeremy's proposed:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Start temporary transaction&lt;/LI&gt;&lt;LI&gt;Create a default 3D view&lt;/LI&gt;&lt;LI&gt;Create FilteredElementCollection on view elements.&lt;/LI&gt;&lt;LI&gt;Apply WhereElementIsNotElementType&lt;/LI&gt;&lt;LI&gt;Iteration&lt;/LI&gt;&lt;LI&gt;Rollback to remove created view&lt;/LI&gt;&lt;LI&gt;Since it seems that 3D elements are what is wanted here, all elements visible in the new (unfiltered) 3D view are targets.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This seems a rather convoluted approach that I would have thought replaced by some FilteredElementCollector code. Did you resolve this as I am stuck? Maybe we need to get all categories in the project, and then iterate that list to look for instances.&amp;nbsp;I must be down rabbit hole...&amp;nbsp;Dale&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Sep 2015 09:28:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5814607#M73468</guid>
      <dc:creator>Dale.Bartlett</dc:creator>
      <dc:date>2015-09-13T09:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: Traverse all model elements in a project - top-down approach</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5814714#M73469</link>
      <description>&lt;P&gt;Dear Dale,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, there are simpler approaches, that just require executing a single filtered element collector.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It all depends on what exactly you are after.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look here for a number of different suggestions and approaches:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.9" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.9&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope one of them suits you needs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How &lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;exactly&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt; do &lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;you&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt; define 'model elements'?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Sun, 13 Sep 2015 14:20:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5814714#M73469</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2015-09-13T14:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: Traverse all model elements in a project - top-down approach</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5815247#M73470</link>
      <description>&lt;P&gt;Hi Jeremy, Thanks for the reply. To be clear, "all model elements" could be defined as all objects that exist in the real world (chairs, doors ,walls, etc&amp;nbsp;- component and system families). Graphic elements such as levels, sheets, views, dimensions, annotation, profiles,&amp;nbsp;etc would not&amp;nbsp;be included. I have been through all of your samples (and others)&amp;nbsp;many times, and whilst there are lots of examples&amp;nbsp;to filter for a specitic category or feature, I have been unable to come up with a solution that provides all model elements as defined above.&amp;nbsp;Your example from 2009&amp;nbsp;may be the best, but given that it is several years old, I&amp;nbsp;have been looking for&amp;nbsp;more contemporary code. Apologies if&amp;nbsp;I am overlooking something obvious; I thought this would be a five minute job but&amp;nbsp;I have been unable to come up with a simple, solid solution.&amp;nbsp;Thanks again, Dale.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;code&amp;gt;&lt;/P&gt;&lt;P&gt;In 2009, we used the following helper method to select all model elements:&lt;/P&gt;&lt;P&gt;public static ElementSet GetAllModelElements(Application app )&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; ElementSet elems = app.Create.NewElementSet();&lt;BR /&gt;&amp;nbsp; Geo.Options opt = app.Create.NewGeometryOptions();&lt;BR /&gt;&amp;nbsp; ElementIterator iter = app.ActiveDocument.Elements;&lt;BR /&gt;&amp;nbsp; while( iter.MoveNext() )&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Element e = iter.Current as Element;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if( !( e is Symbol || e is FamilyBase ) )&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if( null != e.Category )&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if( null != e.get_Geometry( opt ) )&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elems.Insert( e );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; return elems;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;lt;/code&amp;gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2015 07:17:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5815247#M73470</guid>
      <dc:creator>Dale.Bartlett</dc:creator>
      <dc:date>2015-09-14T07:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: Traverse all model elements in a project - top-down approach</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5815330#M73471</link>
      <description>&lt;P&gt;Dear Dale,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this fit the bill?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  IEnumerable&amp;lt;Element&amp;gt; GetAllModelElements( 
    Document doc )
  {
    Options opt = new Options();

    return new FilteredElementCollector( doc )
      .WhereElementIsNotElementType()
      .WhereElementIsViewIndependent()
      .Where&amp;lt;Element&amp;gt;( e 
        =&amp;gt; null != e.Category
        &amp;amp;&amp;amp; null != e.get_Geometry( opt ) );
  }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just now added and published this in The Building Coder samples release 2016.0.120.14:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/jeremytammik/the_building_coder_samples/releases/tag/2016.0.120.14" target="_blank"&gt;https://github.com/jeremytammik/the_building_coder_samples/releases/tag/2016.0.120.14&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try it out, and let's ensure that we really get something up and running that suits your needs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2015 08:39:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5815330#M73471</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2015-09-14T08:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: Traverse all model elements in a project - top-down approach</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5815702#M73472</link>
      <description>&lt;P&gt;If I ever get to AU again, I owe you a beer!&amp;nbsp;Two maybe. Works perfectly. Thanks again, I hope this is helpful for others as I really struggled to resolve it. Dale&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2015 13:48:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/traverse-all-model-elements-in-a-project-top-down-approach/m-p/5815702#M73472</guid>
      <dc:creator>Dale.Bartlett</dc:creator>
      <dc:date>2015-09-14T13:48:41Z</dc:date>
    </item>
  </channel>
</rss>

