BuildingCoder.CmdRoomNeighbours.Execute C# (CSharp) Метод

Execute() публичный Метод

public Execute ( ExternalCommandData commandData, string &message, ElementSet elements ) : System.Result
commandData ExternalCommandData
message string
elements ElementSet
Результат System.Result
        public Result Execute( 
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
              UIDocument uidoc = uiapp.ActiveUIDocument;
              Document doc = uidoc.Document;

              // Interactively select elements of type Room,
              // either via pre-selection before launching the
              // command, or interactively via post-selection.

              JtSelectorMulti<Room> selector
            = new JtSelectorMulti<Room>(
              uidoc, BuiltInCategory.OST_Rooms, "room",
              e => e is Room );

              if( selector.IsEmpty )
              {
            return selector.ShowResult();
              }

              IList<Room> rooms = selector.Selected;

              List<string> msg = new List<string>();

              int n = rooms.Count;

              msg.Add( string.Format(
            "{0} room{1} selected{2}\r\n",
            n, Util.PluralSuffix( n ),
            Util.DotOrColon( n ) ) );

              SpatialElementBoundaryOptions opt
            = new SpatialElementBoundaryOptions();

              IList<IList<BoundarySegment>> loops;

              Room neighbour;
              int i = 0, j, k;

              foreach( Room room in rooms )
              {
            ++i;

            loops = room.GetBoundarySegments( opt );

            n = loops.Count;

            msg.Add( string.Format(
              "{0}. {1} has {2} loop{3}{4}",
              i, Util.ElementDescription( room ),
              n, Util.PluralSuffix( n ),
              Util.DotOrColon( n ) ) );

            j = 0;

            foreach( IList<BoundarySegment> loop in loops )
            {
              ++j;

              n = loop.Count;

              msg.Add( string.Format(
            "  {0}. Loop has {1} boundary segment{2}{3}",
            j, n, Util.PluralSuffix( n ),
            Util.DotOrColon( n ) ) );

              k = 0;

              foreach( BoundarySegment seg in loop )
              {
            ++k;

            neighbour = GetRoomNeighbourAt( seg, room );

            msg.Add( string.Format(
              "    {0}. Boundary segment has neighbour {1}",
              k,
              (null==neighbour
                ? "<nil>"
                : Util.ElementDescription( neighbour )) ) );
              }
            }
              }

              Util.InfoMsg2( "Room Neighbours",
            string.Join( "\n", msg.ToArray() ) );

              return Result.Succeeded;
        }