Solids and faces are sometimes used as inputs to other utilities. The Revit API provides several routines which can be used to create such geometry from scratch or to derive it from other inputs.
The method
returns a copy of the input geometry element with a transformation applied. Because this geometry is a copy, its members cannot be used as input references to other Revit elements, but it can be used geometric analysis and extraction.
The GeometryCreationUtilities class is a utility class that allows construction of basic solid shapes:
The resulting geometry is not added to the document as a part of any element. However, the created Solid can be used as inputs to other API functions, including:
The following example uses the GeometryCreationUtilities class to create cylindrical shapes based on a location and height. This might be used, for example, to create volumes around the ends of a wall in order to find other walls within close proximity to the wall end points:
Code Region: Create cylindrical solid |
// Build cylinder centered at wall end point, extending 3' in diameter CurveLoop cylinderLoop = new CurveLoop(); XYZ arcCenter = new XYZ(endPoint.X, endPoint.Y, elevation); Application application = wall.Document.Application; Arc firstArc = Arc.Create(arcCenter, 1.5, 0, Math.PI, XYZ.BasisX, XYZ.BasisY); Arc secondArc = Arc.Create(arcCenter, 1.5, Math.PI, 2 * Math.PI, XYZ.BasisX, XYZ.BasisY); cylinderLoop.Append(firstArc); cylinderLoop.Append(secondArc); List<CurveLoop> singleLoop = new List<CurveLoop>(); singleLoop.Add(cylinderLoop); Solid proximityCylinder = GeometryCreationUtilities.CreateExtrusionGeometry(singleLoop, XYZ.BasisZ, height); |
The BooleanOperationsUtils class provides methods for combining a pair of solid geometry objects.
The ExecuteBooleanOperation() method takes a copy of the input solids and produces a new solid as a result. Its first argument can be any solid, either obtained directly from a Revit element or created via another operation like GeometryCreationUtils.
The method ExecuteBooleanOperationModifyingOriginalSolid() performs the boolean operation directly on the first input solid. The first input must be a solid which is not obtained directly from a Revit element. The property GeometryObject.IsElementGeometry can identify whether the solid is appropriate as input for this method.
Options to both methods include the operations type: Union, Difference, or Intersect. The following example demonstrates how to get the intersection of two solids and then find the volume.
Code Region: Volume of Solid Intersection |
private void ComputeIntersectionVolume(Solid solidA, Solid solidB) { Solid intersection = BooleanOperationsUtils.ExecuteBooleanOperation(solidA, solidB, BooleanOperationsType.Intersect); double volumeOfIntersection = intersection.Volume; } |