def measureDistance(mName="none", *args):
"""first the name of the measure node, then the 2 objects ORRRR select the two objects and run (will give name 'distanceBetween'"""
objs = []
if mName == "none":
mName = "distanceBetween"
objs = getTwoSelection()
else:
for each in args:
objs.append(each)
#add check for 2 selectiont
if len(objs) != 2:
cmds.error("you must enter either a measure name and 2 objects OR no arguments and manually select 2 objs")
dist = cmds.shadingNode("distanceBetween", asUtility=True, name=mName)
objA = objs[0]
objB = objs[1]
objAMatrix = objA + ".worldMatrix"
objBMatrix = objB + ".worldMatrix"
objAPoint = objA + ".rotatePivot"
objBPoint = objB + ".rotatePivot"
distPoint1 = dist + ".point1"
distPoint2 = dist + ".point2"
distMatrix1 = dist + ".inMatrix1"
distMatrix2 = dist + ".inMatrix2"
cmds.connectAttr(objAPoint, distPoint1)
cmds.connectAttr(objBPoint, distPoint2)
cmds.connectAttr(objAMatrix, distMatrix1)
cmds.connectAttr(objBMatrix, distMatrix2)
cmds.select(clear=True)
return(dist)
评论列表
文章目录