このウォークスルーでは、壁からジオメトリ データを取得する方法を説明します。次の情報を取り扱います。
壁のジオメトリ情報を取得するには、詳細なカスタマイズ オプションを持つ Geometry.Options オブジェクトを作成する必要があります。コードは次のとおりです。
コード領域 20-1: Geometry.Options を作成 |
Autodesk.Revit.DB.Options geomOption = application.Create.NewGeometryOptions(); if (null != geomOption) { geomOption.ComputeReferences = true; geomOption.DetailLevel = Autodesk Autodesk.Revit.DB.DetailLevels.Fine; // Either the DetailLevel or the View can be set, but not both //geomOption.View = commandData.Application.ActiveUIDocument.Document.ActiveView; TaskDialog.Show("Revit", "Geometry Option created successfully."); } |
壁のジオメトリは、面とエッジで構成されるソリッドです。面とエッジを取得するには、次の手順を実行します。
サンプル コードは次のとおりです。
コード領域 20-2: 面とエッジを取得 |
private void GetFacesAndEdges(Wall wall) { String faceInfo = ""; Autodesk.Revit.DB.Options opt = new Options(); Autodesk.Revit.DB.GeometryElement geomElem = wall.get_Geometry(opt); foreach (GeometryObject geomObj in geomElem) { Solid geomSolid = geomObj as Solid; if (null != geomSolid) { int faces = 0; double totalArea = 0; foreach (Face geomFace in geomSolid.Faces) { faces++; faceInfo += "Face " + faces + " area: " + geomFace.Area.ToString() + "\n"; totalArea += geomFace.Area; } faceInfo += "Number of faces: " + faces + "\n"; faceInfo += "Total area: " + totalArea.ToString() + "\n"; foreach (Edge geomEdge in geomSolid.Edges) { // get wall's geometry edges } } } TaskDialog.Show("Revit", faceInfo); } |