I want user to select a pipe from the UI , by clicking a button. Following code I am using to achieve this task. But I am able to select pipe only after closing the UI window. I want the user to select the pipe while my UI window is active.
class CustomISelectionFilter(ISelectionFilter):
def __init__(self, category_name):
self.category_name = category_name
def AllowElement(self, e):
if e.Category.Name == self.category_name:
return True
else:
return False
def AllowReference(self, ref, point):
return true
class MyWindow(Windows.Window):
def __init__(self):
wpf.LoadComponent(self,xamlfile) #self is the instance of the class and we are loading xaml file into that instance
def btn_Click_SelectPipe(self,sender,args):
try:
ductsel = uidoc.Selection.PickObject(ObjectType.Element,CustomISelectionFilter("Pipes"),"Select a Pipe")
except Exceptions.OperationCanceledException:
TaskDialog.Show("Operation canceled","Canceled by the user")
Here is my UI