Addressing all OPs of a component using Python?

Hey there, I have a custom component with multiple operators inside and I’m trying to bypass all of these operators except for a few of them with the click of a button
I’m using this script in the chop execute:
op(‘opname’).bypass = 1
and it works without a problem but the problem is I wanna bypass many operators all at once so I was thinking there should be a way to address all OPs in the component minus a few which I can type their names but I don’t know how to achieve this
I’d appreciate it if anyone could help me out here

In this case you’re looking for Python methods available for a COMP, so look in documentation here:

There you’ll find the method findChildren() which can do what you want.

Thank you for your response but as a beginner I have very limited knowledge of Python. The findchildren() section instructions are very vague to me and I couldn’t even find what I was looking for there. There was nothing about all OPs there but I went with the closest option to what I was looking for which was to specify the type of most of the OPs which was TOP. But still as a beginner I don’t understand how I can integrate findchildren() into my chop execute so I guessed it could be like this:
op(‘n.findChildren(type=TOP)’).bypass = 1
but apparently it wasn’t
I’d appreciate if you could help me out by giving me more specific guidance rather than referring to a sophisticated documentation. I’d definitely wanna read the whole documentations on python as soon as I’m ready for it but right now I just need a simple script and don’t have the time to go through all that.
Thank you for your help in advance

that method returns a list, which you’d need to iterate over with a loop to address all found operators, like this:

operator_list = yourcomp.findChildren()

for operator in operator_list:
	operator.bypass = 1

…adding any arguments you need in findChildren() to narrow down your search, and replacing yourcomp.
“type” is I think a specific operator type, not a category like TOP or CHOP.

I’d recommend to familiarize yourself with at least a tiny bit of python if you see yourself needing such functionality in TD. No need to read the documentation. You can find some beginner videos on python loops, python objects, generic stuff like that, or start your days with a video from this series.

1 Like

Thank you for your response and also the link you provided. I think you’re actually right. It is time for me to start learning the basics of python.