Login | Register 
FEATURES
APPLICATIONS
DOWNLOADS
EDUCATION
BLOG
WIKI
FORUM
STORE

Python, addressing inside of variables

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

Python, addressing inside of variables

Postby GJG » Tue Jul 09, 2019 7:09 pm

Hello Everyone !

let's say I have a chop execute connected to a button comp and a 'base1' comp with a small network inside it.

My goal is:

1) to make a copy of "base1" just below the original one once I click the button.

2) change a value of a "constant1" chop inside the freshly copied base comp. (this is the part were I got stuck)

my code under onOffToOn so far:

Code: Select all
   op_amt = len(me.parent().findChildren(name = 'base*'))
   new_base = op('../project1').copy(op('base1'))
   new_base.nodeY = op('base1').nodeY - (150 * op_amt)
       
here is where I'd like to change value of "constant1" inside the new_base.

   return


How do I write this ?
Any help appreciated
GJG
 
Posts: 6
Joined: Mon Feb 25, 2019 9:38 am

Re: Python, addressing inside of variables

Postby nettoyeur » Tue Jul 09, 2019 7:38 pm

add this line:

Code: Select all
op(new_base.path + '/constant1').par.value0 = 33


Also look into the Replicator COMP which could be easier to manage multiple copies of a component.
Idzard Kwadijk | freelance TouchDesigner consultant | IdzArd.com
Checkout ChopChopChop.org - the TouchDesigner marketplace!
nettoyeur
 
Posts: 1151
Joined: Mon Oct 15, 2012 12:00 pm
Location: Amsterdam, The Netherlands

Re: Python, addressing inside of variables

Postby GJG » Wed Jul 10, 2019 4:53 am

Super, thanks man :)
GJG
 
Posts: 6
Joined: Mon Feb 25, 2019 9:38 am


Return to Beginners

Who is online

Users browsing this forum: No registered users and 20 guests