© 2010 Autodesk
Introduction to Revit 2011 API
Element Filtering
4.1 Find Instances of a Given Family Type
§
<VB.NET>
''  Find a list of element with the given Class, family type and Category (optional).
Function FindInstancesOfType(ByVal targetType As Type, _
     ByVal idFamilyType As ElementId, _
     Optional ByVal targetCategory As BuiltInCategory = Nothing) As IList(Of Element)
   ''  narrow down to the elements of the given type and category
   Dim collector = New FilteredElementCollector(m_rvtDoc).OfClass(targetType)
   If Not (targetCategory = Nothing) Then
        collector.OfCategory(targetCategory)
   End If
   ''  parse the collection for the given family type id. using LINQ query here.
   Dim elems = _
        From element In collector _
        Where element.Parameter(BuiltInParameter.SYMBOL_ID_PARAM). _ 
              AsElementId.Equals(idType) _
        Select element
   ''  put the result as a list of element for accessibility.
   Return elems.ToList()
End Function
</VB.NET>
§e.g., Find doors with a given type “M_Single-Flush: 0915 x 2134”
§