you working backward... don't look at some code and say how can i use this? define the logic you want first then say: what is the code to get this?
the script you're doing is big. if you don't use a smart logic it will be a mess.
I guess you already have the output of your script: create file with proper information / format from CATIA to other tubing app.
now define the input: will it be a product of part with dumb solid, solid from tubing workbench, just tubing run, user created tube geometry... define what is in scope what is not.
then process with logic from geometry to get the info then from info to output format. The logic to extract the info will be different from one input (tubing run) to another (user created geometry). Try to have the least interaction with the user, make the application smart : why would you ask the user to select a solid if there is only one in the file? (the logic definition would help you define smart opportunities).
for your standard parts I would search for edges in the solid then keep only circle one and get circle center, from that you can also get the normal direction if you need.
for the tube, if you use the tubing workbench and have the run, you should be able to get the points (and bend radius) from the run. If you don't have the run but used the tubing workbench you should be able to identify the sketch that define the tube center line and then get info from vertices or edges regarding the info you need.
When a code is playing with selection is might be wise to prevent user from interacting... pop up a modal form that eventually inform the user about the process evolution : found tube name xxx, processing points, found standard part name yyy, processing points... this could also help you !
Eric N.
indocti discant et ament meminisse periti