Catch errors

Catch errors

Anonymous
Not applicable
574 Views
4 Replies
Message 1 of 5

Catch errors

Anonymous
Not applicable

Hi there,

 

I'm trying to switch a profile in a sweep. When the profile is not correctly drawn (like none closed loop or overlapping lines) Revit will throw a messagebox telling the sweep can't be made, with the options Delete or Cancel.

 

I receive this message when I am doing a transaction.Commit. I have put a try catch around it, but it never comes in the catch.

 

Does anybody know how you can intercept this error message of revit so I can do a transaction.rollback in case of an incorrectly drawn profile.

 

Kind regards,

 

0 Likes
575 Views
4 Replies
Replies (4)
Message 2 of 5

Revitalizer
Advisor
Advisor

Hi Remy,

 

what about your Transaction's FailureHandlingOptions ?

 

You could implement a IFailuresPreprocessor.

This would give you access to single FailureMessageAccessor objects, which give you more detailed information about what's happened and why.

 

The IFailuresPreprocessor returns a FailureProcessingResult, so you can rollback your transaction by returning FailureProcessingResult.ProceedWithRollBack.

 

 

 

Best regards,

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 3 of 5

Anonymous
Not applicable
Why not verify for yourself that the profile is correct before using it?

A few of the Revit classes even provide a validity checking method (view
crop region does I think). If you can't find a built-in method, it is not
too difficult to perform the check yourself by looping through and checking
that each end point is within Revit's geometric tolerance (1×10^-9) of
exactly one other end point.

It is then also a good idea to check that the loopd doesn't self intersect.
Which is a little trickier, but if the loops provided are mostly correct
with just the occaisonal gap then you could probably skip this.
Message 4 of 5

Anonymous
Not applicable
Thank you both for your suggestions. I will try the FailureHanlding method first, because at this time it is enough for me to catch the fact the profile is incorrect. I will let you know the result 🙂
0 Likes
Message 5 of 5

jeremytammik
Autodesk
Autodesk

Hi guys,

 

Thank you for the helpful suggestions.

 

One possibility to validate curve loops is provided by the ExporterIFCUtils.ValidateCurveLoops method.

 

I used it once in the RoomEditorApp:

 

http://thebuildingcoder.typepad.com/blog/2013/04/extrusion-analyser-and-plan-view-boundaries.html#4

 

Here is the code, although currently commented out:

 

https://github.com/jeremytammik/RoomEditorApp/blob/master/RoomEditorApp/CmdUploadRooms.cs

 

Cheers,

 

Jeremy



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

0 Likes