Maybe someone missed this cool update and didn't point it out in the release notes, but in H20.5 it's now possible to define your types directly in the AttribWrangle snippet.
#include <math.h> #outer // { // This code will be placed outside of the generated function struct Point{ float x, y; float dist(const Point other){ return sqrt(pow(other.x - x, 2) + pow(other.y - y, 2)); } }; struct Rectangle{ Point p1, p2; float area(){ return abs((p1.x - p2.x) * (p1.y - p2.y)); } float perimeter(){ return 2 * (abs(p1.x - p2.x) + abs(p1.y - p2.y)); } } #endouter // } // This code will be in the function. Point pt1 = Point(0,0); Point pt2 = Point(1,2); @dist = pt1->dist(pt2); Rectangle rect = Rectangle(pt1, pt2); @area = rect->area(); @perimeter = rect->perimeter();
https://www.sidefx.com/docs/houdini/vex/snippets.html#structs-and-outer-code [www.sidefx.com]