Sci-Fi, Languages and Pipe Insulation Retrieval

Three quick notes from my recent email correspondence and reading:

Pipe Insulation Retrieval Performance

Alexander @aignatovich @CADBIMDeveloper Ignatovich, aka Александр Игнатович, shares an interesting observation on a performance issue retrieving MEP pipe insulation elements using GetDependentElements:

Recently, I faced with a performance issue getting pipe insulation. My previous implementation looked like this:

  var pipeInsulation = pipe
    .GetDependentElements( new ElementClassFilter( 
      typeof( PipeInsulation ) ) )
    .Select( pipe.Document.GetElement )

I didn't notice it before because I tested the code on a small model.

However, in the big model, the entire calculation took over an hour. Calculations were also huge, so I spent some time trying to figure out what is going wrong.

The improved solution looks like this:

  var pipeInsulation = InsulationLiningBase
    .GetInsulationIds( pipe.Document, pipe.Id )
    .Select( pipe.Document.GetElement )

With that, the entire calculations take seconds instead of hours.

This issue is related only to MEP; I haven't faced any other performance issues using the GetDependentElements method.

Thank you very much for the interesting observation, Alex!

Programming Languages to Learn

A frequent question is which programming language to learn to implement Revit add-ins. Here it comes up again, with an F# twist:

Question: We are now starting our in-house computational strategy in order to automate processes on both Revit-Dynamo and Inventor-iLogic and I am struggling to decide which language code we should start to learn. C#, Python or F#? I am takin my first steps into coding, but I have a few years of experience on Dynamo & Grasshopper. I would also like to add that our Inventor application has an automation interface developed by a consultant company written in F# that we would like to take control over in the long term. Long story short: I would like to understand the pro and cons of which of these three languages should we start to learn to better unify a future workflow between Revit and Inventor, keeping in mind that we have something in-house already developed in F#.

Answer: Since the Revit API is completely .NET based and all .NET languages are completely interoperable, it really does not matter much at all which one you learn and use. Any one of them can be used to interact fully with any other.

Furthermore, all .NET languages compile to the same underlying IL or intermediate language. From IL, you can decompile back into any other .NET language, making it easy to switch back and forth between languages and even transform your code base from one to another.

Therefore, obviously, you need not really worry about learning F# at all, if you are not interested in procedural programming yourself.

In short, I would say:

Here are some other thoughts on this topic:

Agency by William Gibson

I just finished reading Agency by William Gibson, a brilliant sci-fi including a critical look at politics and its rather helpless and fruitless attempts to control climate change, big business, the current pandemic, probably AI, soon, and other interesting challenges. It includes an original new (for me, anyway) idea on time travel and its impossibility. It treats the possibility of benevolent and humane AI with a lot of optimism, which I agree with. Gibson is a true visionary. He also coins (?) the term CCA, competitive control area, a territory where it is unclear who holds the power: government, warlords, multinational companies, criminal organisations... one wonders whether that might be an accurate and critical way of viewing our current real world right now...

William Gibson Agency

Addendum – Jackpot

Wow! Good news!

I just discovered that Agency is part two of the Jackpot trilogy.

So, next thing I do is order part one, The Peripheral.