Namespace:
Autodesk.Revit.DB
Opening
Class
Description:
An opening in an Autodesk Revit project or family document.
An opening in an Autodesk Revit project or family document.
Remarks:
The object represents a variety of different types of openings:
The object represents a variety of different types of openings:
- A rectangular opening in a wall created by two boundary points in a revit project.
- An opening created by a set of curves applied to a roof, floor, ceiling, beam, brace or column.
- A vertical shaft opening extending one or more levels.
- A simple opening created on a wall or ceiling in a family document.
Examples
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.ToString();
//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 + ")";
}