Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthew Ragan raganmd

View GitHub Profile
@raganmd
raganmd / td-set-custom-pars-to-default.py
Last active November 25, 2022 19:53
TouchDesigner | Set Custom Pars to Defaults
View td-set-custom-pars-to-default.py
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
View script_top_download_img_cb.py
# 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
View python-reqs.cmd
@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
View scriptDAT-isDefault.py
# 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
View 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):
View TD-Python-style.py
# Based on PEP8
# Classes
SomethingClass
class Foo:
# Public Methods and Functions
Something_public_method
View bezier-snippet.py
import bezier
import numpy as np
# press 'Setup Parameters' in the OP to call this function to re-create the parameters
def onSetupParameters(scriptOp):
page = scriptOp.appendCustomPage('Custom')
p = page.appendFloat('Val1', label='P1', size=3)
page = scriptOp.appendCustomPage('Custom')
p = page.appendFloat('Val2', label='P2', size=3)
View td_par_helper_class.py
class par_helper:
'''A generalized parameter helper for simple par callbacks
The intention of this extension is to provide a slim interface
for easily scritable actions intended to be connected to custom
changes. The model assumes that the developer would like to
call a scriptable action whose function name matches the parameter
name.
'''
def __init__(self, my_op, actionsMOD, debug=False):
View _startProject.cmd
@echo off
rem turn off echo
rem set TouchDesigner build numbers
set TOUCHVERSION=2021.10330
rem set our project file target
set TOEFILE="dev-env.toe"
rem set the rest of our paths for executables