BuiltInFailures.RoomFailures when OpenDocumentFile Multiple Rooms error

BuiltInFailures.RoomFailures when OpenDocumentFile Multiple Rooms error

david_rock
Enthusiast Enthusiast
670 Views
2 Replies
Message 1 of 3

BuiltInFailures.RoomFailures when OpenDocumentFile Multiple Rooms error

david_rock
Enthusiast
Enthusiast

Hello,

 

I have a command that will open many models, process and close. However the command keeps stalling due to the following message.

 

"Multiple Rooms are in the same enclosed region.  The correct area and perimeter will be assigned to one Room and the others will display "Redundant Room."  You should separate the regions, delete the extra Rooms, or move them into different regions."

 

Is there a way to implement the FailuresPreprocessor when opening a model using OpenDocumentFile. As far as I'm aware, I cannot open a model while a transaction is open.

 

Kind Regards

David

 

0 Likes
Accepted solutions (1)
671 Views
2 Replies
Replies (2)
Message 2 of 3

RPTHOMAS108
Mentor
Mentor
Accepted solution

Below is an example of the FailureProcessing event:

 

I've added explanations of my approach in the comments

 

public class Class
{
	public static object IDontWantToHandleThisNow { get; set; }

	public void HandleFailures(object s, Autodesk.Revit.DB.Events.FailuresProcessingEventArgs e)
	{
		if (IDontWantToHandleThisNow == true)
			return;

		FailuresAccessor FA = e.GetFailuresAccessor;
		foreach (FailureMessageAccessor item in FA.GetFailureMessages) {
			FailureDefinitionId F_ID = item.GetFailureDefinitionId;
			if (F_ID == BuiltInFailures.RoomFailures.RoomsInSameRegion) {
				FA.DeleteWarning(item);
			}
		}
		//FA.DeleteAllWarnings() 'Might want to do this instead if you don't care what any of the ignorable messages are at this time
		//You may encounter lots of other messages not just this specific one. 
	}


	public void DoingSomthingWithMultipleFiles(Autodesk.Revit.UI.UIApplication UIApp)
	{
		IDontWantToHandleThisNow = false;
		//Or
		UIApp.Application.FailuresProcessing += HandleFailures;

		//UIApp.OpenAndActivateDocument(...)

		//It may be a better workflow to set this event up during application OnStartup and remove it during OnShutdown
		//Then have a static boolean variable as above that will by pass the event handler if you don't want to handle it.
		//The problem with adding and removing event handlers is that the code may fail inbetween leaving their current status ambiguous
		//Then when code runs again it may fail because handler already exists.


		//Should try to ensure that encountered errors don't prevent the below line occuring
		//(if you want to see the errors at some point in same session).

		IDontWantToHandleThisNow = true;
		//Or
		UIApp.Application.FailuresProcessing -= HandleFailures;
	}

}
0 Likes
Message 3 of 3

david_rock
Enthusiast
Enthusiast

Yes that solution worked well.

 

Thank you very much.

 

Kind Regards

David

0 Likes