<?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: Select all physical items in model in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6823665#M60808</link>
    <description>&lt;P&gt;I'd probably use .WhereElementIsViewIndependent&amp;nbsp;in there somewhere also. Faster than some of the iteration/LINQ methods.&lt;/P&gt;</description>
    <pubDate>Mon, 23 Jan 2017 09:47:01 GMT</pubDate>
    <dc:creator>matthew_taylor</dc:creator>
    <dc:date>2017-01-23T09:47:01Z</dc:date>
    <item>
      <title>Select all physical items in model</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6822366#M60805</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to select all the Model Element instances in my model. i.e. anything that is a physical object, so I can change the value of a certain Property&amp;nbsp;on all of them.&amp;nbsp;Property value will be different depending on where the instance is in the model. I have the below method but it is not picking up host families or the likes of ducts. Help appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IList&amp;lt;Element&amp;gt; GetAllElements(Document doc)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ElementClassFilter FamilyInstanceFilter = new ElementClassFilter(typeof(FamilyInstance));&lt;BR /&gt;FilteredElementCollector FamilyInstanceCollector = new FilteredElementCollector(doc);&lt;BR /&gt;IList&amp;lt;Element&amp;gt; ElementsCollection = FamilyInstanceCollector.WherePasses(FamilyInstanceFilter).ToElements();&lt;BR /&gt;IList&amp;lt;Element&amp;gt; AllModelElements = new List&amp;lt;Element&amp;gt;();&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;foreach (Element e in ElementsCollection)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;if ((null != e.Category)&lt;BR /&gt;&amp;amp;&amp;amp; (null != e.LevelId)&lt;BR /&gt;&amp;amp;&amp;amp; (null != e.get_Geometry(new Options()))&lt;BR /&gt;)&lt;BR /&gt;{&lt;BR /&gt;AllModelElements.Add(e);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;return AllModelElements;&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Sun, 22 Jan 2017 07:12:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6822366#M60805</guid>
      <dc:creator>deusextechnic</dc:creator>
      <dc:date>2017-01-22T07:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: Select all physical items in model</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6822841#M60806</link>
      <description>&lt;P&gt;Your filter looks OK to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cf.:&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;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Sun, 22 Jan 2017 17:45:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6822841#M60806</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-01-22T17:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: Select all physical items in model</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6822940#M60807</link>
      <description>&lt;P&gt;When you &amp;nbsp;use a familyInstance filter , you only find User Created families, and not the system families.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public static&amp;nbsp;class Extensions&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;public static bool IsPhysicalElement(this Element e)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;if (e.Category == null) return false;&lt;/P&gt;&lt;P&gt;if (e.ViewSpecific) return false;&lt;/P&gt;&lt;P&gt;// exclude specific unwanted categories&lt;/P&gt;&lt;P&gt;if (((BuiltInCategory)e.Category.Id.IntegerValue) == BuiltInCategory.OST_HVAC_Zones) return false;&lt;/P&gt;&lt;P&gt;//&lt;/P&gt;&lt;P&gt;return e.Category.CategoryType == CategoryType.Model &amp;amp;&amp;amp; e.Category.CanAddSubcategory;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;List&amp;lt;Element&amp;gt; AllElem = new FilteredElementCollector(document)&lt;/P&gt;&lt;P&gt;.WhereElementIsNotElementType()&lt;/P&gt;&lt;P&gt;.Where(e =&amp;gt;e.IsPhysicalElement() )&lt;/P&gt;&lt;P&gt;.ToList&amp;lt;Element&amp;gt;();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Jan 2017 19:14:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6822940#M60807</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2017-01-22T19:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: Select all physical items in model</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6823665#M60808</link>
      <description>&lt;P&gt;I'd probably use .WhereElementIsViewIndependent&amp;nbsp;in there somewhere also. Faster than some of the iteration/LINQ methods.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 09:47:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6823665#M60808</guid>
      <dc:creator>matthew_taylor</dc:creator>
      <dc:date>2017-01-23T09:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: Select all physical items in model</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6826648#M60809</link>
      <description>&lt;P&gt;Dear Matt,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for pointing out the importance of being aware of the relative performance of quick&amp;nbsp;and slow element filters versus LINQ or .NET post-processing, cf. also:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2015/12/quick-slow-and-linq-element-filtering.html#2" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2015/12/quick-slow-and-linq-element-filtering.html#2&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your suggestion is great.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, don't you think&amp;nbsp;&lt;SPAN&gt;WhereElementIsViewIndependent returns the exact same result as Element.ViewSpecific, which is already checked in the IsPhysicalElement predicate?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Or, to be exact, the exact opposite result?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I would assume and hope that is the case.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Correction: your suggestion holds in any case, since&amp;nbsp;WhereElementIsViewIndependent can be used directly on the filtered element collector BEFORE using LINQ or .NET to iterate over the collection and check&amp;nbsp;Element.ViewSpecific for each element, one by one.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Cool!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jeremy&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 11:04:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6826648#M60809</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-01-24T11:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: Select all physical items in model</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6826683#M60810</link>
      <description>&lt;P&gt;Hi Jeremy,&lt;/P&gt;
