2013年5月10日金曜日

nuke python Readノードを順番に並べる



startFrame = 1
for n in nuke.selectedNodes():
    n['frame_mode'].setValue('start_at')
    n['frame'].setValue(str(startFrame))
    n['before'].setValue('black')
    n['after'].setValue('black')
    startFrame += n['last'].getValue()-n['first'].getValue()+1



Copyノードを作り、コンスタントノードと選択ノードをインプットA、Bにさす。
fromScriptって値の設定の仕方が便利。
ノードをスクリプトエディタにコピペ した書き方で書ける。

for n in nuke.selectedNodes():
    Const = nuke.createNode( "Constant" )
    Const["format"].setValue("1280-720")
    Const["color"].setValue([0,0,0,1])
    Const["channels"].setValue("rgba")
    Cp = nuke.nodes.Copy()
    Cp.setInput(1, Const)
    Cp.setInput(2, n)
    Cp['from0'].fromScript('rgba.alpha')
    Cp['to0'].fromScript('rgba.alpha')