我正在尝试编写一个转盘脚本,它会自动将我的所有对象(边界框)放入我的分辨率门的帧中,即HD 1080(1920x1080)
test = cmds.select('MODELS*')
mel.eval('FrameSelectedInAllViews')
cmds.setAttr('TT_CAM.cameraScale', 1)
由于我有很多,我上面的代码是用于编写边界框的正确方法吗?
答案 0 :(得分:2)
我只能想到创建临时定位器,填充所选对象的边界框,然后构建这些定位器,这与我测试过的一样好。
我在下面的脚本中添加了评论:
from pymel.core import *
select("MODELS*")
## Gather our world bounding box and store it in a variable called b
b = general.exactWorldBoundingBox()
## b now contains min and max XYZ world coords
## Name our temporary locators
locName = "tempLoc"
## Create a locator at each min and max point to form a fake bounding box
positions = [[0,1,2], [0,4,2], [0,4,5], [3,4,5], [3,1,5], [3,4,2], [3,1,2], [0,1,5]]
## Create the locators
for position in positions:
print position
spaceLocator(p=(b[position[0]],b[position[1]],b[position[2]]), name=locName)
## Once we create the locators, frame locators, delete
tempLocators = select("tempLoc*", r=1)
runtime.FrameSelectedInAllViews()
delete()