Distance from point to segment

Hello everyone.
I have some problems when using the slicer.
In my project,I want to get the distance from the center of GTV to the lung boundary,which means the distance to the apex of lung in SI direction and the distance to the chest wall in LR,AP direction.
Now the problems is I can not markup the point I want.For example,in this image, I want get the two distances by scripts.
1668676163342

I checked all the slicer extension but no one can do that.So I wondeing if anyone can help me to solve it!
Thanks a lot!

You can get the intersection of a line (starting point is the center, endpoint is a point far away in the desired direction) and a mesh (obtained from the segment) and use IntersectWithLine method of a vtkModifiedBSPTree locator to get the intersection point.