BuildingCoder.CmdSlabBoundary.GetFloorBoundaryPolygons C# (CSharp) Метод

GetFloorBoundaryPolygons() публичный статический Метод

Return all floor slab boundary loop polygons for the given floors, offset downwards from the bottom floor faces by a certain amount.
public static GetFloorBoundaryPolygons ( List floors, Options opt ) : List>
floors List
opt Options
Результат List>
        public static List<List<XYZ>> GetFloorBoundaryPolygons(
            List<Element> floors,
            Options opt)
        {
            List<List<XYZ>> polygons = new List<List<XYZ>>();

              foreach( Floor floor in floors )
              {
            GeometryElement geo = floor.get_Geometry( opt );

            //GeometryObjectArray objects = geo.Objects; // 2012
            //foreach( GeometryObject obj in objects ) // 2012

            foreach( GeometryObject obj in geo ) // 2013
            {
              Solid solid = obj as Solid;
              if( solid != null )
              {
            GetBoundary( polygons, solid );
              }
            }
              }
              return polygons;
        }

Usage Example

        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication app   = commandData.Application;
            UIDocument    uidoc = app.ActiveUIDocument;
            Document      doc   = uidoc.Document;

            List <Element> floors = new List <Element>();

            if (!Util.GetSelectedElementsOrAll(
                    floors, uidoc, typeof(Floor)))
            {
                Selection sel = uidoc.Selection;
                message = (0 < sel.GetElementIds().Count)
          ? "Please select some floor elements."
          : "No floor elements found.";
                return(Result.Failed);
            }

            Options opt = app.Application.Create.NewGeometryOptions();

            List <List <XYZ> > polygons
                = CmdSlabBoundary.GetFloorBoundaryPolygons(
                      floors, opt);

            List <List <UV> > flat_polygons
                = Flatten(polygons);

            int i = 0, n = flat_polygons.Count;

            double[] areas = new double[n];
            double   a, maxArea = 0.0;

            foreach (List <UV> polygon in flat_polygons)
            {
                a = GetSignedPolygonArea(polygon);
                if (Math.Abs(maxArea) < Math.Abs(a))
                {
                    maxArea = a;
                }
                areas[i++] = a;
            }

            Debug.Print(
                "{0} boundary loop{1} found.",
                n, Util.PluralSuffix(n));

            for (i = 0; i < n; ++i)
            {
                Debug.Print(
                    "  Loop {0} area is {1} square feet{2}",
                    i,
                    Util.RealString(areas[i]),
                    (areas[i].Equals(maxArea)
            ? ", outer loop of largest floor slab"
            : ""));
            }

            using (Transaction t = new Transaction(doc))
            {
                t.Start("Draw Polygons");

                Creator creator = new Creator(doc);
                creator.DrawPolygons(polygons);

                t.Commit();
            }
            return(Result.Succeeded);
        }