BuildingCoder.CmdSlopedWall.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;

              Autodesk.Revit.Creation.Application ac
            = app.Application.Create;

              //CurveArray profile = ac.NewCurveArray(); // 2012
              List<Curve> profile = new List<Curve>( 4 ); // 2012

              double length = 10;
              double heightStart = 5;
              double heightEnd = 8;

              XYZ p = XYZ.Zero;
              XYZ q = ac.NewXYZ( length, 0.0, 0.0 );

              //profile.Append( ac.NewLineBound( p, q ) ); // 2012
              profile.Add( Line.CreateBound( p, q ) ); // 2014

              p = q;
              q += heightEnd * XYZ.BasisZ;

              //profile.Append( ac.NewLineBound( p, q ) ); // 2012
              profile.Add( Line.CreateBound( p, q ) ); // 2014

              p = q;
              q = ac.NewXYZ( 0.0, 0.0, heightStart );

              //profile.Append( ac.NewLineBound( p, q ) ); // 2012
              //profile.Add( ac.NewLineBound( p, q ) ); // 2013
              profile.Add( Line.CreateBound( p, q ) ); // 2014

              p = q;
              q = XYZ.Zero;

              //profile.Append( ac.NewLineBound( p, q ) ); // 2012
              //profile.Add( ac.NewLineBound( p, q ) ); // 2013
              profile.Add( Line.CreateBound( p, q ) ); // 2014

              Document doc = app.ActiveUIDocument.Document;

              using ( Transaction t = new Transaction( doc ) )
              {
            t.Start( "Create Sloped Wall" );

            //Wall wall = doc.Create.NewWall( profile, false ); // 2012
            Wall wall = Wall.Create( doc, profile, false ); // 2013

            t.Commit();
              }
              return Result.Succeeded;
        }
CmdSlopedWall