BuildingCoder.CmdWindowHandle.Execute2 C# (CSharp) Метод

Execute2() публичный Метод

Modified version with changes to use WindowSelect, by Tao (Tau) Yang, Autodesk.
public Execute2 ( ExternalCommandData commandData, string &message, ElementSet elements ) : System.Result
commandData ExternalCommandData
message string
elements ElementSet
Результат System.Result
        public Result Execute2(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            if( null == _hWndRevit )
              {
            Process process
              = Process.GetCurrentProcess();

            IntPtr h = process.MainWindowHandle;
            _hWndRevit = new WindowHandle( h );
              }

              UIApplication app = commandData.Application;
              UIDocument uidoc = app.ActiveUIDocument;
              Document doc = uidoc.Document;

              Selection sel = uidoc.Selection;

              using( CmdWindowHandleForm f
            = new CmdWindowHandleForm() )
              {
            f.Show( _hWndRevit );
            bool go = true;
            while( go )
            {

            #if _2010
              sel.StatusbarTip = _prompt;
              go = sel.WindowSelect();
            #endif // _2010

              IList<Element> a = sel.PickElementsByRectangle( _prompt );
              go = 0 < a.Count;

              //SelElementSet ss = sel.Elements; // 2014
              //int n = ss.Size;
              ICollection<ElementId> ids = sel.GetElementIds(); // 2015
              int n = ids.Count;

              string s = string.Format(
            "{0} element{1} selected{2}",
            n, Util.PluralSuffix( n ),
            ( ( 0 == n )
              ? ";\n" + _prompt
              : ":" ) );

              //foreach( Element e in ss )
              foreach( ElementId id in ids )
              {
            s += "\n";
            s += Util.ElementDescription(
              doc.GetElement( id ) );
              }
              f.LabelText = s;
              Debug.Print( "go = " + go.ToString() );
            }
              }
              return Result.Failed;
        }
CmdWindowHandle