レベル

レベル

レベルは有限の水平面で、壁、屋根、床、天井などのレベルにホストされる要素の参照面となります。Revit プラットフォーム API では、Level クラスは Element クラスから派生します。継承された Name プロパティは、Revit UI のグリッド記号の横にあるユーザが認識できるレベル名を取得するために使用されます。プロジェクト内のすべてのレベルを取得するには、ElementIterator イテレタを使用してレベル オブジェクトを検索します。

立面図

Level クラスには次のプロパティがあります。

  • Elevation プロパティ(LEVEL_ELEV)は、地表レベルの上または下の高さを取得したり変更するために使用されます。
  • ProjectElevation プロパティは、高さ基準パラメータの値にかかわらず、プロジェクトの基準点に基づいた高さを取得するために使用されます。
  • 高さ基準はレベル タイプ パラメータです。
    • その BuiltInParameter は LEVEL_RELATIVE_BASE_TYPE です。
    • その StorageType は整数です。
    • 0 はプロジェクト、1 は共有を表します。

次のコード サンプルは、Level クラス フィルタを使用してプロジェクトのすべてのレベルを取得する方法を表しています。

コード領域 15-1: すべてのレベルを取得

private void Getinfo_Level(Document document)
{
        StringBuilder levelInformation = new StringBuilder();
        int levelNumber = 0;
        FilteredElementCollector collector = new FilteredElementCollector(document);
        ICollection<Element> collection = collector.OfClass(typeof(Level)).ToElements();
        foreach (Element e in collection)
        {
                Level level = e as Level;
        
                if (null != level)
                {
                        // keep track of number of levels
                        levelNumber++;
                
                        //get the name of the level
                        levelInformation.Append("\nLevel Name: " + level.Name);

                        //get the elevation of the level
                        levelInformation.Append("\n\tElevation: " + level.Elevation);
                
                        // get the project elevation of the level
                        levelInformation.Append("\n\tProject Elevation: " + level.ProjectElevation);
                }
        }

        //number of total levels in current document
        levelInformation.Append("\n\n There are " + levelNumber + " levels in the document!");
        
        //show the level information in the messagebox
        TaskDialog.Show("Revit",levelInformation.ToString());
}

レベルを作成する

[レベル]コマンドを使用すると、建物内の垂直方向の高さや階を定義し、既存の各階や他の建物参照にレベルを作成できます。レベルは、断面図ビューまたは立面図ビューに追加する必要があります。さらに、Revit プラットフォーム API を使用して新しいレベルを作成できます。

次のコード サンプルでは、新しいレベルを作成する方法を示します。

コード領域 15-2: 新しいレベルを作成

Level CreateLevel(Autodesk.Revit.Document document)
{
        // The elevation to apply to the new level
        double elevation = 20.0; 
        
        // Begin to create a level
        Level level = document.Create.NewLevel(elevation);
        if (null == level)
        {
                throw new Exception("Create a new level failed.");
        }
        
        // Change the level name
        level.Name = "New level";
        
        return level;
}
注: 新しいレベルの作成後は、Revit はこのレベルに関連付けられている平面図ビューを作成しません。必要に応じて、自分で作成できます。平面図ビューの作成方法の詳細は、「平面図ビュー」を参照してください。