&lt;P&gt;Haha, yes, your correction is what I was going to say!&lt;/P&gt;
&lt;P&gt;Just for anybody reading this though, &lt;SPAN&gt;WhereElementIsViewIndependent would need to be used in conjunction with WhereElementIsNotElementType (as &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2083518"&gt;@FAIR59&lt;/a&gt;&amp;nbsp;showed) to get the desired result.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I use LINQ a lot and don't feel that performance is altered much (by using it). Using fast filters where possible certainly helps with that, though.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I used to view LINQ as 'magic'! It's now an everyday tool that simplifies many operations. (I have your blog to thank for that.)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope you're having a great day!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;-Matt&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 11:16:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6826683#M60810</guid>
      <dc:creator>matthew_taylor</dc:creator>
      <dc:date>2017-01-24T11:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: Select all physical items in model</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6826751#M60811</link>
      <description>&lt;P&gt;Dear Matt,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I promise you that extracting element data from Revit to .NET and checking it there, e.g., with LINQ, costs at least twice as much time&amp;nbsp;as leaving it on the Revit side and applying some kind of filter instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Therefore, whenever possible, it pays off hugely to analyse all the element properties and how they are reflected in parameter values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The parameter values can be filtered using a filtered element collector parameter filter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;50% speed improvement over using LINQ post-processing guaranteed:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2010/06/element-name-parameter-filter-correction.html" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2010/06/element-name-parameter-filter-correction.html&lt;/A&gt;&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>Tue, 24 Jan 2017 11:44:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6826751#M60811</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-01-24T11:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: Select all physical items in model</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6826777#M60812</link>
      <description>&lt;P&gt;Hi Jeremy,&lt;/P&gt;
&lt;P&gt;Don't worry, I have heeded this warning in the past and&amp;nbsp;I always fast filter the collector as much as possible before even thinking LINQing.&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;-Matt&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 11:51:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6826777#M60812</guid>
      <dc:creator>matthew_taylor</dc:creator>
      <dc:date>2017-01-24T11:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Select all physical items in model</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6826847#M60813</link>
      <description>&lt;P&gt;I have a hope that it can help:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;RevitAPI.chm&lt;/STRONG&gt; (of Revit 2017.1 SDK). The &lt;EM&gt;ElementClassFilter&lt;/EM&gt; class description:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This filter will match elements whose class is an exact match to the input class, or elements whose class is derived from the input class.&lt;BR /&gt;&lt;BR /&gt;There is a small subset of Element subclasses in the API which are &lt;STRONG&gt;not supported&lt;/STRONG&gt; by this filter. These types exist in the API, but not in Revit's native object model, which means that this filter doesn't support them. In order to use a class filter to find elements of these types, it is necessary to use a higher level class and then process the results further to find elements matching only the subtype. &lt;STRONG&gt;The following types are affected by this restriction&lt;/STRONG&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Subclasses of Autodesk.Revit.DB.Material&lt;BR /&gt;Subclasses of Autodesk.Revit.DB.CurveElement&lt;BR /&gt;Subclasses of Autodesk.Revit.DB.ConnectorElement&lt;BR /&gt;Subclasses of Autodesk.Revit.DB.HostedSweep&lt;BR /&gt;Autodesk.Revit.DB.Architecture.Room&lt;BR /&gt;Autodesk.Revit.DB.Mechanical.Space&lt;BR /&gt;Autodesk.Revit.DB.Area&lt;BR /&gt;Autodesk.Revit.DB.Architecture.RoomTag&lt;BR /&gt;Autodesk.Revit.DB.Mechanical.SpaceTag&lt;BR /&gt;Autodesk.Revit.DB.AreaTag&lt;BR /&gt;Autodesk.Revit.DB.CombinableElement&lt;BR /&gt;Autodesk.Revit.DB.Mullion&lt;BR /&gt;Autodesk.Revit.DB.Panel&lt;BR /&gt;Autodesk.Revit.DB.AnnotationSymbol&lt;BR /&gt;Autodesk.Revit.DB.Structure.AreaReinforcementType&lt;BR /&gt;Autodesk.Revit.DB.Structure.PathReinforcementType&lt;BR /&gt;Autodesk.Revit.DB.AnnotationSymbolType&lt;BR /&gt;Autodesk.Revit.DB.Architecture.RoomTagType&lt;BR /&gt;Autodesk.Revit.DB.Mechanical.SpaceTagType&lt;BR /&gt;Autodesk.Revit.DB.AreaTagType&lt;BR /&gt;Autodesk.Revit.DB.Structure.TrussType&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 12:23:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6826847#M60813</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-01-24T12:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: Select all physical items in model</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6827219#M60814</link>
      <description>&lt;P&gt;Hi Jeremy, Matt&lt;/P&gt;&lt;P&gt;I agree that you should use the .WhereElementIsViewIndependent filter instead of checking Element.ViewSpecific.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The rest of the checks in the IsPhysicalElement predicate check properties of the Element.Category and I think those can't be filtered in a fast filter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An alternative approach would be to define your own set of Categories ( maybe 20 or 30 ). All the elements in the "Physical"model would belong to that set, if you have defined it correct.&lt;BR /&gt;Then you can use a ElementMulticategoryFilter combined with the .WhereElementIsNotElementType and .WhereElementIsViewIndependent&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cheers, Frank&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 14:38:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6827219#M60814</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2017-01-24T14:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: Select all physical items in model</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6827327#M60815</link>
      <description>&lt;P&gt;Dear Frank,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, indeed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That reminds me of my&amp;nbsp;approaches to retrieve MEP and structural elements:&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 published this discussion on the blog now, and added it to that topic group as well:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2017/01/dynamic-scripts-model-elements-and-vertical-alignment.html#3" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2017/01/dynamic-scripts-model-elements-and-vertical-alignment.html#3&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much for all your highly qualified contributions!&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>Tue, 24 Jan 2017 15:02:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-physical-items-in-model/m-p/6827327#M60815</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-01-24T15:02:05Z</dc:date>
    </item>
  </channel>
</rss>

