I came across this post by TNT in a search. using the distanceBetween node I'm about to try it this morning I'll post when I find out what happens.
You can create a distanceBetween node:
createNode distanceBetween;
this creates distanceBetween1. You can now enter the coordinates of two points in the attribute editor or you can use an expression that does this for you:
//
float $Tmp1[] = getAttr object1.translate
;
vector $point1 = <>;
float $Tmp2[] = getAttr object2.translate
;
vector $point2 = <>;
eval ("setAttr distanceBetween1.point1 " + $point1);
eval ("setAttr distanceBetween1.point2 " + $point2);
float $distance = getAttr distanceBetween1.distance
;
//
SOLUTION 3:
You can use the distance tool (modify->measure->distance_tool)
This creates two locators. You can point-constrain them to the two objects and use this line:
float $distance = getAttr distanceDimension1.distance
;
hope this helps