Announcements

Announcement: We’re aware of an issue affecting starting a new topic from category pages and creating new blog posts. New topics can still be started directly from the relevant board. Learn more here.

General warning swallower

General warning swallower

Anonymous
Not applicable
2,289 Views
5 Replies
Message 1 of 6

General warning swallower

Anonymous
Not applicable

In my solution I'm opening a lot of families from within a project. Sometimes some popups appear during opening a family. I enclosed the opening process inside a transaction in which I handle warnings via IFailuresPreprocessor. I noticed that:

 

about 90% warnings I can suppres with the following:

FailuresAccessor a;
a.DeleteAllWarnings();
return FailureProcessingResult.Continue;

But the remaining 10% won't get suppressed with such treatment, they do get suppressed with:

FailuresAccessor a;
IList<FailureMessageAccessor> failures = a.GetFailureMessages();
a.ResolveFailures(failures);
return FailureProcessingResult.ProceedWithCommit;

Is there a general way to check with what kind of treatment current warning can get suppressed? I don't want to go into a switch case block because the warnings are really various and it'd take ages before I covered them all. Another issue is that it doesn't matter so much how I treat the warnings because I don't resave the families in my solution - I just close them without saving.

 

0 Likes
2,290 Views
5 Replies
Replies (5)
Message 2 of 6

jeremytammik
Autodesk
Autodesk

Dear Adam,

 

Thank you for your cool query.

 

I am not aware of any generic warning swallower within the Revit API.

 

The solution you have already seems pretty good to me.

 

For something yet more generic, all I can suggest is a Windows dialogue handler:

 

http://thebuildingcoder.typepad.com/blog/2009/10/dismiss-dialogue-using-windows-api.html

 

https://github.com/jeremytammik/JtClicker

 

The Building Coder provides an entire topic group on the subject of Detecting and Handling Dialogues and Failures:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.32

 

Please let us know how you end up resolving this.

 

I am sure your solution will come in handy for others also.

 

Thank you!

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 6

Wolfgang.B.Weh
Enthusiast
Enthusiast
Message 4 of 6

jeremytammik
Autodesk
Autodesk

Cool. Since you say so, I added it to the topic group:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.32

 

Thank you!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 6

Anonymous
Not applicable

Thank you gents 🙂

 

Indeed the Severity is what I was looking for, my solution seems to be working fine now. The code below:

 

public FailureProcessingResult PreprocessFailures(FailuresAccessor a)
{
	IList<FailureMessageAccessor> failures = a.GetFailureMessages();
	
	foreach(FailureMessageAccessor f in failures)
	{
		FailureSeverity fseverity = a.GetSeverity();
		if(fseverity == FailureSeverity.Warning) a.DeleteWarning(f);
		else
		{
			a.ResolveFailure(f);
			return FailureProcessingResult.ProceedWithCommit;
		}
	}
	return FailureProcessingResult.Continue;
}

Kind regards,

 

Adam

Message 6 of 6

jeremytammik
Autodesk
Autodesk

Thank you very much, Adam and Wolfgang!

 

I summarised this thread here on The Building Coder:

 

http://thebuildingcoder.typepad.com/blog/2016/09/warning-swallower-and-roomedit3d-viewer-extension.h...

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes