'Creating bounding box for a polygon using Revit API in C#
I am trying to create a bounding box for any given ploygon using Revit API. Can someone help?
namespace Revit_SquarePlacement.Command
{
[Transaction(TransactionMode.Manual)]
class cmd_Training : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
{
try
{
UIApplication UIAPP = commandData.Application;
UIDocument UIDoc = UIAPP.ActiveUIDocument;
Autodesk.Revit.DB.Document ActiveDoc = UIDoc.Document;
//Creating Bounding Box
Reference oRef = UIDoc.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element);
Element oLineEle = ActiveDoc.GetElement(oRef.ElementId);
Line oLine = oLineEle as Wall;
if (oWall != null)
{
LocationCurve WallocCurve = oWall.Location as LocationCurve;
Line oLine = WallocCurve.Curve as Line;
XYZ LineStartPoint = oLine.GetEndPoint(0);
XYZ LineEndPoint = oLine.GetEndPoint(1);
}
I tried finding the start and end point of a line and using that I tried getting min and max value of the line in order to get a bounding box. How should I move forward?
Solution 1:[1]
The Building Coder samples defines a method ExpandTo that can do what you require:
It is used and described here:
- Curve Following Face and Bounding Box Implementation
- GeoSnoop .NET Boundary Curve Loop Visualisation
- Determining the Size and Location of Viewports on a Sheet
- Vacation End, Forge News and Bounding Boxes
- FilterRule Use and Retrieving Exterior Walls
- Room Boundaries to CSV and WPF Template
- AI, Boundaries, Loops and RevitApiDocs 2020
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jeremy Tammik |
