Distance Between, How?

Hi..

I

it will create a shape node and Q the shapenode distance then u can get it

CODE
getAttr distanceDimensionShape1.distance

Hi!
I actually did the same yesterday, although it didn't run perfectly... somehow maya bugs every now and then and "forget" to create the measure tool.
But when it works you should get the attribute distance from the distanceDimension node using:
float $myDis = getAttr distanceDimensionShape1.distance;
sorry if it's not actually correct I'm not behind maya right now. If it doesn't look the node up in the node reference guide!
Note: I think maya uses centimeters as units.

good luck!
Bob

Or you can use an expression to get the value and add it to a custom attribute.
For example

CODE
vector $p1 = <>;
vector $p2 = <>;
vector $diff = ( $p1 - $p2 );

float $distance = sqrt( dot( $diff, $diff ) );

object.customAttr = $distance;

getAttr object.customAttr;

Or you could do the same thing with linking together nodes. If of course you have trouble with distance dimension. Which I also have had in the past. Should not be to heavy on your scene either.

cheers

MAya allways calcs everything as if it was unitless, anyway if it bugs you need to rechek yoru code.

PS. dont use a expression for this as its much more over head then distyance dimension.

Aslo this dont make much sense either:

vector $diff = ( $p1 - $p2 );
float $distance = sqrt( dot( $diff, $diff ) );

As mag( $p1 - $p2 ) calculates same thing but with a few less steps to iterate and a bit faster

Hold down, guys ! sqrt( dot( $diff, $diff ) ) ?

What about the distance Between node ( in hypershade/general utilities).
You create a node, connect your first object ("center"or whatever you want) to the distanceBetween.point1.
Same for the second object in distanceBetween.point2.
Then at the end you have a value "distanceBetween.distance" in Maya units.
Just connect this value to whatever you need ... and that's it ! No getAtt, matrix calculations or ... what was it ? sqrt( dot( $diff, $diff ) ).

Cheers,
Guyb.