如何只将所选节点的轴移动到边界框的底部?
# Move the pivot for each selected not to it's center then bottom
import maya.cmds as cmds
curSel = cmds.ls(long = True, selection = True, type = 'dagNode')
for n in curSel:
bbox = cmds.exactWorldBoundingBox(n)
cmds.xform(n, cp=1)
答案 0 :(得分:3)
bbox
是 XYZ min 和 XYZ max 的6个元素列表:[xmin, ymin, zmin, xmax, ymax, zmax]
。如果您希望枢轴点为底部中心,则需要平均X,最小Y和平均Z:
bbox = cmds.exactWorldBoundingBox(n)
bottom = [(bbox[0] + bbox[3])/2, bbox[1], (bbox[2] + bbox[5])/2]
cmds.xform(n, piv=bottom, ws=True)