BuildingCoder.CmdListMarks.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 app = commandData.Application;
              UIDocument uidoc = app.ActiveUIDocument;
              Document doc = uidoc.Document;

              //Autodesk.Revit.Creation.Application creApp = app.Application.Create;
              //Autodesk.Revit.Creation.Document creDoc = doc.Create;

              FilteredElementCollector doors
            = Util.GetElementsOfType( doc,
              typeof( FamilyInstance ),
              BuiltInCategory.OST_Doors );

              int n = doors.Count();

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

              if( 0 < n )
              {
            Dictionary<string, List<Element>> marks
              = new Dictionary<string, List<Element>>();

            foreach( FamilyInstance door in doors )
            {
              string mark = door.get_Parameter(
            BuiltInParameter.ALL_MODEL_MARK )
            .AsString();

              if( !marks.ContainsKey( mark ) )
              {
            marks.Add( mark, new List<Element>() );
              }
              marks[mark].Add( door );
            }

            List<string> keys = new List<string>(
              marks.Keys );

            keys.Sort();

            n = keys.Count;

            Debug.Print( "{0} door mark{1} found{2}",
              n, Util.PluralSuffix( n ),
              Util.DotOrColon( n ) );

            foreach( string mark in keys )
            {
              n = marks[mark].Count;

              Debug.Print( "  {0}: {1} door{2}",
            mark, n, Util.PluralSuffix( n ) );
            }
              }

              n = 0; // count how many elements are modified

              if( _modify_existing_marks )
              {
            using( Transaction tx = new Transaction( doc ) )
            {
              tx.Start( "Modify Existing Door Marks" );

              //ElementSet els = uidoc.Selection.Elements; // 2014

              ICollection<ElementId> ids = uidoc.Selection
            .GetElementIds(); // 2015

              //foreach( Element e in els ) // 2014

              foreach( ElementId id in ids ) // 2015
              {
            Element e = doc.GetElement( id ); // 2015

            if( e is FamilyInstance
              && null != e.Category
              && (int) BuiltInCategory.OST_Doors
                == e.Category.Id.IntegerValue )
            {
              e.get_Parameter(
                BuiltInParameter.ALL_MODEL_MARK )
                .Set( _the_answer );

              ++n;
            }
              }
              tx.Commit();
            }
              }

              // return Succeeded only if we wish to commit
              // the transaction to modify the database:
              //
              //return 0 < n
              //  ? Result.Succeeded
              //  : Result.Failed;
              //
              // That was only useful before the introduction
              // of the manual and read-only transaction modes.

              return Result.Succeeded;
        }
CmdListMarks