Hello, I am pretty new to TouchDesigner and have been starting to create some of my own networks after following @elekktronaut 's beginner series. I have quickly found that I desire a system for storing presets, and decided to make my own, as my needs are simple.
I want to interact with the preset system via text commands, and do not require a UI. My thought is to have a Base COMP that basically just contains a single Text DAT, using extensions to define and recall presets and the component’s storage to store the preset data.
Given that all my work will be done via scripting, I’d like to utilize Git, which I am familiar with and use with other scripting languages.
What I am unsure about is the best way to work with the actual text file, to make use of git diff and merge, while still having a .tox that I can just drop into a project and be ready to go. Is this feasible? Or would I need to also drop the script file into the project folder, and then have the Text DAT find the script using project.folder
? Or simply copy the script’s contents into the Text DAT when I wanted to save a self-contained .tox?
Just externalize the extension Text DAT to a separate text file ending in .py and you should be good to go. You’d have two files then, a .tox and a .py file.
1 Like
Thank you! Does it even make sense to use a Base if it only contains one Text DAT? Or should I simply have a Text DAT that acts as a module, and then put it into a COMP down the line if I need to expand it?
As with most programming tasks, there are several ways to do this. Which one is best for your setup is largely a personal preference, although there may be downstream implications for your choices that can be hard to predict when you’re starting out.
If you simply want a tox that you can drop into your project (as you stated above) then you don’t need to externalize the Text DAT at all. If you’ve configured your Comp to include an extension it will generate the Text DAT automatically, and you can just edit that in place. Then the extension will come bundled with your tox and you can drop it in as needed.
If you want to use Git and use its diff capabilities to see changes to the extension then you’ll need to externalize the python file as I wrote above.
Generally when working with an extension the simplest approach is is to have a Comp with the Text DAT enclosed, and “expand” it by adding functions to the extension as needed over time. This fits the basic design pattern that TD uses for component hierarchies and allows you to make use of public vs private members/functions within the network’s namespace - in other words you can do things like calling a public function via a call like op(‘opName’).MyFunction().
Also, you’ll want a Comp if you’re planning to use component storage for your presets.
Make sure you’ve read this document and really understand it before you go too far. There are ways that you can import python modules as well - both those you’ve downloaded (via pip or otherwise), and those that you’ve created yourself. I’d start simple and then ask for help if you want to get more complex down the line.
1 Like