Docs Developer

VSCodeTools

VS Code integration: open externalized scripts, sync files and generate TouchDesigner type stubs.

⌨ Developer Toolbar button

Why use it

A text DAT is fine for ten lines and hard work for three hundred: no search across files, no autocomplete, no git diff. So extension code usually moves to VS Code, and that brings its own chores: a workspace for the project, a file path and Sync to File on every DAT, a sensible folder layout, and a way back before you hand the .toe to someone else.

VSCodeTools does those chores. One button opens the project's workspace in VS Code, one key syncs the DAT you are on to a properly named file, typing stubs make your extensions and TouchDesigner's Python autocomplete, and one pulse puts everything back into the .toe before you ship.

Features

  • Open the project in VS CodeOne click creates the project's workspace file and opens it in VS Code or Cursor.
  • Sync a DAT to a fileCtrl+Shift+E writes the DAT you are on to a file named after it, and from then on the DAT and the file stay in sync both ways.
  • File type and folder picked for youThe file extension comes from the DAT's language or contents, and an extension's script goes in a subfolder named after its COMP.
  • Choose the name and pathCtrl+Shift+Alt+E asks for the file's name and path before syncing.
  • Python typing stubsDeploys stubs for your extensions and TouchDesigner's built-in Python typings, so the editor autocompletes them, through an integration of Stubser.
  • Clear syncs before shippingDrops the syncs and the tool's tags for the selected DATs, a network, or the whole project, so the content lives in the .toe again.

How to use it

  1. Set VS Code (code.exe) or Cursor as the text editor in TouchDesigner's Preferences. That is the only requirement: with Auto-detect on, VSCodeTools takes the editor from there and names the workspace after the project file.
  2. Click the VSCodeTools button on the toolbar. The first time, it creates <project name>.code-workspace in the project folder (or uses a workspace file already there) and opens it in your editor. On Windows, when it finds the python.exe of an installed TouchDesigner, it also sets that as the workspace's Python interpreter. Open project in VSCode in quick-launch does the same, and Auto-open opens it every time the project starts.
  3. Go to a DAT you want to edit in VS Code, so it is the current operator, and press Ctrl+Shift+E (with Use Ctrl+Shift+E Shortcut on). Shift-click on the button and Externalize selected in quick-launch do the same. The DAT is written to a file, Sync to File is switched on, the DAT turns pink and it opens in your editor.
  4. Edit in VS Code. Every save updates the DAT in TouchDesigner, and changes made to the DAT in TouchDesigner are written to the file.

The button does a different job for each click:

  • Click: open the workspace.
  • Right-click: open VSCodeTools' parameters, where the editor and the workspace are set up.
  • Shift-click: sync the current DAT to a file.
  • Ctrl+Shift+Alt-click: the same, asking for the file's name and path first.
  • Alt-click: clear the sync of the selected DATs.
  • Middle-click: deploy stubs for the selected DATs and COMPs.

For opening a component's extension straight from the network, see OpenExt, which works hand in hand with a synced extension. There is also a video breakdown on YouTube.

Where the files go

  • Folder: files are written to Script Sync Base Folder, relative to the project folder. An extension's script gets a subfolder named after the COMP it belongs to, so the extension of mixer1 lands in <folder>/mixer1/.
  • Name: the operator's name.
  • File type: taken from the DAT's declared language, or from its contents when the language says nothing specific. Python becomes .py, a table .tsv, and a GLSL shader .vert or .frag (from _vert or _frag in the DAT's name, or from the shader itself) or .glsl. JSON, YAML, XML and HTML get their own extensions too. Anything unrecognised is saved as .py.

If a file of that name already exists, a dialog asks for another name: OK uses the name you typed, Overwrite syncs to the existing file, Cancel stops. To pick the name and path up front, press Ctrl+Shift+Alt+E or Ctrl+Shift+Alt-click the button.

Every DAT the tool syncs carries its tags (shown read-only as Tags on the Clear page). That is how the Clear page tells its syncs apart from files you set up by hand.

Autocomplete with stubs

