TDResources is a component containing system resources for TouchDesigner, some of which are available for use in your projects. Access TDResources using its Global OP Shortcut:
op.TDResources. Note: Access to these resources will be maintained in future versions of TouchDesigner, but the look of them may change. For example, the system popMenu will always be available, but the colors and font may change.
The system pop-up menu, which is a clone of popMenu, is available via
op.TDResources.PopMenu.Open(...). It is commonly used for RMB option menus and has 2 layers of sub-menus available for use as well. Example code:
op.TDResources.PopMenu.Open(['Go', 'Stop'], callback=debug, callbackDetails=['test'])
For full documentation, see Palette:popMenu and PopMenu Custom COMP Examples.
Button Pop-Up Menuedit
The system button pop-up menu, which is also a clone of popMenu, is available via
op.TDResources.ButtonPopMenu. It is commonly used for menus that pop up when a button is pressed and you want to align the menu to that button, but can technically be used to align a menu to any Panel Component. It does not have sub-menus available.
The difference between this and the system pop-up menu above is that it is meant to be attached to a button and the Buttoncomp, Horizontalattach, and Verticalattach parameters must be set before calling
Open. Example code:
buttonPopMenu = op.TDResources.ButtonPopMenu buttonPopMenu.par.Buttoncomp = op('/myButtonPanel') buttonPopMenu.par.Horizontalattach = 'Left' buttonPopMenu.par.Verticalattach = 'Top' buttonPopMenu.Open(['Go', 'Stop'], callback=debug, callbackDetails=['test'])
For popMenu documentation, see Palette:popMenu and PopMenu Custom COMP Examples.
The system pop-up dialog, a clone of popDialog, is available via
op.TDResources.PopDialog. It is used for simple pop-up dialogs with up to four options and an optional text entry box.
There is a nice code example of this here.
For full documentation, see Palette:popDialog, popDialog Extension and PopDialog Custom COMP Examples.
There is mouse information in a CHOP available for system use in
op.TDResources.MouseCHOP. This can be used to get the mouse state without needing your own Mouse In CHOP. You can see all the channels and access this information by using a Select CHOP. You can also access it directly using code:
mouse = op.TDResources.MouseCHOP normalizedMouseX = mouse['tx'] absoluteMouseX = mouse['abs_mouse_x'] leftButton = mouse['left_button']
There is a simple Web Client DAT interface available via
op.TDResources.WebClient. You can request data via Python by calling the following function:
op.TDResources.WebClient.Request(callback, url, method *args)
callback- function to be called with reply. It should have the following arguments: statusCode, headerDict, data, id. These will all be None (except id) if the request times out.
url- The URL string to send the HTTP request to.
method- The HTTP request method as a string. Must be one of: "GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", or "PATCH"
*args- The remaining arguments will be passed directly to the web client and all options can be found in the documentation for the
requestfunction here: WebclientDAT Class