BuildingCoder.CmdCurtainWallGeom.Execute C# (CSharp) Method

Execute() public method

public Execute ( ExternalCommandData commandData, string &message, ElementSet elements ) : Result
commandData ExternalCommandData
message string
elements ElementSet
return 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;

              Wall wall = Util.SelectSingleElementOfType(
            uidoc, typeof( Wall ), "a curtain wall", false )
            as Wall;

              if( null == wall )
              {
            message = "Please select a single "
              + "curtain wall element.";

            return Result.Failed;
              }
              else
              {
            LocationCurve locationcurve
              = wall.Location as LocationCurve;

            Curve curve = locationcurve.Curve;

            // move whole geometry over by length of wall:

            XYZ p = curve.GetEndPoint( 0 );
            XYZ q = curve.GetEndPoint( 1 );
            XYZ v = q - p;

            Transform tv = Transform.CreateTranslation( v );

            //curve = curve.get_Transformed( tv ); // 2013
            curve = curve.CreateTransformed( tv ); // 2014

            Creator creator = new Creator( doc );
            creator.CreateModelCurve( curve );

            Options opt = app.Create.NewGeometryOptions();
            opt.IncludeNonVisibleObjects = true;

            GeometryElement e = wall.get_Geometry( opt );

            using ( Transaction t = new Transaction( doc ) )
            {
              t.Start( "Create Model Curves" );

              foreach ( GeometryObject obj in e )
              {
            curve = obj as Curve;

            if ( null != curve )
            {
              //curve = curve.get_Transformed( tv ); // 2013
              curve = curve.CreateTransformed( tv ); // 2014
              creator.CreateModelCurve( curve );
            }
              }
              t.Commit();
            }
            return Result.Succeeded;
              }
        }
CmdCurtainWallGeom