Distance Between Line and Point

I’m attempting to automate a certain measurement, but I can’t seem to find the right tools in 3-Matic. I have to find the shortest distance between a line a completely different point. I couldn’t find anything similar to this while checking the 3-Matic and Mimics scripting guides. Is there a good way I can accomplish this measurement with scripting?

Thank you in advance for your assistance,

Here’s the solution I scripted for anyone that’s interested:

The code:

Where (x1,y1,z1) is the point you’re measuring from, (x2,y2,z2) and (x3,y3,z3) are points anywhere along the line you’re measuring.

The equation for finding the distance between a point and a line in 3D space that the code is based on:
For the derivation, go to Wolfram Alpha: Point-Line Distance--3-Dimensional -- from Wolfram MathWorld

Thank you for your time,