Convex Outer Loop, Non-Migration and 15-Year Stint

Various noteworthy items this week, both Revit API related and not:

My Second Stint of 15 Years at Autodesk

I just completed my second 15-year stint of work at Autodesk, joining May 1. 2005.

The first one was for six years, from 1988 to 1994.

By the way, The Building Coder is now in its twelfth year...

To my great surprise, I was seriously congratulated on this milestone:

Wow, I am overwhelmed!

I thought this was no big deal.

Slowly and gradually the flood of congratulations made me realise otherwise...

Thank you very much, everybody, for your many kind words and great support!

I love working with this team!

Forge Trainee Career Launched

Philipp Mueller, Project and Program Manager dealing with Universities and Education, pointed out another happy Forge story:

TU Darmstadt was one of the first Universities in Germany working with Forge. Thanks to the support of Peter Schlipf and Cyrille Fauvel, Jeremy Tammik hosted a hands-on Forge Workshop for Construction Computing Students back in 2016.

Just recently, the PhD student who helped to host the workshop graduated and immediately landed a job at NA Max Bögl as Program Leader for Lean Construction. A major element factor in achieving this was his Phd Thesis a Contribution for the Digital Transformation of Lean Construction leaning strongly on Autodesk Forge and Dynamo. The thesis is in German; here is an English Excerpt:

In the construction industry there, is a high demand and considerable potential for transforming current ways of thinking and working in order to improve cooperation in projects, increase productivity and added value and compensate for decreasing manpower. One prerequisite for this is a transformation towards holistic, process-oriented and digital value chains based on an open-minded, collaborative mentality of all participants. The Building Information Modelling (BIM) methodology and Lean Construction (LC) are two approaches that can facilitate this. In this context, the Work Cycle based approach is examined regarding possibilities for its digital implementation – in particular, by applying and integrating the BIM methodology. For this purpose, scientific work and software solutions used in practice are analysed. Based on this, a concept of a software system is presented that comprises a holistic approach for the digital transformation of Work Cycle Based Time Planning and Control. The software concept consists of a visual programming based application for planning as well as a modular, web-based application based on the central control tool, Work Cycle Control Panels. Underlying these two software applications, the use of a central database and a digital LC model also introduced in this paper ensures a continuous data flow. Finally, demonstration applications are implemented to demonstrate the realisation of a software implementation with usage examples.

Why Does My Add-In Still Run?

Michel Alofs provided a detailed explanation about how the Revit API updates handle the steps of signalling deprecated code and removing it a year later after it has become obsolete, raised in the Revit API discussion forum thread on updating plugins to Revit 2021:

Question: I'm trying to update a Revit plugin for Revit 2021.

The code of the plugin was designed for Revit 2019, but it also works in Revit 2020.

I Followed the guide on how to maintain Revit plug-ins for multiple versions and it works for Revit 2021 too.

I've seen that the Revit 2021 API had several changes, one of then regarding the UnitUtils.ConvertFromInternalUnits method. Now it uses a ForgeUnitID instead of a DisplayUnitType enum member.

My question is: Why does the code that's been originally written in the 2019 version works seamlessly in Revit 2021?

Answer: Good question.

The answer is simple: the methods provided by the Revit API assemblies to serve the Revit API calls made by your add-in remain unchanged.

New methods have been added, for instance, the new unit API ones that you mention. However, you are not using them, so that makes no difference for your add-in.

Other methods may have been changed or even removed. However, luckily for you, you have not been using them, so that makes no difference for your add-in.

In the code for R2019, you haven't used any of the removed 'obsolete' code in R2020/R2021.

For instance, the rules for filters changed in R2019 and the old style was removed in R2020.

So, if you had used a command with these methods, the add-in wouldn't run or crash (attempting to use the same assembly for R2020/R2021); also, the .NET Framework version could be an issue.

See the post on What's New in the Revit 2020 API.

Response: I actually have used a lot of methods that have been replaced in the 2021 version of the Revit API.

I use some of the methods of the UnitUtils class... some of them were replaced.

When Visual Studio compiles my code, does it adapt, or recognize the old methods and somehow translate them to the new ones?

That's the only thing I can think of.

Answer: UnitUtils hasn't been removed in R2021, it will be gone in R2022 (if it follows the same route as always).

See Obsolete API removal.

Only the Autodesk.Revit.DB.ImageImportOptions and methods relating to it have now been removed (and would return an error).

Once a function is replaced or obsolete (deprecated), it will be removed in the next Revit version.

For instance, ParameterFilterElement.GetRules is marked as deprecated in the Revit 2019 API and was removed completely in Revit 2020.

That gives you one year's time to update your code to remove all dependencies on deprecated API.

Ensure that your add-in compiles with zero warnings, and you will be ready to compile it for the next major release of Revit as well.

If your code generates warnings about using deprecated code now, it will no longer run unmodified in the next major release of Revit.

Many thanks to Michel for the detailed explanation!

To summarise and point out the gist of this:

This procedure gives you one year's time to update your code to remove all dependencies on deprecated API.

Ensure that your add-in compiles with zero warnings, and you will be ready to compile it for the next major release of Revit as well.

If your code generates warnings about using deprecated code now, it will no longer run unmodified in the next major release of Revit.

Determine Outer Loop Around Points

I had a nice discussion with Francisco Contreras on determine an outer loop around given points in a series of comments on the article on disjunct planar face outer loops:

Question: I have a List<xyz> with elements that always are circumscribed to a quad.

I need to get the outer loop of it and store it like a face.

I know you cannot create faces, but the outer loop is good enough; I created a class that store it.

Do you know how can I do it?

Outer loop around points

Answer: This is either very simple or just plain simple.

The very simple solution is to determine the concave hull of your points.

The less simple task would be to retrieve the (non-concave, convex) outer loop.

Very much less simple, actually.

What IS the outer loop unless you have a convex hull?

Take another look at your points:

Outer loop around points

Is the outer loop A-B-C-E-G-H?

Why is it not A-B-C-D-E-G-H?

Or A-B-C-D-E-F-G-H?

Or A-B-C-E-G-H-F-D-A?

I recommend you just go for the convex hull, e.g., with this algorithm.

Oh, I see now that you mention it is a quad... so it is convex in any case.

Problem solved.

Response: Many thanks for your help, I´m trying to implement it.

Question, this should work for any set of points on a given plane?

Or, should I change something if the plane is vertical or horizontal?

Because the code Written by Maxence is giving me an infinite loop, the program does not go beyond the third point.

Answer: For a 2D convex hull computation, you would normally expect to be working with 2D points.

If your points are in a horizontal plane, discard all Z coordinates.

In a vertical plane aligned with the X axis, discard Y; aligned with Y axis, discard X. Else rotate the coordinates appropriately.

In a slanted plane, transform your coordinates into the XY plane.

I implemented a 2D convex hull calculation in The Building Coder samples.

I implemented transformation of 3D points into a 2D plane in order to make use of the 2D polygon area calculation for 3D planar polygons.