A script to measure a total length of selected objects (boxes)

Hi folks,
I often have to assemble objects, such as carts, from a profiled pipe. And then the customer asks to calculate the length of all the segments. I thought that if all the parts differ from each other only in length, why not come up with a script that can immediately calculate the length of all such segments? Each segment has a long side. You can determine the length of this side for each selected object and sum them up. And considering that you often have to make changes, then after each change you need to recalculate everything again. Such a script would be useful to anyone who works with materials that are cut - wooden bars, pipes, etc. Can any of the experts in writing scripts help to write such a useful script?

Try this definition.
mesure.gh (35.0 KB)


Hey everyone! Finally, a tool has appeared that allows designers like me, who know nothing about programming, to solve these kinds of problems on their own. Of course, I’m talking about ChatGPT, which generated code that solved the problem described above in just a minute. Long live OpenAI! Below is a working script, in case anyone needs it. In addition to calculations, it automatically creates and populates an Excel spreadsheet.
PS. Tested on Rhino5 x64 (works like a charm!)

MeasureSimilarExtrusions.rvb (4.8 KB)