Project Class

From TouchDesigner 099 Wiki

The Project class describes the current session. It can be accessed with the project object, found in the automatically imported td module.

Members

folder (Read Only) The folder at which the project resides.
name (Read Only) The filename under which the project is saved.
saveVersion (Read Only) The App version number when the project was last saved.
saveBuild (Read Only) The App build number when the project was last saved.
saveOsName (Read Only) The App operating system name when the project was last saved.
saveOsVersion (Read Only) The App operating system version when the project was last saved.
paths (Read Only) A dictionary which can be used to define URL-syntax path prefixes. This dictionary is saved and loaded in the toe file. Example: Set project.paths['movies'] = 'C:/MyMovies', and reference with parameter expression: movies://butterfly.jpg.
cookRate Get or set the maximum number of frames processed each second. In general you should not need to use this. It is preferred to look at the FPS of the root component to know the cooking rate. Individual components may have their own rates, specified by rate.

Example:
a = project.cookRate # get the current cook rate
project.cookRate = 30 # set the cook rate to 30 FPS
Note: This is displayed and set in the user interface at the bottom-left: the "FPS" field.

realTime Get or set the real time cooking state. When True, frames may be skipped in order to maintain the cookRate. When False, all frames are processed sequentially regardless of duration. This is useful to render movies out using the Movie File Out TOP without dropping any frames for example.

Example:
a = project.realTime
project.realTime = False # turn off real time playback.

isPrivate (Read Only) True when the project networks cannot be directly viewed.
isPrivateKey (Read Only) True when the private networks are accessible by a pass phrase.

Methods

load(path)

Load a specific .toe file from disk.
  • path - (Optional) The path of the file to load. If not specified, loads the default toe file, as specified in preferences.
   project.load('test_demo.toe')

save(path, saveExternalToxs=False)bool

Save the current session to disk. Returns True if a file was saved, False otherwise (eg, if the file exists, and when prompted, the user selects to not overwrite).
  • path - (Optional) If not provided the default/current filename is incremented and used. The current file is project.name under folder project.folder.
  • saveExternalToxs - (Keyword, Optional) If set to True, will save out the contents of any COMP that references an external .tox into the referenced .tox file.
   project.save('test_demo.toe')
   project.save()


quit(force=False, crash=False)

Quit the project.
  • force - (Keyword, Optional) If set to True, unsaved changes will be discarded without prompting.
  crash - (Keyword, Optional) If set to True, the application will terminate unexpectedly. This is used for system testing.
   project.quit()  #quit project, possibly prompting for unsaved changes if 'Prompt to Save on Exit' in Preferences dialog is enabled.
   project.quit(force=True)  #quit project immediately.


addPrivacy(key)bool

Add privacy to a toe file with the given key.
Privacy can only be added to toes that currently have no privacy, and are using a Pro license.
  • key - The key phrase. This should resolve to a non-blank string.
   project.addPrivacy('secret')

removePrivacy(key)bool

Completely remove privacy from a toe file.
  • key - The current privacy key phrase.
   project.removePrivacy('secret')

accessPrivateContents(key)bool

Gain access to a private file. The file will still be private the next time it is saved or re-opened.
  • key - The current privacy key phrase.
   project.accessPrivateContents('secret')


stack()str

Formatted contents of current cook and parameter evaluation stack.
   print(project.stack())

pythonStack()str

Formatted contents of current python stack.
   print(project.pythonStack())