Another great tip from the Mayastation, this time on how to get the command that generates the object distance from the camera that you would see in the object details HUD display. I must say this is very handy!
“If you would like to use the HUD and enable Object information. You would get the object distance from the camera. In order to get the MEL command that does that, one should first consider that the Documentations states”
“This setting is used to select certain pre-defined HUDs, some of which retrieve specific data, that is unobtainable through normal MEL commands or scripts.”
The workaround would be doing something like so
vector $p1=`getAttr persp.translate`;
vector $p2=`getAttr pSphere2.translate`;
vector $result=$p1-$p2;
print (mag($result))
“Thanks to Lap Ho for his tip.”
Good tip if this could be turned into a menu item that could be called under the HUD menu. Might be useful for DOF calculations.