Extract cross-section center line of a block instance object

I want to extract the cross-section center line of the objects (block instances) given in the attached sample file. The actual file has many such objects with different lengths. Is there a way to extract the center lines using Grasshopper?

Test file.3dm (191.7 KB)

If the cross-section center line you’re talking about is this, you can use Bounding Box. Elefront plugin is required.

Get CenterLines Fr Block_re.gh (8.9 KB)

Thanks for your quick response with the Grasshopper script!
Is it possible to select all the block instances at once and extract their names?
And there are some objects which are kinked. How can I modify your script to make it work for both straight and kinked objects? The attached file includes an example of a typical kinked object.

Test file 1.3dm (124.4 KB)

Use the latest version of Elefront(4.11). And your blocks are made up of small pieces of mesh, so it’s hard to get a centerline unless you have a simple configuration.
You’ll have to work separately for the bented objects.

Get CenterLines Fr Block_reV3.gh (9.6 KB)

Thank you very much for providing the updated script!
I’ll work separately for the bent objects.