Failure Handling Options Help (Warning Suppression)

I’m trying to suppress the errors that arise when you automatically publish coordinates, via transaction failure handling options.

Python Script...
import clr
from Autodesk.DesignScript.Geometry import *

# Import DocumentManager and TransactionManager
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# Import RevitAPI
from Autodesk.Revit.DB import *

# Import ToDSType(bool) extension method
import Revit
# Import ToProtoType, ToRevitType geometry conversion extension methods

# Import DSCore nodes in Dynamo
import DSCore
from DSCore import *

# Import python library
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
import os
import shutil
import math
# Import math library
from math import *

#Import Data and Time
from datetime import datetime
now =

#Import System Library
import System
from System.Collections.Generic import *
from System.IO import Directory, Path

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

#Preparing input from dynamo to revit
rvtLinkInstances = UnwrapElement(IN[0])
result = []
#Do some action in a Transaction

projSite = None
projLocName = None

ProLoc = UnwrapElement(IN[1])
orgin = XYZ(0, 0, 0)
projPos = ProLoc.get_ProjectPosition(orgin)
projLocName = ProLoc.Name
projPosEW = projPos.EastWest
projPosNS = projPos.NorthSouth
projPosEl = projPos.Elevation
projPosAngle = projPos.Angle
projSite = ProLoc.GetSiteLocation()
projSiteLat = projSite.Latitude
projSiteLong = projSite.Longitude
projSiteTimeZ = projSite.TimeZone

trigger = True
for rvtLinkInstance in rvtLinkInstances:
	linkdoc = rvtLinkInstance.GetLinkDocument()
	linkdocpath = linkdoc.PathName
	message = "Project Location of specific name already exist"
	message3 = "Project Location of specific name already exist"
	rvtlinktype = doc.GetElement(rvtLinkInstance.GetTypeId())
	newdoc = app.OpenDocumentFile(linkdocpath)
	currentLinkLocation = newdoc.ActiveProjectLocation
	Linklocations = newdoc.ProjectLocations
	for Linklocation in Linklocations:
		if Linklocation.Name == projLocName:
			trigger = False
		else: continue
	if trigger:
		t = Transaction(newdoc, "Create Project Location")
			newloc = currentLinkLocation.Duplicate(projLocName)
			newlocsite = newloc.GetSiteLocation()
			newlocsite.Latitude = projSiteLat
			newlocsite.Longitude = projSiteLong
			newlocsite.TimeZone = projSiteTimeZ
			#newloc = ProjectLocation.Create(newdoc, projSite.Id, projLocName)
			message = "Project Location successfully duplicated/created"
		except Exception as e: 
			message = "Could not create project location due to: " + str(e)
#Publish newloc 

for rvtLinkInstance in rvtLinkInstances:
	linkdoc = rvtLinkInstance.GetLinkDocument()
	message2 = "Project Location already Published"
	Linklocations = linkdoc.ProjectLocations
	for Linklocation in Linklocations:
		if Linklocation.Name == projLocName:
			t = Transaction(doc, "Publish Project Location")
			fho = FailureHandlingOptions.SetDelayedMiniWarnings(True)
				message2 = "Project Location successfully published"
			except Exception as e: 
				message2 = "Could not publish project location due to: " + str(e)
		else: continue	

#Final output
debug = False
#debug = True#Comment to turn off
if debug:
	OUT=['orgin: ', orgin, 'projPos: ' , projPos, 'projLocName: ', projLocName, 'projPosEW: ', projPosEW, 'projPosNS: ', projPosNS, 'projPosEl: ', projPosEl, 'projPosAngle: ', projPosAngle,'projSite: ', projSite, 'projSiteLat: ' , projSiteLat, 'projSiteLong: ' , projSiteLong, 'projSiteTimeZ: ', projSiteTimeZ, 'result: ', result]

	OUT = result

My issue is that I have no idea what the second argument for this method is, it isn’t listed on the SetDelayedMiniWarnings Method site.

Am I creating my FailureHandlingOptions object wrong? I am kinda confused on how this one works because there isn’t a constructor and I don’t know where to pull and existing one from.

Is there another way to automatically close this error dialog box?

Ok in retrospect that should have been pretty obvious,

However, even though I may have my failure handling working correctly my warning dialog box still shows :confused:

Modal Handling On

Modal Handling Off

Delayed Mini Warnings On

My best guess is that this dialog box is not controlled by failure handling because it is a warning, does anyone know how to suppress these?

I am still not sure how event handlers work in IronPython but this post may help you.

1 Like

This stuff is a little out of my league. I think I have found what is needed, however I have no idea how to execute it.

I believe that I need to create an event handler with my desired event (message box) arguments.

In the arguments, I would assign to override the result to IDOK or 1.

I tried to just assign the arguments earlier without an event handler, like this:


However I was given the error that I was only providing 1 of the 2 arguments required and I am assuming that the second argument is referring to the message box object. Bringing me to the DialogBoxShowing event.

Are there any examples of these UIAppplication Event handlers in python?

EDIT: I think I found one:

You can look into using that, but I think it might not actually work, for reasons outlined here. The example you’ve linked to looks like it’s meant to be run using PyRevit, but I don’t really have enough knowledge myself to say whether it will or won’t work.

Yeah I’m not really having much luck.

Is there really no common way to suppress these message dialog boxes in dynamo?

This is now a year-old topic but for the interested readers, this post has a sample code to tackle the issue of handling failures (with Warning level severity) in transactions:
Failure Handling With Dynamo-Python

1 Like