Run() 공개 메소드

public Run ( ) : void
리턴 void
        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;
              }
        }
예제 #2
0
        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);
            }
        }