<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(idFamilyType) _
Select element
'' put the
result as a list of element for accessibility.
Return elems.ToList()
End Function
</VB.NET>