BuildingCoder.CmdSlabSides.Execute C# (CSharp) Method

Execute() public method

public Execute ( ExternalCommandData commandData, string &message, ElementSet elements ) : System.Result
commandData ExternalCommandData
message string
elements ElementSet
return System.Result
        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;
              }

              List<Face> faces = new List<Face>();
              Options opt = app.Application.Create.NewGeometryOptions();

              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 )
              {
            GetSideFaces( faces, solid );
              }
            }
              }

              int n = faces.Count;

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

              using ( Transaction t = new Transaction( doc ) )
              {
            t.Start( "Draw Face Triangle Normals" );
            Creator creator = new Creator( doc );
            foreach ( Face f in faces )
            {
              creator.DrawFaceTriangleNormals( f );
            }
            t.Commit();
              }
              return Result.Succeeded;
        }