CIrcular junction box Connector Location and selection

Greetings.
I have created a custom circular juntion box with four conectors. I would like to create a dynamo script that can select the connector closest to a cable tray or switch box on a wall then draw a conduit from the connector to the switch, should inlcude the bend. If possible you could help incoperate a script that will allow connection from one junction box to another by also selection of the closest connectors. I will highly appreciate your assistance.

image

The juntion box is as shown above.

Thanks
@christian.stan @Vikram_Subbaiah Kindly chip in if you can.