Message 1 of 10
Abort Pickobject()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
Is there a way to abort pickobject() other than the user press ESC.
I am using Pickobject() in a loop in an External Form :
while (!user_pressed_stop)
{
Selection sel = revit.Application.ActiveUIDocument.Selection;
ElementPickFilter myfilter = new ElementPickFilter();
Reference pickedRef = null;
pickedRef = sel.PickObject(ObjectType.Element, myfilter, "Please select an Element");
Element elem =document.GetElement(pickedRef);
listelement.Add(elem);
}
I need to stop the "pick object" from waiting the user input when he clicks the stop button,
I even tried to make work around by sending ESC Key to Revit but it doesnot work properly Every time
private void buttonstop_Click(object sender, EventArgs e)
{
static WindowHandle _hWndRevit = null;
IntPtr ptr;
Process[] processes = Process.GetProcessesByName("Revit");
if (0 < processes.Length)
{
ptr = processes[0].MainWindowHandle;
_hWndRevit = new WindowHandle(ptr);
}
SetForegroundWindow(ptr);
SendKeys.SendWait("{ESC}");
}Any Proper way to cancel that Function?
Regards,
Basiony