BuildingCoder.CmdGetSketchElements.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;
              Selection sel = uidoc.Selection;

              Reference r = sel.PickObject( ObjectType.Element,
            "Please pick an element" );

              // 'Autodesk.Revit.DB.Reference.Element' is
              // obsolete: Property will be removed. Use
              // Document.GetElement(Reference) instead.
              //Element e = r.Element; // 2011

              Element e = doc.GetElement( r ); // 2012

              Transaction tx = new Transaction( doc );

              tx.Start( _caption );

              ICollection<ElementId> ids = doc.Delete( e.Id );

              tx.RollBack();

              bool showOnlySketchElements = true;

              /*
              StringBuilder s = new StringBuilder(
            _caption
            + " for host element "
            + Util.ElementDescription( e )
            + ": " );

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

            if( !showOnlySketchElements
              || e is Sketch
              || e is SketchPlane )
            {
              s.Append( Util.ElementDescription( e ) + ", " );
            }
              }
              */

              List<Element> a = new List<Element>(
            ids.Select( id => doc.GetElement( id ) ) );

              string s = _caption
            + " for host element "
            + Util.ElementDescription( e )
            + ": ";

              s += string.Join( ", ",
            a.Where( e2 => !showOnlySketchElements
              || e2 is Sketch
              || e2 is SketchPlane )
            .Select( e2 => Util.ElementDescription( e2 ) )
            .ToArray() );

              Util.InfoMsg( s );

              return Result.Succeeded;
        }
CmdGetSketchElements