Retrieve Area Boundary

Retrieve Area Boundary

Moshe-A
Mentor Mentor
733 Views
3 Replies
Message 1 of 4

Retrieve Area Boundary

Moshe-A
Mentor
Mentor

Hi Guys,

 

i want to retrieve the Lines contour of an Area Boundary Element and i'm stuck

actually i do not know how to iterate the result coming from Area.GetBoundarySegments()

 

thanks in advance

Moshe

 

 

namespace MyNameSpace
{
    [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.ReadOnly)]
    public class Class1 : IExternalCommand
    {
        public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
                Document document = commandData.Application.ActiveUIDocument.Document;

                AreaFilter filter = new AreaFilter();
                FilteredElementCollector collector = new FilteredElementCollector(document, document.ActiveView.Id);

                IList<Element> elementAreas = collector.WherePasses(filter).WhereElementIsNotElementType().ToElements();
                IList<IList<BoundarySegment>> boundarySegments;

                foreach (Element elem in elementAreas)
                {
                    Area ba = elem as Area;
                    boundarySegments = ba.GetBoundarySegments(new SpatialElementBoundaryOptions());
                    // stuck here ???
                }
            }
            catch (Exception e)
            {
                message = "Unexpected Exception thrown.";
                return Autodesk.Revit.UI.Result.Failed;
            }

           return Autodesk.Revit.UI.Result.Succeeded;
        }
    }
}

 

 

0 Likes
Accepted solutions (1)
734 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Moshe-A,

 

Try this:

 

http://lmgtfy.com/?q=revit+api+GetBoundarySegments

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 4

Moshe-A
Mentor
Mentor
thank you
0 Likes
Message 4 of 4

jeremytammik
Autodesk
Autodesk

my pleasure entirely  🙂



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes