Python Classes and Modules

From TouchDesigner Documentation
Jump to: navigation, search

The following list of important Python classes and modules is roughly grouped together by subject.

Python Reference has an alphabetical list of all TouchDesigner Python pages on this wiki.

Operator Related Classes[edit]

The following classes are Python interfaces for operators and objects that operators use. Individual operator classes (e.g. TextTOP Class and RampTOP Class) are not listed but do exist in the td module, and links to each can be found here or by clicking on the Python Help button in their parameter dialog. These classes are found in the td module so do not need to be imported.

Helper Classes[edit]

The following helper objects are part of the td module and can thus be accessed anywhere, including expressions, without imports (e.g. absTime.frame).

Standard Python Modules[edit]

The td module also automatically imports a number of helpful standard modules, allowing them to be accessed in expressions through their namespace (e.g. math.cos(math.pi)):

  • collections - container datatypes
  • enum - support for enumerations
  • inspect - inspect live objects
  • math - mathematical functions
  • re - regular expression operations
  • sys - OS specific data and functions
  • warnings - warning control

TouchDesigner Utility Modules[edit]

These modules contain extended Python utilities for use with TouchDesigner.

  • TDStoreTools - utilities for use with TouchDesigner's Storage and Dependency system. This module can be imported directly (import TDStoreTools).
  • TDFunctions (op.TDModules.mod.TDFunctions) - A variety of utilities for advanced Python coding in TouchDesigner. This module cannot be imported directly. Instructions for use is at the top of its wiki page.
  • TDJSON (op.TDModules.mod.TDJSON) - JSON utilities specific to TouchDesigner. This module cannot be imported directly. Instructions for use is at the top of its wiki page.

3rd Party Packages[edit]

The following 3rd party packages are automatically installed with TouchDesigner. They are not in the td module, so must be imported explicitly to be used in scripts. The name in parentheses is the actual package name used (e.g. to use OpenCV, write this at top of script: import cv2). For information on adding or installing other Python modules, see Importing Modules.

  • asn1crypto (asn1crypto) - Parsing and serializing ASN.1 structures
  • Authlib (authlib) - Library to build OAuth and OpenID Connect servers.
  • Certifi (certifi) - Root Certificates for validating the trustworthiness of SSL certificates while verifying the identity of TLS hosts
  • CFFI (cffi) - Interaction with C code
  • Chardet (chardet) - The Universal Character Encoding Detector
  • Cryptography (cryptography) - High level recipes and low level interfaces to common cryptographic algorithms
  • idna (idna) - Support for the Internationalised Domain Names in Applications (IDNA) protocol
  • jsonpath (jsonpath_ng) - JSONPath tools for accessing and altering JSON structures
  • MWParserFromHell (mwparserfromhell) - An easy-to-use and outrageously powerful parser for MediaWiki wikicode
  • NumPy (numpy) - Fundamental package for scientific computing with Python
  • OpenCV (cv2) - Open source computer vision.
  • ply (ply) - Parsing tools for lex and yacc.
  • Requests (requests) - The only Non-GMO HTTP library for Python, safe for human consumption
  • Requests OAuthlib (requests_oauthlib) - Easy-to-use Python interface for building OAuth1 and OAuth2 clients
  • urllib3 (urllib3) - HTTP client
  • PyYAML (yaml) - YAML parser and emitter

Installing Custom Packages and Modules[edit]

You can also install your own Python packages that are not included with TouchDesigner. For instructions, go here.

Any of the procedural data operators. OPs do all the work in TouchDesigner. They "cook" and output data to other OPs, which ultimately result in new images, data and audio being generated. See Node.

An Operator Family that contains its own Network inside. There are twelve 3D Object Component and eight 2D Panel Component types. See also Network Path.

An Operator Family which operate on Channels (a series of numbers) which are used for animation, audio, mathematics, simulation, logic, UI construction, and many other applications.

An Operator Family that reads, creates and modifies 3D polygons, curves, NURBS surfaces, spheres, meatballs and other 3D surface data.

is the procedural mechanism in TouchDesigner, where if one piece of data changes, it automatically causes other operators and expressions to re-cook.

TouchDesigner is a hierarchy of components. "root" is the top-most network in the hierarchy. The Path is simply /. A typical path is /project1/moviein1.