In the Revit Platform API, the Opening object is derived from the Element object and contains all of the Element object properties and methods. To retrieve all Openings in a project, use Document.ElementIterator to find the Elements.Opening objects.
This section explains how to use the Opening properties.
For more details about Curve, refer to Geometry.
The following example illustrates how to retrieve the existing Opening properties.
Code Region 11-6: Retrieving existing opening properties |
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 + ")"; } |
In the Revit Platform API, use the Document.NewOpening() method to create an opening in your project. There are four method overloads you can use to create openings in different host elements:
Code Region 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); |
Figure 39: Opening cut perpendicular to the host element face
Figure 40: Opening cut vertically to the host element