Does somebody know how the Distance From Camera info in the Heads Up 
Display is being query?

I can“t find the script inside the maya folder, it is a pre script but is 
not being show in iniHUDScripts.mel or iniHUD.mel  is 
named: HUDObjDetDistFromCam

I try different ways of getting the same value, xform, translate, center, 
bounding box, none is giving me the same numbers as the HUD gives me, 
besides, I had to use different method for different objects (alembics, 
plugin caches like yeti fur, arnold standins) but the HUD seems to be 
always right doesn't matter which kind of object you select, how is this 
being achieved?

I know I can query the HUD result directly from there, but I had to select 
every object before doing that, and turn on Object Details in HUD

Can I call the procedure HUD is using, directly from mel or python? 

Some examples, :


import maya.cmds as cmds
import maya.OpenMaya as om
import maya.OpenMayaUI as mui

#-------------------------- HUD Distance from Camera  (you need to turn on 
Object Details)

print(cmds.headsUpDisplay("HUDObjDetDistFromCam", q=1, sr=1))

#-------------------------  X FORM
P1 = cmds.xform("camara", q=1, ws=1, t=1)
P2= cmds.xform(cmds.ls(sl=1), q=1, ws=1, t=1)
v1, v2 = om.MVector(*P1), om.MVector(*P2)
distanceFromCamera=om.MVector(v2-v1).length()
print "Distancia", distanceFromCamera

#-------------------------  TRANSLATE
P1 = cmds.getAttr("camara.translate")
P2= cmds.getAttr(cmds.ls(sl=1)[0]+".translate")
v1, v2 = om.MVector(*P1[0]), om.MVector(*P2[0])
distanceFromCamera=om.MVector(v2-v1).length()
print "Distancia", distanceFromCamera

#-------------------------  CENTER
P1 = cmds.getAttr("camara.translate")
P2= cmds.getAttr(cmds.ls(sl=1)[0]+".center")
v1, v2 = om.MVector(*P1[0]), om.MVector(*P2[0])
distanceFromCamera=om.MVector(v2-v1).length()
print "Distancia", distanceFromCamera

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/7be9473d-745e-4c13-b892-69058db807f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to