PPT_LOGO_4b
Revit Programming Introduction <#>
Copyright © 2009 Autodesk Inc.
全ての要素をリスト
»    // *ALL* elements are bundled together and accessible via Document's ElementIterator
»    string line;
»    Element elem;
»    ElementIterator iter = commandData.Application.ActiveDocument.Elements;
»    while( iter.MoveNext() )
»    {
»      elem = iter.Current as Element;
»      line = "Id=" + elem.Id.Value.ToString(); // Element Id
»      line += "; Class=" + elem.GetType().Name; // Element class (System.Type)
»      // Element Category, not implemented for all classes, may return null:
»      line += "; Category=" + ( null == elem.Category ? string.Empty : elem.Category.Name );
»      // Element Name (different meaning for different classes, but mostly implemented logically")
»      // Later, we'll see that more precise info on elements can be obtained in class-specific ways...
»      line += "; Name=" + elem.Name;
»      sw.WriteLine( line );
»    }
要素コレクション
Id=16; Class=DimensionType; Category=; Name=Linear - 3mm Arial
Id=17; Class=Element; Category=; Name=
Id=19; Class=Element; Category=; Name=
Id=20; Class=FillPattern; Category=; Name=Solid fill
. . .
Id=126907; Class=Element; Category=; Name=M_W-Wide Flange
Id=126908; Class=Element; Category=; Name=W310X38.7
Id=126933; Class=Element; Category=; Name=Section Boxes
Id=126939; Class=Wall; Category=Walls; Name=Generic - 200mm
ここでは、全ての要素をリストします。
commandData.Application.ActiveDocument.ElementsよりElementIteratorを取得し、iter.MoveNextでイテレータを移動し、ElementIterator ::Currentで現在の要素を取得し、幾つかの情報を表示しています。
実際にはRevit上では公開されていない要素にもアクセスするので、Revitで表示されるよりも多くの情報が表示されます。
仮に、Element以降のクラスから派生されていないクラスは未だAPIでのアクセスはサポートされていませんので御注意下さい。
RvtMgdDbgツールでClass名がElementになっているものがそれに当たります。