Handling ExtrusionAnalyzer Failures

The desk solids are processed perfectly well by the extrusion analyser, but two of the chair solids produce failures.
This is the standard Revit content 'Furniture Chair - Office' returning invalid solids.

Since I don't (yet?) know how to detect beforehand whether a solid will cause a failure or not, the only option I see is to encapsulate the extrusion analyser implementation in an exception handler.
I also added code to report how many failures occur:

Testing the ExporterIFCUtils ValidateCurveLoops Method

Rudolf Honke added a very valid
suggestion to
my
SortCurvesContiguous implementation: You may have a look at ExporterIFCUtils.ValidateCurveLoops method. RevitApi.chm says:
"Does validity checks on a list of curve loops to ensure that they are all co-planar, closed, and properly oriented."
I have never tested this method, but perhaps it prevents you from inventing the wheel another time...

I like that suggestion a lot and am interested to find out how useful this method might be.

It takes a list of curve loops and returns a new list of curve loops "properly oriented, if possible. If not, the return contains no loops."

I added code to test this method, passing in to it the output produced by the extrusion analyser:

Unfortunately, the CurveLoop Append method throws an exception saying "This curve will make the loop not contiguous. Parameter name: pCurve".

It obviously expects contiguous curves to be passed in and can therefore not be used to re-orient curves if they are oriented the wrong way.

So much for that suggestion.
You got my hopes up there, Rudolf, but no luck this time.

First Conclusion and Capitulation

My first (erroneous) conclusion for the extrusion analyser was simple: the output I receive for a plan view is much too complex for my use.

I was expecting it to return the simplest possible contour to represent the shadow cast by the solid passed in.
The results include lots of extraneous loops that do not contribute to the shadow of the object.

Oops.

Since I am passing in the multiple solids from the desk and the chair to the extrusion analyser one by one, individually, it is obviously returning a plan view boundary outline for each one of the solids, individually, as well.

At first glance I thought that this result is much too complicated for me to handle, since all I want is one single boundary for the whole object.

For a moment, I gave up on the whole idea of using the extrusion analyser and decided to switch to a 2D plan view instead, and ask for the view-specific family instance representation in that view. For the desk, that would simply give me the desired rectangular outline.

Capitulation.

Then I switched on my brain for a second again and realised the obvious fact that individual solids will generate individual outlines.

I decided to give the extrusion analyser another go, unite all the solids into one single one, then pass that in to a single call of the extrusion analyser.

Reimplementation with a Boolean Union

'Gesagt, getan', as the Germans say, 'No sooner said than done', 'a word and a blow'.

I united all the desk solids, passed the resulting union in to the extrusion analyser, and it produces a single closed loop.

I united all the chair solids, passed the resulting union in to the extrusion analyser, and it produces one single failure.

Oh no!

The individual chair solids causing a failure when passed in individually also cause a failure when united with the unproblematic ones.

Next idea:

Extract the family instance solids from the geometry one by one.

Test each solid by passing it in to the extrusion analyser on its own.

If it causes a failure, discard it.

If it does not, unite it with the others.

Pass in the union of all non-failing solids to the extrusion analyser.

The chairs have arcs in them, so maybe they have to be as complex as they appear.

The desk should actually be just one single simple rectangle, so maybe there is a possibility to clean up its loop, e.g. reduce the 12 vertices to just four, e.g. by identifying collinear segments or something.

I'll look at that in more detail anon.

As you can see, this is all very experimental work in progress.

I hope you can get some use out of it anyway, and am excited to see where this will lead me.

Conclusion, Next Steps and Download

It works so far, and I will still have hope of using this for my final project implementation.

The next step is to test the validity of the loops I retrieve.
As said, the end goal is:

Alternatively, I could first implement a visualisation tool in .NET for local use and testing.
I have had that on my list for a long time anyway.

Anyway, here is
GetFurnitureLoops.zip containing
the complete source code, Visual Studio solution and add-in manifest of the current state of this external command.

New Revit Add-ins

Before closing, here are some new Revit add-ins pointed out by developers that have been active here on the blog:

Israel Rodriguez of icubY released his
mYbox add-in
providing an easy way to integrate families that are on our portal directly inside Revit, AutoCAD and SketchUp, and includes a WPF client using the Revit API to instantiate the families
(video).
The content is mainly in Brazilian Portuguese.

Fernando Malard of
ofcdesk
points out his
ofctools,
providing advanced maintenance commands to optimise and streamline work, e.g. creating, editing or deleting large numbers of elements.