Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthew Ragan raganmd

View GitHub Profile
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 Jun 8, 2022
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 Feb 7, 2022
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 Sep 3, 2021
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
View TD-import-deps.py
projectDep = f'{project.folder}/td-python-dep'
if projectDep not in sys.path:
sys.path.append(projectDep)
for each in sys.path:
print(each)
else:
pass