我正在尝试编写一个转盘脚本,它会自动将我的所有对象(边界框)放入我的 HD 1080 (1920x1080) 分辨率门的框架内
test = cmds.select('MODELS*')
mel.eval('FrameSelectedInAllViews')
cmds.setAttr('TT_CAM.cameraScale', 1)
因为我有很多,我上面的代码是编写边界框脚本的正确方法吗?
请您参考如下方法:
我只能考虑创建临时定位器,填充所选对象的边界框,然后将这些定位器框起来,到目前为止我测试过的效果很好。
我在下面的脚本中添加了注释:
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()
