Python Loops For Setting Parameters

I’m finally starting to understand for loops and while loops but haven’t been able to relate them to TD Operators.

Let’s say I have 10 Constant TOPs and I wanted to set the resolution1 parameter to 20 in all 10 TOPs. I’d love to write a little script to handle this task, the result of which would set all the parameters automagically. Something like:

o = op(‘constant’)
p = o.par.resolution1
par = 20

while oppar != 20
print(par)

First, I’m not sure if a while loop is better than a for loop in this situation. Second, I know that code is junk - I just want to convey what I’m after.

Can you help explain this mystery that is probably very obvious to everyone but me?
Thanks!


Brain.

It’s something like this:

# get all the constant TOPs
constants = ops('constant*')

for c in constants:
    c.par.resolution1 = 20

Not checking for typing errors. If you have other nodes in the network named constantXX, such as Constant CHOPs, you’ll need to add an if statement inside the for to ensure you are only changing constant TOPs.

Perfect, thank you Malcolm!!

Guess it was the on-the-fly variables that were throwing me for a loop… :open_mouth:

This gives me enough to play with, thanks again.


Brain.