Revit プラットフォーム API では、開口部オブジェクトは Element オブジェクトから派生したものであり、Element オブジェクト プロパティとメソッドのすべてが含まれています。プロジェクト内のすべての開口部を取得するには、Document.ElementIterator を使用して Elements.Opening オブジェクトを検索します。
このセクションでは、開口部プロパティを使用する方法について説明します。
曲線の詳細は、「ジオメトリ」を参照してください。
次の例は、既存の開口部プロパティを取得する方法を示します。
|
コード領域 11-6: 既存の開口部プロパティを取得 |
private void Getinfo_Opening(Opening opening)
{
string message = "Opening:";
//get the host element of this opening
message += "\nThe id of the opening's host element is : " + opening.Host.Id.IntegerValue;
//get the information whether the opening has a rect boundary
//If the opening has a rect boundary, we can get the geometry information from BoundaryRect property.
//Otherwise we should get the geometry information from BoundaryCurves property
if (opening.IsRectBoundary)
{
message += "\nThe opening has a rectangular boundary.";
//array contains two XYZ objects: the max and min coords of boundary
IList<XYZ> boundaryRect = opening.BoundaryRect;
//get the coordinate value of the min coordinate point
XYZ point = opening.BoundaryRect[0];
message += "\nMin coordinate point:(" + point.X + ", "
+ point.Y + ", " + point.Z + ")";
//get the coordinate value of the Max coordinate point
point = opening.BoundaryRect[1];
message += "\nMax coordinate point: (" + point.X + ", "
+ point.Y + ", " + point.Z + ")";
}
else
{
message += "\nThe opening doesn't have a rectangular boundary.";
// Get curve number
int curves = opening.BoundaryCurves.Size;
message += "\nNumber of curves is : " + curves;
for (int i = 0; i < curves; i++)
{
Autodesk.Revit.DB.Curve curve = opening.BoundaryCurves.get_Item(i);
// Get curve start point
message += "\nCurve start point: " + XYZToString(curve.GetEndPoint(0));
// Get curve end point
message += "; Curve end point: " + XYZToString(curve.GetEndPoint(1));
}
}
TaskDialog.Show("Revit",message);
}
// output the point's three coordinates
string XYZToString(XYZ point)
{
return "(" + point.X + ", " + point.Y + ", " + point.Z + ")";
}
|
Revit プラットフォーム API で、プロジェクトに開口部を作成するには、Document.NewOpening()メソッドを使用します。さまざまなホスト要素に開口部を作成するために使用できる、4 つのメソッド オーバーロードがあります。
|
コード領域 11-7: NewOpening() |
//Create a new Opening in a beam, brace and column. public Opening NewOpening(Element famInstElement, CurveArray profile, eRefFace iFace); |
//Create a new Opening in a roof, floor and ceiling. public Opening NewOpening(Element hostElement, CurveArray profile, bool bPerpendicularFace); |
//Create a new Opening Element. public Opening NewOpening(Level bottomLevel, Level topLevel, CurveArray profile); |
//Create an opening in a straight wall or arc wall. public Opening NewOpening(Wall, XYZ pntStart, XYZ pntEnd); |
図 39: ホスト要素の面に垂直な開口部の切り取り
図 40: ホスト要素に垂直な開口部の切り取り