我正在尝试获取项目的尺寸(格式
),用外行术语来说就是项目的高度和宽度项目进行进一步加工。在阅读 Formats documentation 上的文档时在Nuke Python开发者指南上,我发现要获取项目的宽度和高度,必须选择脚本中的任何节点,例如
# Viewer1 is only generic thing in every project
nuke.toNode("Viewer1").setSelected(True)
projwidth = nuke.selectedNode().format().width()
projheight = nuke.selectedNode().format().height()
但这会对节点图产生一些不利影响。即使我将 nuke.toNode("Viewer1").setSelected(False)
附加到上述行的末尾,小控件仍连接到 Viewer1。
Here's如果您想查看整个脚本,请查看代码。
整个过程看起来很糟糕。我这样做有什么问题吗?可能的解决办法是什么?
最佳答案
您可以在脚本编辑器
中使用此行更改项目的查看器尺寸:
nuke.tcl('knob root.format ' '4K_DCP')
注意root.format
后面有一个空格
。
如果您想使用自己的格式,您还应该将这些行放入 .nuke
文件夹中的 init.py
或 menu.py
中(自动):
import nuke
Format_1600 = "1600 900 0 0 1600 900 1 Format_1600"
nuke.addFormat(Format_1600)
nuke.knobDefault("Root.format", "Format_1600")
其中:1600 900 0 0 1600 900 1 Format_1600
是:
# width = 1600, height = 900
# x = 0, y = 0, right = 1600, top = 900
# pixel aspect = 1 (square pixels)
# name = Format_1600
或者您可以从核武器列表中选择任何现有格式:
nuke.knobDefault('Root.format', 'HD_1080')
And, of course, you can
get
dimensions and other values of the project's format:
nuke.root()['format'].value().width()
nuke.root()['format'].value().height()
nuke.root()['format'].value().name()
nuke.root()['format'].value().pixelAspect()
nuke.root()['format'].value().x()
nuke.root()['format'].value().y()
nuke.root()['format'].value().r()
nuke.root()['format'].value().t()
关于python - 如何在 Foundry Nuke 中获取项目尺寸?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46287653/