سؤال

How can I move just the pivot of the selected node to the bottom of the bounding box?

# 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)
هل كانت مفيدة؟

المحلول

bbox is a 6-element list of XYZ min and XYZ max: [xmin, ymin, zmin, xmax, ymax, zmax]. If you want the pivot point to be the bottom center, you'll want the average X, minimum Y, and average 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)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top