Typing stubs tell your editor what your components and TouchDesigner's own Python contain, so it can autocomplete them. This part is an integration of AlphaMoonbaseBerlin's Stubser and typings.

  1. Once per project, pulse Install under TD Typings on the Stubs page. It writes TouchDesigner's built-in typings into a typings folder in the project, so td module members autocomplete. After a TouchDesigner upgrade, Force writes them again over the old ones.
  2. Select the COMPs whose extensions you are writing, or DATs, and pulse Deploy Stubs (or middle-click the button). Your editor can then autocomplete their members.
  3. To include members whose names start with _, switch on Private. Unpromoted decides whether the lowercase members, the ones not reachable straight off the COMP, are included.

Clearing a sync before you ship

A synced DAT reads its content from its file. Ship the .toe without the script files and it opens looking for files that are not there.

The Clear page puts the content back into the .toe. It drops the sync and this tool's tags at the scope you pick, from selected DATs through in current pane and in current pane and all children to all in project. Cleared DATs turn grey again, the files stay on disk, and each clear is one undo step. Only DATs carrying all of the tool's tags are touched, so a sync you set up by hand stays as it is.

Get it

Tick it on the install page and it installs with the rest of your setup and stays up to date.

Download FNS_VSCodeTools.tox Version 3.2.10, the tool on its own. It works in any project, and this copy never updates itself.

Where it appears

Shortcuts

  • Ctrl+Shift+E / Ctrl+Shift+Alt+E

Parameters

Its Registry page comes from FNS_ConfigRegistry and FNS_ToolbarRegistry.

Custom

ControlType / defaultWhat it does
Code.exeCodeexe file pathempty Path to your editor's executable (code.exe, or Cursor). Auto-detect fills it from TouchDesigner's Preferences text-editor setting, so you usually never touch it.
WorkspaceWorkspace file pathempty Path to the .code-workspace file this project opens. Auto-detect names it after the project file.
Auto-detectAutodetect on / offoff Fill Code.exe and Workspace automatically: the editor from TouchDesigner's Preferences, the workspace from the project's name. On by default; turn it off to pin either by hand.
Auto-openStartup on / offoff Open the workspace in your editor as soon as the project starts.
OpenOpen button Open the workspace now. If none exists yet, one is created in the project root and opened.
Sync settings
Script Sync Base FolderFolder folder pathempty Where synced scripts are written, relative to the project root. An extension script also gets a subfolder named after the COMP it belongs to.
Use Ctrl+Shift+E ShortcutShortcutactive on / offoff Enable the sync shortcut: it externalizes the selected DAT into the folder above, named after the operator. Add Alt to force the dialog and choose another name or path.
Sync File SelectedExternalizeselected button Sync the selected DAT to a file now, the same action as the shortcut.

Clear

ControlType / defaultWhat it does
TagsTagsread-only textempty Read-only. The tags this tool puts on every DAT it syncs, and looks for when clearing: an operator must carry all of them to count as synced.
Clear Synced Scripts... (undoable)
selected DATsClearselected button Drop the sync and this tool's tags from the selected DATs, so their content lives in the project file again.
in current paneClearcomp button Drop the sync and tags from every DAT in the current pane, not descending into children.
in current pane and all childrenClearcompchildren button Drop the sync and tags from every DAT in the current pane and all of its children.
all in projectClearall button Drop the sync and tags from every synced DAT in the project. Do this before shipping a .toe without its script files. Otherwise it opens looking for files that are not there.

Stubs

ControlType / defaultWhat it does
Stubs TagsTags2read-only textTDExtension FNS_externalized Read-only. The tags that mark an operator as stub-bearing, the same way the Clear tab's tags mark a synced DAT.
PrivatePrivate on / offoff Include methods and attributes whose names start with '_' in the generated stubs.
UnpromotedUnpromoted on / offon Include unpromoted members, the lowercase ones that are not reachable straight off the COMP, in the generated stubs.
Deploy StubsDeploystubs button Generate Python typing stubs for the selected DATs, or for the selected COMPs' extensions, so your editor can autocomplete them.
TD Typings
InstallInstall button Install TouchDesigner's own built-in Python typings, so td module members autocomplete in your editor.
ForceForce button Install the built-in typings even when they are already there, overwriting them. Use it after a TouchDesigner upgrade.

About

ControlType / defaultWhat it does
READMEOpen2 button Open this tool's README.