Good chance I’m missing something here, but I’m seeing a strange behavior I can’t seem to work around.
@elburz and I were chatting this morning about delay scripts, and he ran into an issue that I couldn’t get out of my head this morning.
The expected behavior is to use ops()
to return a list of operators that you then run a delay script against. That might look like this:
i = 0
for op in ops('item*'):
script = "op('{}').par.Pulse.pulse()".format(op.path)
print(script)
printScript = "print(args[0])"
i+=1
run(printScript, script, delayFrames = i*60)
run(script, delayFrames = i*60)
This however produces the following error message:
Traceback (most recent call last):
File "</project1/text4:op('/project1/item1').par.Pulse.pulse()>", line 1
TypeError: 'td.containerCOMP' object is not callable
Printing the script, it does look as though it aught to work; and sure enough, running one of the printed lines does work as expected.
I tested this against a few other delay mechanisms, both of which work.
This script works correctly:
for i in range(7):
script = "op('/project1/item{}').par.Pulse.pulse()".format(i+1)
print(script)
run(script, delayFrames = 60*i)
As does this one:
targetOps = [
"/project1/item1",
"/project1/item2",
"/project1/item3",
"/project1/item4",
"/project1/item5",
"/project1/item6",
"/project1/item7"]
i = 0
for eachItem in targetOps:
script = "op('{}').par.Pulse.pulse()".format(eachItem)
print(script)
i+=1
run(script, delayFrames = 60*i)
Interestingly, the findChildren()
method produces the same results as the ops
method:
i = 0
for op in parent().findChildren(name='item*', depth=1):
script = "op('{}').par.Pulse.pulse()".format(op.path)
print(script)
printScript = "print(args[0])"
i+=1
run(printScript, script, delayFrames = i*60)
run(script, delayFrames = i*60)
Resulting error:
Traceback (most recent call last):
File "</project1/text4:op('/project1/item1').par.Pulse.pulse()>", line 1
TypeError: 'td.containerCOMP' object is not callable
Finally, a list comprehension built from ops()
is successful:
targetOps = [op.path for op in ops('item*')]
i = 0
for eachItem in targetOps:
script = "op('{}').par.Pulse.pulse()".format(eachItem)
print(script)
i+=1
run(script, delayFrames = 60*i)
This seems like it might be an issue with the ops()
and findChildren()
methods?
Attached is an example toe file:
ops-bug.toe (4.5 KB)
Thanks Derivative Team