Create Centerline for a Entire Part

I very much appreciate for the Report Length Of Tube Feature code, it helps me a lot but I would like to extend its functionality.

The code helps build the centerline, however, it asks user to select each portion of the tube then create the centerline and do the length report. I, however, would like to have a code just loop through all the portion if the portion is tube, then do the centerline without actually asking the user for anything.

Sorry for asking too many questions

"Sorry for asking too many questions"

I don't actually see a question in the post above... :)

I don't have any code on hand that does exactly what you want. However, if I were faced with this problem, here is what I would try first:

If the part is parameterized, look for tube features and collect the defining curves into a list (or other collection). Calculate the bounding boxes of the housing solids of interest then look for center line curves that have an endpoint in the bounding box. If you are lucky, there will be one curve that connects both housings; otherwise, loop through the center line collection looking for one with an end point that matches the first line's endpoint (within a reasonable tolerance). Keep looping through the center lines until you find a path from one housing to the other; when you find a path, perform a length measurement on the curves that make up the path.

@ Journaling - I would like to address a few issues before going to final step.I would like to build the whole centerline (without knowning the length) with a single click instead of selecting each portion to get the centerline built. Probably, I am trying to look into the parts' feature if a feature is a tube, then apply the code that you posted.

If you are working with parameterized tube features, this journal will do what you want:
http://nxjournaling.com/content/report-length-tube-feature

It asks the user to select a tube feature, but this can be changed to simply look for tube features in the part file with no user interaction.