Login | Register 

how to handle multiple containers

Still a little green? Ask your beginner's questions here

how to handle multiple containers

Postby dus » Wed Apr 17, 2019 1:40 am

i was wondering if there is a way to tell touchdesigner in phyton to go from a list of operators and do the same thing by their number or by name, for example if i have 20 operators called: null1, null2, null3, etc to null20, how could i say that when all of those operators are in 0 do something, is there a way? should i convert that data to a table, or should i do variables or is there something like range(19) in phtyon? ive thinking about this for days but i pretty far from solving it

thanks for the help!
Posts: 8
Joined: Tue Jun 19, 2018 6:44 pm

Re: how to handle multiple containers

Postby Ivan » Wed Apr 17, 2019 6:04 pm

Your question isn't totally clear, but if I understand, you might want something like this:

Code: Select all
for compNum in range(20):
   comp = op('null' + str(compNum))
User avatar
Posts: 194
Joined: Fri Mar 18, 2016 7:12 pm

Re: how to handle multiple containers

Postby rob » Thu Apr 18, 2019 10:18 am

Depending on the naming convention, you can also use the ops function to get them directly:

Code: Select all
for comp in ops('null*'):


Code: Select all
for comp in ops('null[1-20]'):

User avatar
Posts: 1621
Joined: Tue Nov 13, 2007 1:14 am

Re: how to handle multiple containers

Postby hmbemba » Thu Apr 18, 2019 10:28 am

Here's some code I like to use often in a textdat

Code: Select all
path = me.parent().findChildren(type=TOP, depth=1)
for x in range( len( path ) ):   
         #If you want to skip certain ops
   #if path[x] != ' ' : #and path[x].base != ' ':
      #Print these ops
      # op(str(path[x])).par.whatever = ......
Posts: 18
Joined: Mon Mar 27, 2017 6:48 pm

Re: how to handle multiple containers

Postby nettoyeur » Thu Apr 18, 2019 5:44 pm

Also checkout Tags: https://docs.derivative.ca/Tag

You can give any operator one or multiple tags. Together with the findChildren method this is a very powerful and fast way to find a group of nodes and do something with them.

The findChildren method is explained here:
Idzard Kwadijk | freelance TouchDesigner consultant | IdzArd.com
Checkout ChopChopChop.org - the TouchDesigner marketplace!
Posts: 1073
Joined: Mon Oct 15, 2012 12:00 pm
Location: Amsterdam, The Netherlands

Return to Beginners

Who is online

Users browsing this forum: Google [Bot] and 9 guests