Hello guys,
I’m struggling with event handler in dynamo. I want to supress TaskDialog from postable command.
Could you help me with this?
import clr
import System
from System import EventHandler
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import RevitCommandId
import Autodesk
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
clr.AddReference("RevitAPIUI")
from Autodesk.Revit.UI.Events import DialogBoxShowingEventArgs
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
def confirm(sender, eventArgs):
return eventArgs.OverrideResult(TaskDialogResult.Ok)
bool = IN[0]
if bool == True:
CmndID = RevitCommandId.LookupCommandId('ID_PURGE_UNUSED')
#cmdMonitor = RevitCommandEndedMonitor(uiapp)
dialogEventHandler = EventHandler[DialogBoxShowingEventArgs](confirm)
uiapp.DialogBoxShowing += dialogEventHandler
uiapp.PostCommand(CmndID)
RevitCommandId.LookupPostableCommandId
uiapp.DialogBoxShowing -= dialogEventHandler
error = 'Success'
else:
error = 'Set IN[0] to true'
#Assign your output to the OUT variable
OUT = error