本文整理汇总了Python中nuke.root方法的典型用法代码示例。如果您正苦于以下问题:Python nuke.root方法的具体用法?Python nuke.root怎么用?Python nuke.root使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nuke
的用法示例。
在下文中一共展示了nuke.root方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _force_update_all
# 需要导入模块: import nuke [as 别名]
# 或者: from nuke import root [as 别名]
def _force_update_all():
with nuke.root():
node_count = 0
for node in nuke.allNodes():
if node.Class() == "Cryptomatte":
node_count = node_count + 1
cinfo = CryptomatteInfo(node)
_update_cryptomatte_gizmo(node, cinfo, force=True)
nuke.message("Updated %s cryptomatte gizmos." % node_count)
#############################################
# Utils - Update Gizmi
#############################################
示例2: reset_resolution
# 需要导入模块: import nuke [as 别名]
# 或者: from nuke import root [as 别名]
def reset_resolution():
"""Set resolution to project resolution."""
project = io.find_one({"type": "project"})
p_data = project["data"]
width = p_data.get("resolution_width",
p_data.get("resolutionWidth"))
height = p_data.get("resolution_height",
p_data.get("resolutionHeight"))
if not all([width, height]):
missing = ", ".join(["width", "height"])
msg = "No resolution information `{0}` found for '{1}'.".format(
missing,
project["name"])
log.warning(msg)
nuke.message(msg)
return
current_width = nuke.root()["format"].value().width()
current_height = nuke.root()["format"].value().height()
if width != current_width or height != current_height:
fmt = None
for f in nuke.formats():
if f.width() == width and f.height() == height:
fmt = f.name()
if not fmt:
nuke.addFormat(
"{0} {1} {2}".format(int(width), int(height), project["name"])
)
fmt = project["name"]
nuke.root()["format"].setValue(fmt)
示例3: has_unsaved_changes
# 需要导入模块: import nuke [as 别名]
# 或者: from nuke import root [as 别名]
def has_unsaved_changes():
return nuke.root().modified()
示例4: current_file
# 需要导入模块: import nuke [as 别名]
# 或者: from nuke import root [as 别名]
def current_file():
current_file = nuke.root().name()
# Unsaved current file
if current_file == 'Root':
return None
return os.path.normpath(current_file).replace("\\", "/")
示例5: populate_sub_cache
# 需要导入模块: import nuke [as 别名]
# 或者: from nuke import root [as 别名]
def populate_sub_cache(ptask_version=None, refresh=False):
if not ptask_version:
ptask_area = PTaskArea.current()
ptask = PTask.get(ptask_area.spec)
if ptask_area.version:
ptask_version = ptask.version(ptask_area.version)
else:
ptask_version = ptask.latest_version
nuke_file = nuke.root().name()
nuke_dir = os.path.dirname(nuke_file)
if refresh or not SUBD_REPR_CACHE:
for sub in ptask_version.subscriptions:
for product_repr in sub.product_version.representations:
product = product_repr.product_version.product
if product.category != 'imgseq':
continue
product_repr_str = product.name_spec + ' @ ' + \
product_repr.type
if product_repr.resolution != 'none':
product_repr_str += PTaskSpec.SEPARATOR + \
product_repr.resolution
sub_import_dir = get_import_dir(product_repr,
product=product, area=ptask_area, relative_to=nuke_dir)
# populate cache lookups
SUBD_REPR_CACHE.append(product_repr)
PRODUCT_REPR_STR_TO_PATH[product_repr_str] = \
sub_import_dir
# -----------------------------------------------------------------------------
示例6: process
# 需要导入模块: import nuke [as 别名]
# 或者: from nuke import root [as 别名]
def process(self, context, plugin):
import nuke
nuke.root()["proxy"].setValue(0)
示例7: execute
# 需要导入模块: import nuke [as 别名]
# 或者: from nuke import root [as 别名]
def execute(self, instance):
import nuke
# Get frame range
node = instance[0]
first_frame = nuke.root()["first_frame"].value()
last_frame = nuke.root()["last_frame"].value()
if node["use_limit"].value():
first_frame = node["first"].value()
last_frame = node["last"].value()
# Render frames
nuke.execute(node.name(), int(first_frame), int(last_frame))
示例8: process
# 需要导入模块: import nuke [as 别名]
# 或者: from nuke import root [as 别名]
def process(self, context):
import nuke
context.data["framerate"] = nuke.root()["fps"].getValue()
示例9: process
# 需要导入模块: import nuke [as 别名]
# 或者: from nuke import root [as 别名]
def process(self, context, plugin):
import nuke
import ftrack
ftrack_data = context.data("ftrackData")
task = ftrack.Task(ftrack_data["Task"]["id"])
parent = task.getParent()
nuke.root()["fps"].setValue(parent.get("fps"))
handles = parent.get("handles")
nuke.root()["first_frame"].setValue(parent.getFrameStart() - handles)
nuke.root()["last_frame"].setValue(parent.getFrameEnd() + handles)
示例10: makeNodesRelative
# 需要导入模块: import nuke [as 别名]
# 或者: from nuke import root [as 别名]
def makeNodesRelative(nodes, knobTypes):
result = { 'warnings': [], 'replacements': [], 'projectFolder': None}
projectfile = nuke.root()['name'].value()
if projectfile =="":
result['warnings'].append('Please save the nuke script before running this function such that it has a valid path.')
return result
projectFolderAbsolute = posixpath.dirname(projectfile)
result['projectFolder'] = projectFolderAbsolute
projectFolderRelative = "[file dirname [value root.name]]"
for n in nodes:
for k in knobTypes:
if n.knob(k):
originalFilePath = n[k].value()
if n[k].isAnimated():
result['warnings'].append("Didn't replace "+k+' of node '+n['name'].value()+' since the knob is animated')
elif n[k].hasExpression():
result['warnings'].append("Didn't replace "+k+' of node '+n['name'].value()+' since the knob has an expression')
elif originalFilePath.strip()=="":
#result['warnings'].append("Didn't replace "+k+' of node '+n['name'].value()+' since it is empty')
pass
elif originalFilePath.startswith(projectFolderRelative):
result['warnings'].append("Didn't replace "+k+' of node '+n['name'].value()+' since it is already a relative path:\n'+ __removePrefix(originalFilePath,projectFolderRelative))
else:
relativeFilePath = posixpath.relpath(originalFilePath,projectFolderAbsolute)
n[k].setValue(projectFolderRelative + '/' +relativeFilePath)
result['replacements'].append(k+' of '+ n['name'].value()+':\n'+relativeFilePath)
return result
示例11: makeNodesAbsolute
# 需要导入模块: import nuke [as 别名]
# 或者: from nuke import root [as 别名]
def makeNodesAbsolute(nodes, knobTypes):
result = { 'warnings': [], 'replacements': [], 'projectFolder': None}
projectfile = nuke.root()['name'].value()
if projectfile =="":
result['warnings'].append('Please save the nuke script before running this function such that it has a valid path.')
return result
projectFolderAbsolute = posixpath.dirname(projectfile)
result['projectFolder'] = projectFolderAbsolute
projectFolderRelative = "[file dirname [value root.name]]"
for n in nodes:
for k in knobTypes:
if n.knob(k):
originalFilePath = n[k].value()
if n[k].isAnimated():
result['warnings'].append("Didn't replace "+k+' of node '+n['name'].value()+' since the knob is animated')
elif n[k].hasExpression():
result['warnings'].append("Didn't replace "+k+' of node '+n['name'].value()+' since the knob has an expression')
elif originalFilePath.strip()=="":
#result['warnings'].append("Didn't replace "+k+' of node '+n['name'].value()+' since it is empty')
pass
elif originalFilePath.startswith(projectFolderRelative):
relativeFilePath = __removePrefix(originalFilePath,projectFolderRelative+'/')
absoluteFilePath = posixpath.join(projectFolderAbsolute, relativeFilePath)
absoluteNormalizedFilePath = posixpath.normpath(absoluteFilePath)
n[k].setValue(absoluteNormalizedFilePath)
result['replacements'].append(k+' of '+ n['name'].value()+':\n'+absoluteNormalizedFilePath)
else:
result['warnings'].append("Didn't replace "+k+' of node '+n['name'].value()+' since it is no relative path.\nproject path:'+projectFolderAbsolute+'\nfile path: '+originalFilePath)
return result
示例12: center_chromatik
# 需要导入模块: import nuke [as 别名]
# 或者: from nuke import root [as 别名]
def center_chromatik():
try:
node_format = nuke.selectedNode()
except ValueError:
node_format = nuke.root()['format'].value()
nuke.thisNode()['center'].setValue((node_format.width() / 2, node_format.height() / 2))
示例13: getCurrentSceneFile
# 需要导入模块: import nuke [as 别名]
# 或者: from nuke import root [as 别名]
def getCurrentSceneFile():
return nuke.root().name()
示例14: _force_update_all
# 需要导入模块: import nuke [as 别名]
# 或者: from nuke import root [as 别名]
def _force_update_all():
with nuke.root():
node_count = 0
for node in nuke.allNodes():
if node.Class() == "Cryptomatte":
node_count = node_count + 1
cinfo = CryptomatteInfo(node, reload_metadata=True)
_update_cryptomatte_gizmo(node, cinfo, force=True)
nuke.message("Updated %s cryptomatte gizmos." % node_count)
示例15: _troubleshoot_setup
# 需要导入模块: import nuke [as 别名]
# 或者: from nuke import root [as 别名]
def _troubleshoot_setup():
MSG_BAD_INSTALL = ("Installation is wrong, callbacks were not found. "
"setup_cryptomatte() did not run, init.py may "
"not be set up properly. ")
PROXY_MODE = "Proxy mode is on, this can cause artifacts. "
issues = []
expected_knob_changeds = ["Cryptomatte", "Encryptomatte"]
if any(x not in nuke.callbacks.knobChangeds for x in expected_knob_changeds):
issues.append(MSG_BAD_INSTALL)
if nuke.root().knob('proxy').value():
issues.append(PROXY_MODE)
return issues