我想编写一个脚本,该脚本使用Nuke的内置性能计时器来" SANITY-CHACK"当前comp。为此,我正在清理所有观看器缓存以开始新鲜。现在我需要触发缓存。似乎实现此目的的唯一方法是使用nuke.activeViewer().play(1)
。使用此呼叫,我可以缓存时间轴,但是当时间轴完全缓存以便能够停止并重置Performace Timers时,我没有迹象表明。
我知道,我也可以使用nuke.activeViewer().frameControl(+1)
一次跳过1帧,直到我在最后一帧,但在我看来,使用此调用并没有导致COMP来缓存该帧。实际上,时间轴表示框架已缓存,但nuke.activeViewer().node().frameCached(nuke.frame())
返回false
。
尽管如此
这里是:
import nuke
nuke.clearRAMCache()
vc = nuke.activeViewer()
v = vc.node()
fr = v.playbackRange()
vc.frameControl(-6)
print fr.maxFrame()
cached_frames = 0
while cached_frames < fr.maxFrame():
print "Current Frame: {}".format(nuke.frame())
if not v.frameCached(nuke.frame()):
print "Frame: {} not cached".format(nuke.frame())
while not v.frameCached(nuke.frame()):
print "caching..."
vc.play(1)
print "Frame: {} cached".format(nuke.frame())
print "Incrementing from caching"
cached_frames += 1
else:
vc.frameControl(1)
print "incrementing from skipping"
#cached_frames += 1
print "Cached Frames: {}".format(cached_frames)
print "DONE"
vc.stop()
我知道这不是一个非常不错的代码,但有时这些行执行得很好,有时它只是随机(至少看起来如此)的时间。
那么,核武器中的观众是否有任何回调或可写的回调或类似的东西?
任何帮助都非常感谢!
您想实现哪些特定要求W.R.T?
nuke具有内置功能
" nuke可以在屏幕上显示准确的性能正时数据或将其输出到XML文件中,以帮助您在慢速脚本中对瓶颈进行故障排除。当启用性能时序时,在节点图中显示了定时信息,并且节点本身是根据颜色的从绿色(快节点)到红色(慢节点)所花费的总处理时间的比例。" -
提到
模拟查看时间表上的回调仅使用线程才能实现。只需创建一个线程,检查要缓存的当前帧,然后使用该线程中的nuke.activeViewer().frameControl()
逐步到下一个帧。