Skip to content

Commit 53f0b54

Browse files
committed
Preliminary Commit
Moves code from raganmd repo
1 parent 50cbc84 commit 53f0b54

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1904
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: version updates
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
7+
jobs:
8+
Build_tox:
9+
runs-on: [self-hosted, Windows, TouchDesigner]
10+
steps:
11+
- name: Check out repository code
12+
uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
fetch-tags: true
16+
17+
- name: Start Python Runner
18+
run: python scripts/build_tox.py
19+
env:
20+
IS_GITHUB: "TRUE"
21+
22+
- name: Release
23+
uses: softprops/action-gh-release@v2
24+
if: startsWith(github.ref, 'refs/tags/')
25+
with:
26+
files: ./release/latest/sudoMagicSave.tox

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
scripts/__pycache__/
3+
4+
release/
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"folders": [
3+
{
4+
"name": "Automation",
5+
"path": "../.github/"
6+
},
7+
{
8+
"name": "Build Scripts",
9+
"path": "../Scripts/"
10+
}
11+
],
12+
"settings": {}
13+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"folders": [
3+
{
4+
"name": "TD Save External",
5+
"path": "../TouchDesigner"
6+
}
7+
],
8+
"settings": {}
9+
}

README.md

Lines changed: 193 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,193 @@
1-
# TD-TOX-Saver
1+
# TD-TOX-Saver
2+
*a simple save external tox and text helper*
3+
[matthew ragan](matthewragan.com) | [SudoMagic](sudomagic.com)
4+
5+
## TouchDesigner Version
6+
* 099 2023.11880
7+
8+
## TOX Version
9+
10+
* 1.8.x
11+
12+
## OS Support
13+
14+
* Windows 10
15+
* macOS
16+
17+
## Summary
18+
Working with git and TouchDesigner isn't always an easy process, but it's often an essential part of the process of tracking your work and collaborating with others. It also encourages you to begin thinking about how to make your projects and components more modular, portable, and reuseable. Those aren't always easy practices to embrace, but they make a big difference in the amount of time you invest in future projects. It's often hard to plan for the gig in six months when you're worried about the gig on Friday - and we all have those sprints or last minute changes.
19+
20+
It's also worth remember that no framework will ever be perfect - all of these things change and evolve over time, and that's the very idea behind externalizing pieces of your project's code-base. An assembly of concise individually maintainable tools is often more maintainable than [rube golbergian](https://en.wikipedia.org/wiki/Rube_Goldberg) contraption - and while it's certainly less cool, it does make it easier to make deadlines.
21+
22+
So, what does all this have to do with saving external tox files? TOX files are the modules of TouchDesigner - they're component operators that can be saved as individual files and dropped into any network. These custom operators are made out of other operators. In 099 they can be set to be private if you have a pro license - keeping prying eyes away from your work (if you're worried about that).
23+
24+
That makes these components excellent candidates for externalization, but it takes a little extra work to keep them saved and sycned. In a perfect world we would use the same saving mechanism that's employed to save our TOE file to also save any external file, or better yet, to ask us if we want to externalize a file. That, in fact, is the aim of this TOX.
25+
26+
## Supported File Types
27+
* `.tox`
28+
29+
30+
# Parameters
31+
![base save and pars](assets/base_save_and_pars_v2.PNG)
32+
33+
## Save Settings
34+
35+
### Log to Texport
36+
37+
If you want to track when and where your external files are being saved, or if you're worried that something might be going wrong, you can turn on the `Logtotextport` parameter to see the results of each save operation logged for easy view and tracking.
38+
39+
### Include About Page
40+
41+
This will add a page to your externalized TOX that adds additional support information:
42+
43+
* TD Version - the version of TouchDesigner that the TOX was saved with
44+
* TD Build - the build of TouchDesigner that the TOX was saved with
45+
* TOX Version - an auto incrementing version number whose patch increment will be automatically updated with each save
46+
* Last Saved - a date stamp with the date and time from the last TOX save
47+
48+
## Colors
49+
50+
### TouchDesigner
51+
52+
#### Default Color
53+
54+
The default color is set as a read-only parameter used to reset the network worksheet background color. This is used in conjunction with the following two parameters to provide visual indicators for when a save or load operation has happened.
55+
56+
#### BG Color
57+
This is the color that the network background will flash when you externalize a TOX - it's the visual indicator that your tox has been successfully saved.
58+
59+
#### External Op
60+
This is the color of your operator after it's been externalized.
61+
62+
### Python
63+
64+
#### Default - any external file
65+
66+
All DATs that have been externalized can be set to this color so you can more quickly identify external files.
67+
68+
#### Python Extension - any file tagged `EXT`
69+
If an externalized Python file has been tagged with `EXT` this color will be applied to the Text DAT. This is a helpful mechanic for color coding any DATs that you are using as extensions
70+
71+
#### Python Module - any file tagged `MOD`
72+
73+
If an externalized Python file has been tagged with `MOD` this color will be applied to the Text DAT. This is a helpful mechanic for color coding any DATs that you are using as modules on demand
74+
75+
### Comments
76+
77+
Comments are a super helpful addition to TouchDesigner networks, but it can be hard to know how to use them. Borrowing from the work done in the [ToDoTree Extension for VS Code](https://marketplace.visualstudio.com/items?itemName=Gruntfuggly.todo-tree) this section of parameters aims to help you color code your comments. Prepend any comment's header with a `#` and one of the identifiers:
78+
79+
* Bug - `#BUG`
80+
* Hack - `#HACK`
81+
* Fix - `#FIXME`
82+
* Note - `#NOTE`
83+
84+
Colors associated with these parameters will then be used to set the color of the comment in your network.
85+
86+
![base save and pars](assets/comment-colors.png)
87+
88+
## Short Cuts
89+
90+
### `ctrl+w`
91+
The way you'll use this tox is just as if you were working as you might normally. Only, when you hit `ctrl + w`, if you're inside of a COMP that hasn't been saved externally, you'll be asked if you want to externalize that module. If you select `yes` you'll next be asked where you want to save that module. This module will then create a folder that has the same name as your component, and save the tox inside of that folder (the tox will also have the same name as the component). Better yet, this module will auto-populate the path to the external tox with the location you've selected. When you press `ctrl + w` again it will warn you that you're about to over-write your tox. If you confirm that you want to replace your tox, it will save the updated version right where your previous tox was located.
92+
93+
### `ctrl+shift+w`
94+
In addition to saving a single file, you can also see all the components that you've changed by using this shortcut. This will open a menu of all of your external COMPs.
95+
96+
## All TOX Components - floating window
97+
98+
![create-a-dir](assets/all-tox-comps-window.png)
99+
100+
It's not always easy to remember which `COMPs` have been externalized, or to get to them quickly. The `ctrl+shift+w` hot key opens a floating window that can help you manage your external TOX files. This floating window provides a quick view of a number of different attributes for your external files. Here you can see the name, version, and last saved date for your `TOX`. There are also four quick action buttons you might use.
101+
102+
:eye: - jump your current TD network pane to be inside of this component. If you want a fast way to navigate to parts of your TouchDesigner network this can be very helpful.
103+
104+
:floppy_disk: - Save your TOX. You can use this button to save your TOX instead of using `ctrl+w` from inside the Component
105+
106+
:open_file_folder: - open your file explorer to see where this TOX is located on your computer.
107+
108+
:recycle: - reload the TOX in your network. This is equivalent to clicking on the `reload` parameter for your `COMP`
109+
110+
:snake: - re-init your extension. If your TOX has has an extension, you can use this button to quickly reinitialize it without needing to navigate to your component.
111+
112+
# Suggested Workflow
113+
114+
115+
116+
Add the `base_save` `TOX` file into your network. You only need to add one. Save your whole project file (your `.toe`). My recommendation is create a folder for your project somewhere on your computer and to save your `.toe` file in this directory. This will make it easier to collect all of your related files close to your project file. I like keeping my `TOX` files in their own directory. I usually create a folder called something like `td-modules` where I'll save my `TOX` files.
117+
118+
When you're in any COMP in TouchDesigner use the hot-key `ctrl + w`
119+
120+
## Externalization Only
121+
1. Create a directory for your project
122+
![create-a-dir](assets/create-project-dir.PNG)
123+
124+
2. Open TouchDesigner and save your `.TOE` file in your new directory **this is an important step** - saving your project makes sure that the member `project.folder` correct points to your `.TOE` file.
125+
![create-a-project](https://github.com/raganmd/touchdesigner-save-external/blob/master/assets/create-project-toe.PNG?raw=true)
126+
127+
3. Drop the `base_save.tox` from `touchdesigner-save-external\release` into your network - I'd recommend doing this at the root of your project, or in a place in your project specifically designed to hold other tools. I like to create a base called tools where I keep all the things that I use for development, or that any machine might need (meaning when you're thinking on a single `.TOE` file that's configured based on a machine's role)
128+
![drag-into-network](assets/drag-into-network.gif)
129+
130+
4. Create a new component, and navigate inside of this new COMP.
131+
![create-a-new-comp](assets/create-new-comp.PNG)
132+
133+
5. Use `ctrl + w` to save your project as you might usually.
134+
6. Notice that you're now prompted to save your COMP externally - select `Yes`
135+
![ctrl-s](assets/prompt-to-externalize.PNG)
136+
137+
7. Create a new folder in your project folder called `td-modules` (this is my suggestion, though you can use any name you like). Navigate into this folder and compete the save process.
138+
![create-a-modules-dir](assets/create-td-modules-dir.PNG)
139+
140+
8. Check finder (macOS) or explorer (windows) to see that in `td-moduels` you now have a new directory for your tox, and inside of that directory is your saved tox file.
141+
![newly-made-dir](assets/new-save-dir.PNG)
142+
![newly-saved-tox](assets/new-save-tox.PNG)
143+
144+
9. Notice that the color of your tox has changed so you know that it's externalized.
145+
146+
10. Continue to work and save. Note that when you use `ctrl+w` both your project and your tox are saved. If you happen to create an external `.TOX` inside of a tox that's already externalized, you'll be prompted to save both the `parent()` and the current COMP or just the current COMP.
147+
148+
## Using Git
149+
1. Create a new repo
150+
2. Clone / Initialize your repo locally
151+
3. Open TouchDesigner and save your `.TOE` file in your repo
152+
![create-a-project](assets/create-project-toe.PNG)
153+
154+
4. Drop the `base_save.tox` from `touchdesigner-save-external\release` into your network - I'd recommend doing this at the root of your project, or in a place in your project specifically designed to hold other tools. I like to create a base called tools where I keep all the things that I use for development, or that any machine might need (meaning when you're thinking on a single `.TOE` file that's configured based on a machine's role)
155+
![drag-into-network](assets/drag-into-network.gif)
156+
157+
5. Create a new component, and navigate inside of this COMP.
158+
![create-a-new-comp](assets/create-new-comp.PNG)
159+
160+
6. Use `ctrl + w` to save your project as you might usually.
161+
7. Notice that you're now prompted to save your COMP externally - select `Yes`
162+
![ctrl-s](assets/prompt-to-externalize.PNG)
163+
164+
8. Create a new folder in your project folder called `td-modules` (this is my suggestion, though you can use any name you like). Navigate into this folder and compete the save process.
165+
![create-a-modules-dir](assets/create-td-modules-dir.PNG)
166+
167+
9. Check finder (macOS) or explorer (windows) to see that in `td-moduels` you now have a new directory for your tox, and inside of that directory is your saved tox file.
168+
![newly-made-dir](assets/new-save-dir.PNG)
169+
![newly-saved-tox](assets/new-save-tox.PNG?)
170+
171+
10. Notice that the color of your tox has changed so you know that it's externalized.
172+
![external-tox-color](assets/external-tox-color.PNG)
173+
174+
11. Continue to work and save. Note that when you use `ctrl+w` both your project and your tox are saved. If you happen to create an external `.TOX` inside of a tox that's already externalized, you'll be prompted to save both the `parent()` and the current COMP or just the current COMP.
175+
12. Commit and push your work.
176+
177+
# Additional Considerations and Suggestions
178+
At this point, you might have guess that this kind of approach works best in well structured projects. Some suggestions for organization and approach:
179+
* Think about Order and Structure - while I've structured projects lots of different ways, it's worth finding a file structure that you like and sticking with it. That might be a deeply nested structure (watch out that'll bite you if you get too deep - at least on windows), or it might be something more flat. Regardless, think about a structure and stay with it.
180+
* Make Small Simple Tools - to the best of your ability, try to make sure your modules are independent islands. That's not always possible, but if you can think carefully about creating dependencies, you'll be happier for it. Use custom parameters on your components to keep modules independent from one another. Use select operators, or In's and Out's to build connections.
181+
* Reuse that TOX - while this approach is fancy and fun, especially when working with git, it's also about making your future self happier. Thank carefully about how you might make something re-usable and portable to another project. The more you can think through how to make pieces that can easily move from project to project the more time you can spend on the fun stuff... not on the pieces that are fussy and take lots of time.
182+
183+
# An Example Project
184+
In the folder called `sample_project` open the `Sample_project.toe` to see how this might work.
185+
186+
# Credits
187+
### Inspired by the work of:
188+
[Anton Heestand](http://hexagons.se/)
189+
[Willy Nolan](https://github.com/computersarecool)
190+
I've had the great fortune of working with both of these find developers. I regularly use an externalization tool authored by these two developers, and this TOX is partially inspired by their work. Many thanks for a tool that keeps on working and makes using GIT with TouchDesigner something that's reasonable.
191+
192+
### Icons
193+
[Material Design Icons by Google](https://material.io/tools/icons/?icon=save_alt&style=baseline)

TouchDesigner/.env

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
# define file and version
3+
file=./project.toe
4+
tdVersion=2023.12120
5+
6+
# Project env vars
7+
SM_ROLE=standby
8+
SM_PUBLIC=_public
9+
10+
# TOUCH VARS
11+
12+
# Set the variable TOUCH_WEB_LAUNCH to use select a different web browser
13+
# to use when TouchDesigner launches a browser for things such as help.
14+
# e.g set TOUCH_WEB_LAUNCH to "firefox.exe" to use Firefox for help.
15+
#TOUCH_WEB_LAUNCH=firefox.exe
16+
17+
# Set a path of the external text editor you wish to use with TouchDesigner.
18+
#TOUCH_EDITOR=vscode.exe
19+
20+
# Set to the path of the external table editor you wish to use with TouchDesigner.
21+
# If it is not defined, the text editor will be used.
22+
#TOUCH_TABLE_EDITOR=csvhero.exe
23+
24+
# Set to 1 to force the TouchDesigner text console to always open.
25+
#TOUCH_TEXT_CONSOLE=1
26+
27+
# Disables the saving of a CrashAutoSave.toe and .dmp dump file when
28+
# TouchDesigner crashes. The confirmation dialog will also be be suppressed.
29+
#TOUCH_QUICK_CRASH=1
30+
31+
# Disables all TouchDesigner crash warnings and dialogs.
32+
#TOUCH_DISABLE_CRASH_HANDLERS=1
33+
34+
# Setting this variable lets you force MIDI data coming in from either of the
35+
# two input ports to look like it's a certain MIDI channel number.
36+
# Set the variable to 0 2 4 forces Input 2 to be mapped to MIDI channel 2,
37+
# and Output to MIDI Channel 4.
38+
#TOUCH_MIDI_CHAN_OVERRIDE
39+
40+
# Set to 1 to allow TouchDesigner to startup without checking for software updates.
41+
#TOUCH_NO_UPDATE_CHECK=1
42+
43+
# Enables support for 10-bit color. Requires a high color LDC monitor with a DisplayPort connector.
44+
#TOUCH_10_BIT_COLOR=1
45+
46+
# TouchDesigner outputs every rendered frame twice.
47+
# This is useful when rendering a project at half the refresh rate of your displays,
48+
# as it allows TouchDesigner to reliably perform the frame doubling.
49+
#TOUCH_DOUBLE_DRAW

TouchDesigner/_start.ps1

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
param($env)
2+
3+
4+
function LoadEnvVarObject{
5+
param($envFile)
6+
7+
# Creates a powershell object that holds all of the vars in the .env file passed in.
8+
$envObject = Get-Content $envFile | Out-String | ConvertFrom-StringData
9+
foreach ($property in $envObject.Keys) {
10+
Set-Item "Env:$property" $($envObject.($property))
11+
}
12+
return $envObject
13+
}
14+
15+
function ClearEnvVarObject {
16+
param($envFile)
17+
18+
# Creates a powershell object that holds all of the vars in the .env file passed in.
19+
$envObject = Get-Content $envFile | Out-String | ConvertFrom-StringData
20+
foreach ($property in $envObject.Keys) {
21+
Set-Item "Env:$property" ""
22+
}
23+
}
24+
25+
function GetTouchDesigner {
26+
param($version)
27+
try {
28+
$command = (get-itemproperty -ErrorAction Stop Registry::HKEY_CLASSES_ROOT\TouchDesigner.$version\shell\open\command)."(default)"
29+
return $command.replace(' "%1"', "")
30+
}
31+
catch {
32+
echo "TouchDesigner.$version is not installed on this machine."
33+
echo "Install it here: https://download.derivative.ca/TouchDesigner.$version.exe"
34+
exit
35+
}
36+
}
37+
38+
function RunAsynchronous {
39+
param (
40+
$open_command,
41+
$project_file
42+
)
43+
echo "Running asynchronously..."
44+
Start-Process $open_command $project_file
45+
}
46+
47+
function RunSynchronous {
48+
param (
49+
$open_command,
50+
$project_file
51+
)
52+
echo "Running synchronously..."
53+
Start-Process $open_command $project_file -Wait
54+
}
55+
56+
echo environment:$env
57+
58+
$config = LoadEnvVarObject $env
59+
$tdExe = GetTouchDesigner $config.tdVersion
60+
61+
if($config.SM_BUILD){
62+
echo "building project..."
63+
RunSynchronous $tdExe $config.file
64+
} else {
65+
echo ""
66+
RunAsynchronous $tdExe $config.file
67+
}
68+
69+
ClearEnvVarObject $env

TouchDesigner/dev.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
3+
powershell.exe -file _start.ps1 -env .env

TouchDesigner/project.toe

113 KB
Binary file not shown.
430 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)