FailureResolutionType.DeleteElements is not working

FailureResolutionType.DeleteElements is not working

Anonymous
Not applicable
985 Views
6 Replies
Message 1 of 7

FailureResolutionType.DeleteElements is not working

Anonymous
Not applicable

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

Error-cannot be ignored.

Cannot form radial dimenshion.

I can continue to open the file by clisking the button of Delete Dimension(s).

Bug I want the program to handle this error automatically,so I  write the following codes.

 

Autodesk.Revit.ApplicationServices.Application app = commandData.Application.Application;
app.FailuresProcessing += HandleFailures;

public void HandleFailures(object s, Autodesk.Revit.DB.Events.FailuresProcessingEventArgs e)
{
FailuresAccessor failuresAccessor = e.GetFailuresAccessor();
failuresAccessor.DeleteAllWarnings();
var failures = failuresAccessor.GetFailureMessages();//获取所有的失败信息
foreach (var failure in failures)
{
if (failure.GetSeverity() == FailureSeverity.Error)//获得的是失败信息
{
string content = failure.GetDescriptionText();
if (content.Contains("Cannot form radial dimension"))
{
failure.SetCurrentResolutionType(FailureResolutionType.DeleteElements);
failuresAccessor.ResolveFailure(failure);
}
else
{
failuresAccessor.ResolveFailure(failure);
}
}
}
}

 

When I run the program, it catches the error and debugs normally.

But this window still appears.

What should I do to avoid this window?

0 Likes
Accepted solutions (1)
986 Views
6 Replies
Replies (6)
Message 2 of 7

jeremy_tammik
Alumni
Alumni

If you are certain that you want to suppress and ignore all warnings of all kinds, you could try using this warning swallower:

  

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

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 7

Anonymous
Not applicable

I think that I've done it, but it doesn't make any difference.

There is a Error instead of Warning,so I writer following code.

 

failure.SetCurrentResolutionType(FailureResolutionType.DeleteElements);

failuresAccessor.ResolveFailure(failure);

 

But this window still appears.

I've tried this method ,and it doesn't work.

 

  foreach( FailureMessageAccessor f in failures )  

 {  

   FailureSeverity fseverity = a.GetSeverity();   

  if( fseverity == FailureSeverity.Warning )     {       a.DeleteWarning( f );     }    

 else     {       a.ResolveFailure( f );       } 

}

0 Likes
Message 4 of 7

jeremy_tammik
Alumni
Alumni

If all else fails, as a last resort, you can dismiss the dialogue with the native Windows API:

 

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

 

Look at the first article in the list.

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 5 of 7

Sean_Page
Collaborator
Collaborator
Accepted solution

Make sure your setting the processor handling result.

 

 

e.SetProcessingResult(FailureProcessingResult.ProceedWithCommit)

 

And that is on the eventargs "e".

 

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
0 Likes
Message 6 of 7

Sean_Page
Collaborator
Collaborator

I also might suggest using the DefinitionId and resolution types rather than searching the content string.

 

 

//This is when you know the resolution and don't care what the error is
if(fas.IsFailureResolutionPermitted(fa, FailureResolutionType.DeleteElements))
{
fa.SetCurrentResolutionType(FailureResolutionType.DeleteElements);			fas.ResolveFailure(fa);
}
//This is when you want to check for a specific error and just resolve using the default resolution
if(fa.GetFailureDefinitionId() == BuiltInFailures.FamilyFailures.FamilyIsCorruptError)
{
fas.ResolveFailure(fa);
}

 

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
0 Likes
Message 7 of 7

Anonymous
Not applicable

Thank you very much and I'll take your advice.

0 Likes