I have written a simple script that adds a TimeOffset node after a Read or a FrameRange node.
Quote:
import os
import nuke
def offsetNode():
sn = nuke.selectedNode()
if sn.Class() == ‘Read’:
fr = int(sn[‘first’].value())
to = nuke.createNode(‘TimeOffset’)
to[‘time_offset’].setValue(-fr)
elif sn.Class() == ‘FrameRange’:
fr = int(sn[‘first_frame’].value())
to = nuke.createNode(‘TimeOffset’)
to[‘time_offset’].setValue(-fr)
|
This works very nice. But when I try to convert it so I can just select all the nodes I want to have offsets added it dies…
Quote:
import os
import nuke
def offsetNode():
sn = nuke.selectedNodes()
for n in sn:
if n.Class() == ‘Read’:
fr = int(sn[‘first’].value())
to = nuke.createNode(‘TimeOffset’)
to[‘time_offset’].setValue(-fr)
elif n.Class() == ‘FrameRange’:
fr = int(sn[‘first_frame’].value())
to = nuke.createNode(‘TimeOffset’)
to[‘time_offset’].setValue(-fr)
|
It prints that "list indices must be integers". That I know but where is a list there? I am certain that the solution is super easy I’m just super blind. Any help?
Post a Comment