Skip to content

Instantly share code, notes, and snippets.

@yone80
yone80 / roll.js
Last active August 21, 2018 10:21
Roll - Aftereffects Expression
numsegments = Math.max(2, Math.floor(effect("Segments")("Slider")));
totallength = Math.max(0.001, effect("Line Length")("Slider"));
seglength = totallength / numsegments;
sepdist = Math.max(0.001, effect("Seperation Distance")("Slider") * 0.5) / (Math.PI * 2);
roll = clamp(effect("Roll")("Slider"), 0, 1);
pos = [0, 0];
cv = [];
firsttheta = Math.sqrt(numsegments * seglength / sepdist);
@yone80
yone80 / shapeonmotionpath
Last active November 8, 2017 00:19
Shape on motion path - Aftereffects Expression
seg = Math.floor( Math.max(effect("Segments")("Slider"), 2) );
starttime = effect("Start Time")("Slider");
endtime = effect("End Time")("Slider");
smooth = effect("Smooth")("Checkbox") > 0;
targetlayer = thisComp.layer("Tip");
timemin = Math.min(starttime, endtime);
timemax = Math.max(starttime, endtime);
cv = [];
@yone80
yone80 / circleshape.js
Created October 23, 2017 14:10
Circle shape - Aftereffects Expression
seg = Math.floor( Math.max(effect("Segments")("Slider"), 2) );
radius = effect("Radius")("Slider");
angle_param = clamp(effect("Angle Control")("Angle"), -360, 360);
close = effect("Close")("Checkbox") > 0;
angle = degreesToRadians(angle_param) * 1 / seg;
tangent = [0, 4 / 3 * Math.tan(angle/4) ] * radius;
firsttangent = [0,0];
numiterations = seg + 1;
@yone80
yone80 / shapeonpath.js
Last active October 25, 2017 11:51
Shape on path - Aftereffects Expression
dist = effect("Offset")("Slider"); // Position on path.
w = effect("Width")("Slider"); // Normal direction width.
restpath = thisProperty;
targetpath = thisComp.layer("Path").content("Shape 1").content("Path 1").path; // Target Path
refpt = restpath.points();
refintan = restpath.inTangents();
refouttan = restpath.outTangents();
@yone80
yone80 / Extract Edge Groups
Created September 3, 2017 09:30
VEXpression
string edgegrp = chs('edge_group');
string newgrpname = chs('new_polyline_group_name');
int edges[] = expandedgegroup(0, edgegrp);
int prevpt = -1;
int curprim = -1;
for(int i=0; i<len(edges); i+=2)
{
import soptoolutils
selection = None
if type(kwargs['pane']) is hou.SceneViewer:
viewer = kwargs['pane']
selection = viewer.selectGeometry(geometry_types=(hou.geometryType.Primitives, hou.geometryType.Edges,))
n = soptoolutils.genericTool(kwargs, '$HDA_NAME')
vector origin = chv('t');
vector dir = normalize( chv('dir') );
vector v = @P - origin;
float dist = dot(v, dir);
float range = ch('range');
f@falloff = fit(dist, range, 0, 0, 1);
def checkConnectivity(e1, e2):
chk = e1.points()[0].number == e2.points()[0].number
chk = chk or e1.points()[0].number == e2.points()[1].number
if chk: return 1
chk = e1.points()[1].number == e2.points()[0].number
chk = chk or e1.points()[1].number == e2.points()[1].number
if chk: return 2
return 0
def isNext(e1, e2):
@yone80
yone80 / Group_Menu.py
Last active May 31, 2016 17:19
Houdini Python SOP
node = hou.pwd()
menu = []
parmvalues = kwargs['parm'].eval().split()
if node.inputs():
geo = node.inputs()[0].geometry()
typegroups = []
typegroups.append( geo.primGroups() )
typegroups.append( geo.pointGroups() )
@yone80
yone80 / Polyline_from_edges.py
Last active April 11, 2017 10:12
Houdini Python SOP
node = hou.pwd()
geo = node.geometry()
geo.deletePrims(geo.prims(), True)
pt_delete = set(geo.points())
ptns = node.parm('group').eval().split()
for ptn in ptns:
edges = geo.globEdges(ptn)