This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this will return a list of cell objects | |
raw_col_data = op("table1").col(0) | |
print(raw_col_data) | |
# we can then create a list of only the values with a comprehension | |
col_as_list = [each.val for each in raw_col_data] | |
print(col_as_list) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
par_map = {} | |
target = op("constant2") | |
for each_par in target.pars('name*'): | |
par_map[each_par.val] = f"value{tdu.digits(each_par.name)}" | |
print(par_map) | |
target.store("par_map", par_map) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
par_map = {} | |
target = op("constant2") | |
for each_par in target.pars('name*'): | |
par_map[each_par.val] = f"value{tdu.digits(each_par.name)}" | |
print(par_map) | |
target.store("par_map", par_map) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def reset_defaults(touch_designer_operator:OP) -> None: | |
# get our custom parmameters for an operator | |
custom_pars = touch_designer_operator.customPars | |
# loop through all pars and reset them to their defaults | |
for each_par in custom_pars: | |
touch_designer_operator.par[each_par.name] = each_par.default | |
# to use this function, you pass in an operator - below is an example of how | |
# to reset the custom pars on an operator called `base1` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# me - this DAT | |
# scriptOp - the OP which is cooking | |
import cv2 | |
import numpy | |
import requests | |
# press 'Setup Parameters' in the OP to call this function to re-create the parameters. | |
def onSetupParameters(scriptOp): | |
page = scriptOp.appendCustomPage('Custom') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@REM Example of how to install a collection of python externals | |
@REM into a project directory | |
@REM set python install destination | |
set FILEDEST=%~dp0python-libs | |
@REM pip install commands for the python version for TouchDesigner | |
@REM This assumes we've already installed the coresponding version of python | |
@REM on Windows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# me - this DAT | |
# scriptOp - the OP which is cooking | |
# | |
# press 'Setup Parameters' in the OP to call this function to re-create the parameters. | |
def onSetupParameters(scriptOp): | |
page = scriptOp.appendCustomPage('Custom') | |
p = page.appendOP('Targetop', label='Target Operator') | |
return | |
# called whenever custom pulse parameter is pushed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
def Json_to_dict(json_file): | |
'''converts json to a python dictionary | |
''' | |
with open(json_file, 'r') as target_file: | |
json_dict = json.load(target_file) | |
return json_dict | |
def Save_dict_to_json(input_dict, json_file): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on PEP8 | |
# Classes | |
SomethingClass | |
class Foo: | |
# Public Methods and Functions | |
Something_public_method |
NewerOlder