088 Exports using Python Script

I never could wrap my brain around TScript but Python has made implementing my projects with TD take a fraction of the time.

I’m still manually exporting CHOP channels though. I have been able to return a True/False value of whether a channel is being exported through the CHOP .export attribute, but I haven’t quite figured out a way to script the export.

Looked through the Wiki various times and haven’t run across an answer but maybe I missed it.

THANKS.

+1

Michela, I figured it out finally but I forgot to update this thread.

You must write an expression for the export connection.

So for example, to get “chan1” info from a chop called “math1” into the index of a switch called “switch1”:

n=me.parent()
q=n.op(‘switch1’)
q.par.index.expr=“op(‘math1’)[‘chan1’]”

Notice the two types of quotes, because you have a quote within another quote it helps differentiate the two in python. You have to include all of those quotes.

If you are inserting a variable you must have even more quotes. For example if you have three switches and three math chops and you want to export math1 to switch1, math2 to switch2, and math3 to switch3:

n=me.parent()
q=n.ops(‘switch*’)
x=1
for i in q:
z=‘math’+str(x)
q.par.index.expr=“op('”+z+“')[‘chan1’]”
x+=1

Note there are indents necessary on the last three lines but the text editor removes them.

It is hard to tell in the example but there are two quotation marks next to each other. There is a ’ and a " immediately after because the final expression must have the operator name in quotes as well.

I am sure there is a better way to phrase this, this is just what I have done that has worked for me.

Also I am answering this away from my Touch computer so I am not 100% sure I didn’t miss something.

Erick