FME Geometry, PythonCaller, GenerativeArt

#main_script import fmeobjects import numpy as np from fmeobjects import FMELine, FMEPoint, FMEPolygon """ zig-zag triangular strip is one zigzag row: upleft right downleft right ... /_\/_\ vertices are spaced by L/2 horizontally. The vertical coordinate alternates between: baseline and baseline + H where H = sqrt(3)/2 * L (because we need f) """ def triangle_row2(start, n, L, H): moves = np.array([ (-L/2, H), ( L, 0), (-L/2, -H), ( L, 0), ]) steps = np.tile(moves, (n, 1)) # repeat cycle pts = np.vstack([start, start + np.cumsum(steps, axis=0)]) return pts def triangle_row(start, n, L): H = np.sqrt(3) / 2 * L x0, y0 = start pts = [ (x0 + i * (L / 2), y0 + H * np.sin(i * np.pi / 2)) for i in range(2 * n + 1) ] return np.array(pts) class FeatureProcessor(object): def __init__(self): pass def input(self, feature: fmeobjects.FMEFeature): start_point = np.array([10,10]) #trianguline = triangle_row(start_point, 10, 5) trianguline = triangle_row2(start_point, 11, 1, 3) pline_input = list(map(tuple, trianguline)) line1 = FMELine(pline_input) feature.setGeometry(line1) self.pyoutput(feature) trianguline = triangle_row(start_point, 10, 1) pline_input = list(map(tuple, trianguline)) line1 = FMELine(pline_input) feature.setGeometry(line1) self.pyoutput(feature)