Experimental:Run Command Examples

This page is also posted as a tutorial with an attached example file on the Derivative website here.

The following examples are meant to be pasted into a textDAT. You can then run them (RMB>Run Script or select and ctrl-R) and see the results in a textport.

The Run Command

The run command allows you to run a string as a Python statement. It has many a number of options available as to how to run the command. The most powerful feature of these options is to allow you to delay the execution for a certain number of frames or milliseconds. Below is the full wiki documentation for run. This tutorial will go through all the options one by one.

run(script, arg1, arg2..., endFrame=False, fromOP=None, asParameter=False, group=None, delayFrames=0, delayMilliSeconds=0, delayRef=me)Run:

Run the script, returning a Run object which can be used to optionally modify its execution. This is most often used to run a script with a delay, as specified in the delayFrames or delayMilliSeconds arguments.

  • script - A string that is the script code to execute.
  • arg - (Optional) One or more arguments to be passed into the script when it executes. They are accessible in the script using a tuple named args.
  • endFrame - (Keyword, Optional) If True, the execution will be delayed until the end of the current frame.
  • fromOP - (Keyword, Optional) Specifies an optional operator from which the execution will be run relative to.
  • asParameter - (Keyword, Optional) When fromOP used, run relative to a parameter of fromOP.
  • group - (Keyword, Optional) Can be used to specify a string label for the group of Run objects this belongs to. This label can then be used with the td.runs object to modify its execution.
  • delayFrames - (Keyword, Optional) The number of frames to wait before executing the script.
  • delayMilliSeconds - (Keyword, Optional) The number of milliseconds to wait before executing the script. This value is rounded to the nearest frame.
  • delayRef - (Keyword, Optional) Specifies an optional operator from which the delay time is derived. You can use your own independent time component or op.TDResources, a built-in independent time component.

Running A Simple Script

At its most basic, run allows you to execute a string as a Python script. The following is exactly the same as if you had executed the script argument without wrapping it in the run command.

run(print("hello, world"))