Skip to content

Instantly share code, notes, and snippets.

View raganmd's full-sized avatar
🚀
do all the things

Matthew Ragan raganmd

🚀
do all the things
View GitHub Profile
@raganmd
raganmd / col-to-list-as-lookup.py
Last active November 11, 2023 03:40
col-to-list-as-lookup.py
# 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)
@raganmd
raganmd / constant_chop_par_name_map.py
Last active November 11, 2023 03:43
HQ-TD-Python
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)
@raganmd
raganmd / par_map_from_par_names.py
Last active October 23, 2023 19:32
td_constant_chop_par_map_from_par_names
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)
@raganmd
raganmd / td-set-custom-pars-to-default.py
Last active November 25, 2022 19:53
TouchDesigner | Set Custom Pars to Defaults
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`
@raganmd
raganmd / script_top_download_img_cb.py
Created June 16, 2022 21:44
Google Drive ULR to TOP
# 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')
@raganmd
raganmd / python-reqs.cmd
Last active June 8, 2022 18:50
td-install-python-external
@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
@raganmd
raganmd / scriptDAT-isDefault.py
Created February 7, 2022 05:14
TouchDesigner is par default script DAT
# 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
@raganmd
raganmd / json-handler.py
Last active September 3, 2021 19:05
td-json-handler.py
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):
@raganmd
raganmd / insideBox.glsl
Created July 27, 2021 07:21
insideBox.glsl
‎‎​
# Based on PEP8
# Classes
SomethingClass
class Foo:
# Public Methods and Functions
Something_public_method