© 2010 Autodesk
Introduction to Revit 2011 API
要素フィルタ
 クラスと要素名
<VB.NET>
''  Find a list of elements with given class, name, category (optional).
Public Shared Function FindElements(ByVal rvtDoc As Document, _
    ByVal targetType As Type, ByVal targetName As String, _
    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(rvtDoc).OfClass(targetType)
    If Not (targetCategory = Nothing) Then
            collector.OfCategory(targetCategory)
    End If
    ''  parse the collection for the given names. using LINQ query here.
    Dim elems = _
        From element In collector _
        Where element.Name.Equals(targetName) _
        Select element
    ''  put the result as a list of element for accessibility.
    Return elems.ToList()
End Function
</VB.NET>
§クラスと要素名で該当する要素を見つける
ここでは、まずクラスでフィルタし、レベル 1のようにUIで表示されている要素の名前でクエリして該当する全ての要素を見つけています。