1

我正在尝试获取项目的尺寸(format),在外行术语中,项目的高度宽度用于进一步处理。在阅读有关 Nuke Python 开发人员指南的Formats 文档时,我发现要获取项目的宽度和高度,必须选择脚本中的任何节点,例如

# Viewer1 is only generic thing in every project
nuke.toNode("Viewer1").setSelected(True)
projwidth = nuke.selectedNode().format().width()
projheight = nuke.selectedNode().format().height()

但这会对节点图产生一些不利影响。Gizmo 连接到 Viewer1,即使我附加nuke.toNode("Viewer1").setSelected(False)到上述行的末尾。

如果您想查看整个脚本,这里是代码。

这个整体过程看起来很糟糕。我做错了什么吗?可能的解决方法是什么?

4

1 回答 1

1

您可以使用以下行更改项目的查看器尺寸Script Editor

nuke.tcl('knob root.format ' '4K_DCP')

注意space后面有root.format

如果您想使用自己的格式(自动),也应该将这些行放入文件夹中init.py或文件夹中:menu.py.nuke

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 列表中选择任何现有格式:

nuke.knobDefault('Root.format', 'HD_1080')

而且,当然,您可以get使用项目格式的尺寸和其他值:

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()
于 2017-09-19T08:38:26.007 回答