Detect Touchdesigner start

Is there some kind of a callback or a way to detect if Touchdesigner has just launched?

Thanks!

I did find one way.

Using a timeline Chop and using Chop Execute.

I created a global boolean variable and set it to False. In onValueChange I check if this variable is false. If it is, I do my stuff and set the variable to True.

restarted = False def onValueChange(channel, sampleIndex, val, prev): global restarted if (not restarted): # do my stuff restarted = True return

Use an Execute DAT, it has an onStart() callback in it.

I have found that Execute onStant doesn’t seem to work consistently. Granted I’m not on most recent build, but I did similar Timeline CHOP workaround to be sure.

We’ve moved pretty firmly into an extension framework for installations. With that in mind, I’ll often use the init() method of our Project class for on start executions. Unlike onStart() that can be a little wonky to get a handle on sometimes, using the extension initialization route has been the most consistent and happens as as an order of operations that’s easier to keep a handle on.

1 Like

Strange, I’ve never had a problem with onStart. The init() method sounds like it works well, but I’d stay away from using a chop based start trigger linked to a global. That feels not completely reliable.

To be totally honest, we were doing some pretty stupid things in our onStart().

The messy place we ended up was not knowing the initialization order for touch - so we were trying to configure out networks by calling other extensions. It was never totally clear when onStart() was called, and how that related to operator creation, and python library loading / handling.

I finally managed to track down an issue that was related to the fact that onStart() was called before some other Touch python bits were up and running, so we had to fall back onto some messy explicit calls to first reinit extensions, set temporary variables, blah blah blah. Using an extension’s init solved this because we knew that all of the other Touch house-keeping was up and running before extensions and modules were initialized.

That’s a long way around to say that our issue wasn’t onStart() functioning correctly, but rather our own imperfect understanding of how it actually functioned - story of my life as a programmer.

To your point, I should add that I don’t usually put a ton of code in the onStart(), I usually have a run() command in there that runs init scripts 5-10 seconds after the network is up and running. Maybe that’s why we haven’t had issues with it.

That’s the ticket. We’ve also used the run after delay approach to work around the same challenge.

for onStart() Same here…

(delayFrames=10) :smiley: