get failure type

get failure type

Joris.vd.Meulen
Collaborator Collaborator
937 Views
4 Replies
Message 1 of 5

get failure type

Joris.vd.Meulen
Collaborator
Collaborator

Hi guys,

 

What I want:

if Revit throws a failure to catch that failure and return what kind of failure that is (so I can delete the warning accordingly)

 

 

Example:

I set a Mark to two elements. Revit throws 'Elements have duplicate "Mark" values'.

I want to know what api failure that corresponds to.

 

The answer in this case is: 
BuiltInFailures.GeneralFailures.DuplicateValue

 

But I often struggle which failure I need. So I would like to get "BuiltInFailures.GeneralFailures.DuplicateValue"  as string. Is this possible?

 

love python coding
0 Likes
938 Views
4 Replies
Replies (4)
Message 2 of 5

jeremytammik
Autodesk
Autodesk

It seems to me that the LabelUtils class would be the appropriate place to provide this functionality:

 

https://www.revitapidocs.com/2020/8cdbbb5c-a21e-ad1d-e9a3-6535f5d27894.htm

 

I don't see it there, though.

 

I have asked the development team for advice for you.

 



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

0 Likes
Message 3 of 5

Joris.vd.Meulen
Collaborator
Collaborator

Much appreciated Jeremy.

love python coding
0 Likes
Message 4 of 5

jeremytammik
Autodesk
Autodesk

We don't have precisely what you are asking for. `LabelUtils` are generally for looking up the text that matches an enumerated type. For Failure Definitions, this can be accomplished by `FailureDefinitionRegistry.FindFailureDefinition(id)` and `FailureDefinition.GetDescriptionText()`.

 

However, it sounds like you want to look up the text to find the id. As said, we don't have this, precisely. Furthermore, in your example, the text includes substituted text, so it would be hard to do.

 

Instead, you could subscribe to the `FailuresProcessing` event, log both the ids and text coming from that, write a routine to search the existing `FailureDefinitionId` values, and compare with the `Id` received from the event.

 

In fact, this might be a useful utility for us to offer built-in, so please file a request for this in the Revit Idea Station.

 

Thank you!

 



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

Message 5 of 5

Joris.vd.Meulen
Collaborator
Collaborator

consider that done.

love python coding
0 Likes