複合構造

複合構造

壁、床、天井、屋根はすべて API クラス HostObject の子です。HostObject (とその関連タイプ クラス HostObjAttributes)は、CompoundStructure への読み込み専用アクセスを提供します。

CompoundStructure クラスは、異なるマテリアルで構成される一連のレイヤに対して次の読み込みと書き込みアクセスを提供します。

通常、これらのレイヤは平行で、固定したレイヤ幅でホスト オブジェクト全体を延長します。ただし、壁の場合は構造を「垂直に複合」することができ、その場合、壁の上部と下部からの特定の垂直距離でレイヤが異なります。これらを識別するには、CompoundStructure.IsVerticallyCompound を使用します。垂直複合構造物の場合、構造は、ポリゴン領域に分割される長方形による垂直断面となります。ポリゴン領域の側面はすべて垂直か水平の断面となります。マップは、これらの領域を領域のプロパティを決定する CompoundStructure のレイヤのインデックスに関連付けます。

複合構造は、異なるレイヤ境界のジオメトリ位置を見つけるために使用できます。メソッド CompoundStructure.GetOffsetForLocationLine()により中央の位置基準から任意の位置基準オプション(躯体の中心線、いずれかの側面の仕上げ面、躯体の側面)までのオフセットが分かります。

位置基準までのオフセットが分かれば、CompoundStructure.GetLayerWidth()を使用して既知の位置から開始して各境界レイヤの幅を取得することによって、各レイヤ境界の位置を取得できます。

CompoundStructure の使用に関する注意事項:

マテリアル

HostObjAttributes の各 CompoundStructureLayer は通常、一部のタイプのマテリアルで表示されます。CompoundStructureLayer.MaterialId が -1 を返す場合、マテリアルはカテゴリに関連します。詳細は、「マテリアル」を参照してください。次のサンプル コードは、CompoundStructureLayer マテリアルの取得方法を説明しています。

コード領域 11-5: CompoundStructureLayer マテリアルを取得

public void GetWallLayerMaterial(Autodesk.Revit.DB.Document document, Wall wall)
{
        // get WallType of wall
        WallType aWallType = wall.WallType;
        // Only Basic Wall has compoundStructure
        if (WallKind.Basic == aWallType.Kind)
        {

                // Get CompoundStructure
                CompoundStructure comStruct = aWallType.GetCompoundStructure();
                Categories allCategories = document.Settings.Categories;

                // Get the category OST_Walls default Material; 
                // use if that layer's default Material is <By Category>
                Category wallCategory = allCategories.get_Item(BuiltInCategory.OST_Walls);
                Autodesk.Revit.DB.Material wallMaterial = wallCategory.Material;

                foreach (CompoundStructureLayer structLayer in comStruct.GetLayers())
                {
                        Autodesk.Revit.DB.Material layerMaterial = 
                                document.GetElement(structLayer.MaterialId) as Material;

                        // If CompoundStructureLayer's Material is specified, use default
                        // Material of its Category
                        if (null == layerMaterial)
                        {
                                switch (structLayer.Function)
                                {
                                        case MaterialFunctionAssignment.Finish1:
                                                layerMaterial =                                       
                                                        allCategories.get_Item(BuiltInCategory.OST_WallsFinish1).Material;
                                                break;
                                        case MaterialFunctionAssignment.Finish2:
                                                layerMaterial =                                      
                                                        allCategories.get_Item(BuiltInCategory.OST_WallsFinish2).Material;
                                                break;
                                        case MaterialFunctionAssignment.Membrane:
                                                layerMaterial =
                                                        allCategories.get_Item(BuiltInCategory.OST_WallsMembrane).Material;
                                                break;
                                        case MaterialFunctionAssignment.Structure:
                                                layerMaterial =  
                                                        allCategories.get_Item(BuiltInCategory.OST_WallsStructure).Material;
                                                break;
                                        case MaterialFunctionAssignment.Substrate:
                                                layerMaterial = 
                                                        allCategories.get_Item(BuiltInCategory.OST_WallsSubstrate).Material;
                                                break;
                                        case MaterialFunctionAssignment.Insulation:
                                                layerMaterial = 
                                                        allCategories.get_Item(BuiltInCategory.OST_WallsInsulation).Material;
                                                break;
                                        default:
                                                // It is impossible to reach here
                                                break;
                                }
                                if (null == layerMaterial)
                                {
                                        // CompoundStructureLayer's default Material is its SubCategory
                                        layerMaterial = wallMaterial;
                                }
                        }
                        TaskDialog.Show("Revit","Layer Material: " + layerMaterial);
                }
        }
}

場合によっては「構造」レイヤのマテリアルのみが必要となることがあります。関数が MaterialFunctionAssignment.Structure になっているそれぞれの例を見るのではなく、CompoundStructure.StructuralMaterialIndex プロパティを使用して、マテリアルが解析の目的のタイプの構造プロパティを定義しているレイヤのインデックスを探します。