Skip to content

Patterns vs Generators

Both create repeated geometry, but they operate at different stages.

At a Glance

TopicPatternGenerator
StageRuntime/build graphAuthoring/code expansion
IR artifactpattern.linear / pattern.circular nodeExpanded concrete features only
Best forParametric intent in model historyReusable code templates and loops
Typical useHole arrays, feature/body replication intentProgrammatic creation of many similar features

Pattern Example

Pattern example

ts
const examplePart = part("example-pattern", [
  extrude("seed", profileRect(10, 10), 8, "body:seed"),
  patternLinear(
    "pattern-1",
    selectorFace([predCreatedBy("seed"), predPlanar(), predNormal("+Z")], [rankMaxZ()]),
    [18, 0],
    [4, 1],
    {
      source: selectorNamed("body:seed"),
      result: "body:main",
      deps: ["seed"],
    }
  ),
]);

Generator Example

Feature array example

ts
const cubes = featureArray(
  { count: [3, 2], spacing: [36, 36], origin: [-36, -18, 6] },
  ({ index, offset }) =>
    extrude(
      `cube-${index}`,
      profileRect(16, 16, offset),
      8,
      `body:cube-${index}`
    )
);

Use patterns when you want replicated model intent managed by the kernel graph. Use generators when you want concise code that expands to explicit features.