Trying to run the timeline with a button

Am I doing something wrong here? I’m trying to send the message “me.time.play 1” using this button but I cant figure out where to send that python to make it work.

Hi @g00berbread

executing python from a ui element like a Button is best done via a Panel Execute DAT which provides callbacks for the various states a UI element can have.

Please check out our curriculum at

for fundamental knowledge about the core concepts behind TouchDesigner. Especially section

Hope this helps
cheers
Markus

I reviewed section 107 and I still couldnt get an exact script to make it work. this is what I was trying, whats a script that would just run the code in a table like this??

Hi @g00berbread

me.time.play = 0 would be considered part of a python script. For example when you open the textport and paste and hit enter, it will execute.

You can use a callback function in a Panel Execute DAT and paste it inside the function to execute it when something specific happens.

What you are trying to do in the current script is execute a Table DAT cell or it’s content. THis is a bit unorthodox. What is wrong is your syntax. The cell itself returns a string, and that has to be run in python:

run(op('eval1')[0,0])

or written out to be a bit more clear:

# get the content of the table cell
a = op('eval1')[0,0].val
# run the string
run(a)

When executing your script, you should see some errors - these can always give you hints to what might be wrong. The error you should be seeing is SyntaxError: invalid syntax

Much easier is to just write that script directly into the appropriate callback function:

def onOffToOn(panelValue: PanelValue):
	"""
	Called when a panel value changes from 0 to non-zero.
	"""
	me.time.play = 0
	return

I wonder though what your intent is with controlling the timeline like this. Stopping the timeline will stop operators from processing data which might have unexpected consequences for your project.

cheers
Markus

okay I got it to run through a CHOPexec with the button, and it works with the button.

But, the ultimate goal of this is to use osc to send a 0-1 value to start playback (meant for syncing with audio for performance). And the osc value its getting isnt inputing in the string even though its basically the same value and name, I even printed out the button working and its value but the osc doesnt do that.

Thoughts?

Hi @g00berbread

Difficult to tell from just a screenshot, best to post the file as you have it right now. Are all the parameters of the CHOP Execute DAT set correctly to watch the incoming channel?
Also have a look at the callback function’s arguments: you get the value passed in, no need to fetch it explicitly from the CHOP.

A more general note though, driving animations by controlling the main timeline is not a reliable workflow. Everything stops cooking when you turn the timeline off - your osc messages might stop processing for example.
If you like, explain the general idea of what you are trying to do. Are the animations keyframed, you can use the Timer CHOP to drive those. Are the visuals fully generative, maybe you just want to fade in and out?
I think for 99% of the cases, controlling the timeline would be the wrong approach.

cheers
Markus

I don’t know why it took me so long to realize what you meant about the cooking when timeline isn’t running.

My issue is, for my experience level and how I know to do animations and such, having everything run off the timeline is my best case scenario.

So is there anyway to make osc like, reset the timeline to zero so I could have the touchdesigner visuals start at the same time as audio through Q-Lab? something of that nature?

Hi! I think there are two separate things happening in your screenshots.

Your Button COMP isn’t connected to the OSC input chain, so clicking it won’t trigger the CHOP Execute DAT monitoring select10.

For the TouchDesigner button, use a Panel Execute DAT with:

  • Panels: button1

  • Panel Value: state

  • Off to On: On

Then:

def onOffToOn(panelValue):
    root.time.play = True
    return

For your Max OSC control, the 1.0 / 0.0 values in the Textport suggest the messages are arriving correctly.

One important thing to check: OSC In CHOP → Common → Time Slice = Off.

If your OSC values represent play/pause states, you can keep the Value Change callback and use root.time.play = bool(val).

If they’re momentary button presses, trigger only on the 0 → 1 transition instead. Repeated OSC messages containing 1 without returning to 0 won’t generate new rising edges; an OSC In DAT would be better for detecting every incoming message.

Hope this helps!

— SPATIALWTF