部屋とスペース ジオメトリ

部屋とスペース ジオメトリ

Revit API は、空間要素(部屋とスペース)の 3D ジオメトリへのアクセスを提供します。

SpatialElementGeometryCalculator クラスを使用して空間要素のジオメトリを計算し、ジオメトリと要素の境界要素の間の関係を習得できます。このユーティリティに提供される 2 つのオプションがあります。

ジオメトリの計算結果は、クラス SpatialElementGeometryResults に含まれます。SpatialElementGeometryResults クラスから次を取得できます。

各サブフェースは次を提供します。

このユーティリティの使用に関する注意事項:

次の例では、部屋のジオメトリを計算し、その境界面を検索します

コード領域: SpatialElementGeometryCalculator を使用した面領域

SpatialElementGeometryCalculator calculator = new SpatialElementGeometryCalculator(doc);

// compute the room geometry
SpatialElementGeometryResults results = calculator.CalculateSpatialElementGeometry(room);

// get the solid representing the room's geometry
Solid roomSolid = results.GetGeometry(); 

foreach (Face face in roomSolid.Faces)
{
    double faceArea = face.Area;

    // get the sub-faces for the face of the room
    IList<SpatialElementBoundarySubface> subfaceList = results.GetBoundaryFaceInfo(face);
    foreach (SpatialElementBoundarySubface subface in subfaceList)
    {
        if (subfaceList.Count > 1) // there are multiple sub-faces that define the face
        {
            // get the area of each sub-face
            double subfaceArea = subface.GetSubface().Area;             
            
            // sub-faces exist in situations such as when a room-bounding wall has been
            // horizontally split and the faces of each split wall combine to create the 
            // entire face of the room
        }
    }
}

次の例では、部屋のジオメトリを計算し、部屋を定義する要素に属している面のマテリアルを検索します。

コード領域: SpatialElementGeometryCalculator を使用した面のマテリアル

public void MaterialFromFace()
{
        string s = "";
    Document doc = this.Document;
        UIDocument uidoc = new UIDocument(doc);
        Room room = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element).ElementId) as Room;
        
        SpatialElementBoundaryOptions  spatialElementBoundaryOptions = new SpatialElementBoundaryOptions();
        spatialElementBoundaryOptions.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish;
        SpatialElementGeometryCalculator calculator = new SpatialElementGeometryCalculator(doc, spatialElementBoundaryOptions);
        SpatialElementGeometryResults results = calculator.CalculateSpatialElementGeometry(room);
        Solid roomSolid = results.GetGeometry(); 

        foreach (Face roomSolidFace in roomSolid.Faces)
        {
            foreach (SpatialElementBoundarySubface subface in results.GetBoundaryFaceInfo(roomSolidFace))
            {
                Face boundingElementface = subface.GetBoundingElementFace();
                ElementId id = boundingElementface.MaterialElementId;
                s +=  doc.GetElement(id).Name + ", id = " + id.IntegerValue.ToString() + "\n";
            }
        }
    TaskDialog.Show("revit",s);                 
}