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 / td-module-logging-example
Last active July 26, 2021 02:30
An example of logging with a module rather than with an extension
import datetime
log_file = op( 'text_log' )
full_text = '''{now}
Current Year | {year}
Current Month | {month}
Current Day | {day}
Current Hour | {hour}
cue_list = {
"cue1" : {
"file" : '/Map/Banana.tif',
"mono" : 0 ,
"invert" : 1,
"brightness" : 0.71,
"blacklevel" : 0.51,
"contrast" : 1.93
} ,
"cue2" : {
import json
import os
class Project:
def __init__(self):
self.sys_config = '{project_folder}/system.json'.format(project_folder = project.folder)
return
def Touch_start(self):
@raganmd
raganmd / td-script-dat-starte.py
Last active July 26, 2021 02:30
A starter pass at a generic script DAT format for export tables
# me - this DAT
# scriptOp - the OP which is cooking
#
targets_pars_vals = [
[ 'tex3d1', 'cachesize', 1 ],
[ 'ramp3', 'resolutionh', 1 ],
[ 'tima1', 'blackoffset', -1 ]
]
uniform int numLights;
uniform vec3 viewDirection;
uniform vec3 specularColor;
uniform float shininess;
uniform sampler2D samplerPos;
uniform sampler2D samplerNorm;
# delay scripts example
# first we write out script as a string
delay_script = "constant_op.par.value0 = args[0]"
constant_op = op('constant1')
# next we run our script
for each_time in range(10):
run(delay_script, (each_time+1), delayFrames = 60 * (each_time + 1))
@raganmd
raganmd / TD-to-NR
Created October 24, 2018 22:44
Example of sending a json blob as a json object to NR
sender = op('tcpip1')
import json
def onOffToOn(channel, sampleIndex, val, prev):
msg = {
"time" : absTime.frame
}
j_msg = json.dumps(msg)
sender.sendBytes(str(j_msg))
import math
def distance(x1, y1, z1, x2, y2, z2):
return math.sqrt((x2 - x1)**2 + (y2 - y1)**2 + (z2 - z1)**2)
import numpy
def numpyDist(point1, point2):
p1 = numpy.array(point1)
p2 = numpy.array(point2)
return numpy.linalg.norm(p1-p2)
def tduDist(point1, point2):
p1 = tdu.Vector(point1)
p2 = tdu.Vector(point2)
return p1.distance(p2)