Apply a custom pattern generator

This example illustrates how to create and apply a custom pattern generator (a “Concentric” pattern generator).

# Demo on how to set and configure a custom pattern generator
# Usage:
# - Select one or more polygon objects (in object, not group selection mode)
# - Execute this script
# It creates a "concentric" pattern generator, sets a 'zig-zag' curve to it, and attaches it to
# the selected shapes (works only with polygons)
# Author: Klaus Gieb

import litho.core as lc

doc =

def mkCurve(numSteps, ptsPerStep, minVal,maxVal):
	stepw = 1.0/numSteps
	result = list()
	for v in range(0,numSteps):
		offset = v*stepw
		for s in range(0, ptsPerStep+1):
			x = offset+s*(1.0/ptsPerStep)*stepw
			y = minVal+s*(1.0/ptsPerStep)*(maxVal-minVal)
	return result

pathlist = doc.selection.selectedObjects()
pg = doc.createNode("ConcentricPatternGen") = "ramps"
pg.niceName = "Simple Ramps"
pg.profile = mkCurve(5, 10, 0.2, 0.8)

for p in pathlist:
	leaf = p.leaf
	current = leaf.builder
	if current is not None: current.forceDelete()
	leaf.builder = pg