Skip to content

Instantly share code, notes, and snippets.

View raganmd's full-sized avatar

Matthew Ragan raganmd

View GitHub Profile
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)
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):
@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
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
py -{versionNumber} -m pip install {module} --target="{pathToTargetDir}"
@echo off
rem turn off echo
rem set TouchDesigner build numbers
set TOUCHVERSION=2020.26630
rem set our project file target
set TOEFILE="project.toe"
rem set the rest of our paths for executables
import requests
dataURL = 'https://www.purpleair.com/json?show=182&fbclid=IwAR17uHJ8zpHcj7nwipL7_KRleF8uj9DEZ3Gqz-8AfQwVVC7rYdfWC61aM0Q'
rawData = requests.get(dataURL)
msg = rawData.json()
results = msg.get('results')
for eachDict in results:
def tduDist(point1, point2):
p1 = tdu.Vector(point1)
p2 = tdu.Vector(point2)
return p1.distance(p2)
import numpy
def numpyDist(point1, point2):
p1 = numpy.array(point1)
p2 = numpy.array(point2)
return numpy.linalg.norm(p1-p2)
import math
def distance(x1, y1, z1, x2, y2, z2):
return math.sqrt((x2 - x1)**2 + (y2 - y1)**2 + (z2 - z1)**2)