BuildingCoder.CmdSteelStairBeams.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;
              Application app = uiapp.Application;
              Document doc = uidoc.Document;

              Transaction t = new Transaction( doc );

              t.Start( "Create Steel Stair Beams" );

              // Check whether the required family is loaded:

              FilteredElementCollector collector
            = new FilteredElementCollector( doc )
              .OfClass( typeof( Family ) );

              // If the family is not already loaded, do so:

              if( !collector.Any<Element>(
            e => e.Name.Equals( FamilyName ) ) )
              {
            FamilySymbol symbol;

            if( !doc.LoadFamilySymbol(
              _family_path, SymbolName, out symbol ) )
            {
              message = string.Format(
            "Unable to load '{0}' from '{1}'.",
            SymbolName, _family_path );

              t.RollBack();

              return Result.Failed;
            }
              }

              try
              {
            // Create a couple of connected beams:

            SteelStairs s = new SteelStairs( doc );

            s.Run();

            t.Commit();

            return Result.Succeeded;
              }
              catch( Exception ex )
              {
            message = ex.Message;

            t.RollBack();

            return Result.Failed;
              }
        }
CmdSteelStairBeams