M

AnalyticalModelSurface.GetLoops

Description:
Retrieves Analytical Model Loops with respect to the loopType.
Remarks:
For multiple concentric loops, only the outermost loop will be considered External. All other loops will be considered Internal.
public IList<CurveLoop> GetLoops(
	AnalyticalLoopType loopType
)
Return Value IList<CurveLoop> Loops that satisfy loopType criteria are returned.
// retrieve and iterate current selected element
UIDocument uidoc = commandData.Application.ActiveUIDocument;
ICollection<ElementId> selectedIds = uidoc.Selection.GetElementIds();
Document document = uidoc.Document;
foreach (ElementId id in selectedIds)
{
    Element e = document.GetElement(id);
    Wall aWall = e as Wall;
    if (null != aWall)
    {
        // get AnalyticalModelSurface from Structural Wall
        AnalyticalModelSurface modelWall = aWall.GetAnalyticalModel() as AnalyticalModelSurface;
        if (null == modelWall)
        {
            // Architecture wall doesn't have analytical model
            continue;
        }

        // get wall curves
        StringBuilder wallString = new StringBuilder();
        wallString.AppendLine("Wall curves:");
        IList<CurveLoop> wallCurveLoops = modelWall.GetLoops(AnalyticalLoopType.External);
        foreach (CurveLoop curveloop in wallCurveLoops)
        {
            CurveLoopIterator itr = curveloop.GetCurveLoopIterator();
            itr.Reset();
            while (itr.MoveNext())
            {
                Curve wallCurve = itr.Current;
                wallString.AppendLine(String.Format("{0}, {1}", wallCurve.GetEndPoint(0).ToString(), wallCurve.GetEndPoint(1).ToString()));
            }
        }

         TaskDialog.Show("Wall Analytical Model", wallString.ToString());
    }
}