The tdu module is a generic utility module containing all miscellaneous functions that don't refer specifically to TouchDesigner data structures. tdu is imported by default when the application launches.
dict (Read Only):
A dictionary of all supported file types, organized by category.# example of various file types accepted by Movie File In TOP tdu.fileTypes['movie'] tdu.fileTypes['image']# other file types tdu.fileTypes['audio']
Note: Acceptable file types can be both uppercase and lowercase, so if
suffixis a suffix string, you need to force it to lowercase by using
suffix.lower():for suffix.lower() in tdu.fileTypes['movie']: print(suffix)
tdu.Matrix (Read Only):
The Matrix definition class.
tdu.Position (Read Only):
The Position definition class.
tdu.Vector (Read Only):
The Vector definition class.
tdu.Dependency (Read Only):
The Dependency definition class.
tdu.PathInfo (Read Only):
The PathInfo object takes a file path and has a few utility properties to provide additional information. It is derived from str, so will work as a Python string, but can be differentiated from a regular string by using
Utility properties include:
- path: filepath string
- ext: string after and including "."
- fileType: the TD filetype (from tdu.fileTypes)
- absPath: the absolute path to filepath
- dir: the containing directory of filepath
- exists: exists in file-system
- isDir: is a directory in the file-system
- isFile: is a file in the file-system
tdu.ArcBall (Read Only):
The ArcBall definition class.
Return a random value in the range [0.0, 1.0) given the input seed value. That is, it will never return 1.0, but it may return 0.0. For a given seed, it will always return the same random number. The seed does not need to be a number. If the seed is not numeric, it resolves it to its string representation to produce a unique value. In the case of OPs for example, its string representation is a constant path. Thus one can produce a unique random value for each OP which remains the same for that OP each time you reload TouchDesigner.tdu.rand(me) # return a specific random number based on path tdu.rand(5) # return a specific random number tdu.rand(absTime.frame) # return a different number every frame
tdu.clamp(inputVal, min, max)→
Returns the input value clamped between min and max values. Arguments can be any type that can be compared (float, int, str, etc).
tdu.remap(inputVal, fromMin, fromMax, toMin, toMax)→
Returns the input value remapped from the first range to the second.tdu.remap(0.5, 0, 1, -180, 180) #remap slider value to angle range
Returns the beginning portion of the string occurring before any digits. The search begins after the last slash if any are present.
- str - The string to extract the base name from.tdu.base('arm123') # returns 'arm' tdu.base('arm123/leg456') # returns 'leg'
Note this method will work on any string, but when given a specific operator, its more efficient to use its local base member:n = op('arm123/leg456') b = n.base #returns 'leg'
int or None:
Returns the numeric value of the last consecutive group of digits in the string, or None if not found. The search begins after the last slash if any are present.tdu.digits('arm123') # returns 123 tdu.digits('arm123/leg456') # returns 456 tdu.digits('arm123/leg') # returns None
Note this method will work on any string, but when given a specific operator, its more efficient to use its local digits member:n = op('arm123/leg456') d = n.digits # returns 456
Returns a version of the string suitable for an operator name. Converts illegal characters to underscores.tdu.legalName('a#bc def') # returns 'a_bc_def'
Expand the file path, using project.paths, the current folder, and any other relevant information.tdu.expandPath('movies:/test.bmp') # looks at project.paths for 'movies' entry.
Collapse the file path, using project.paths, the current folder, and any other relevant information.tdu.collapsePath('C:/downloads/test.bmp') # looks at project.paths for any entries matching the path, and removes current folder from prefix.
- path - The path to be shortened.
- asExpression - (Keyword, Optional) If True, result can be used as an expression, including App Class members and quoted strings.
Return a list from a space separated string, allowing quote delimiters.
- string - Any Python object, as it will be evaluated as str(string). Parameters will work.
- eval - (Keyword, Optional) If True convert any valid Python literal structures: strings, numbers, tuples, lists, dicts, booleans, and None.split('1 2.3 None fred "one \'2\'" "[1,2]"') #yields ['1', '2.3', 'None', 'fred', "one '2'", '[1, 2]'] split('1 2.3 None fred "one \'2\'" "[1,2]"', True) #yields [1, 2.3, None, 'fred', "one '2'", [1, 2]]
his function prints the current python stack trace. It passes any additional arguments to the built in traceback.print_stack() method. The printStack method has been customised to provide additional information for TouchDesigner operators.
- file - (Optional) Where the printed output is directed. Defaults to the standard output stream, which is mirrored to the Textport.tdu.printStack() tdu.printStack(file=op('text1')) # redirect to a specific DAT
Returns a set of values based on the input calibration data. This Method is not necessary anymore due to the inclusion of openCV in TouchDesigner. Refer to OpenCV Documentation
An Operator Family that creates, composites and modifies images, and reads/writes images and movies to/from files and the network. TOPs run on the graphics card's GPU.
is the procedural mechanism in TouchDesigner, where if one piece of data changes, it automatically causes other operators and expressions to re-cook.
A dialog box in which commands and scripts can entered manually. Script errors and python
print() messages are also output to the textport.