Hi everyone,
I’m running into an issue where my File Out DAT saves perfectly into a subfolder when running in TouchDesigner, but when I open the exact same .toe file in TouchPlayer, it completely ignores the subfolder and dumps the files into the root of the project directory.
I’ve built a minimal toy example to debug this and have done some deep investigation, but I’m completely stuck on why TouchPlayer is rejecting valid absolute paths.
The Setup (Toy Example)
-
I have a Script DAT with a custom parameter for a subfolder name (e.g.,
children) and an increment counter for file name. -
This feeds into a
File Out DATwith the following expression in the File parameter:project.folder + '/' + op('script1').par.Path + '/' + str(op('script1').par.Increment) + '.txt'
What I’ve Tried:
- Relative Paths: Initially, I used a standard relative path (
children/1.txt). In TouchDesigner it works, but in TouchPlayer it saves to the project root. - Absolute Paths: I explicitly switched to using
project.folderto enforce an absolute path. Even though the expression evaluates to a perfectly valid absolute path (e.g.,C:/Users/Name/Desktop/test/children/1.txt), TouchPlayer still strips thechildrensubfolder and saves it asC:/Users/Name/Desktop/test/1.txt. - Parameter Types: I changed the custom parameter type from Folder to String just in case TouchPlayer was incorrectly validating the Folder parameter on startup. It still saves to the project root.
Both 1 and 2 has been done using an existing folder.
The only workaround so far has been using the following script
import os
def onPulse(par):
if par.name == 'Save':
folder_name = par.owner.par.Path.eval()
increment = par.owner.par.Increment.eval()
# Build absolute directory path using project.folder
abs_dir = os.path.join(project.folder, folder_name)
# Ensure the folder actually exists!
os.makedirs(abs_dir, exist_ok=True)
file_path = os.path.join(abs_dir, f"{increment}.txt")
target_dat = op('out1') # The DAT containing the text
if target_dat:
# Append using native Python
with open(file_path, 'a') as f:
f.write(target_dat.text)
return
Yet, I need to use this in a project that saves long txt files (10k rows approx in total) in chunks and I would rather prefer to rely on native operators instead of Python to ensure they can keep up with writing.
I’ve attached my toy_example.zip to reproduce the issue. Any insights would be hugely appreciated, since I’m stuck in the investigation!
toy_example.zip (73.3 KB)
I’m on Windows 11 and using TD version 2025.31760
