Files
modeling-app/docs/kcl/patternTransform.md

357 lines
451 KiB
Markdown
Raw Normal View History

2024-06-27 22:20:51 -05:00
---
title: "patternTransform"
excerpt: "A linear pattern on a 3D solid."
layout: manual
---
A linear pattern on a 3D solid.
Each repetition of the pattern can be transformed (e.g. scaled, translated, hidden, etc).
```js
patternTransform(num_repetitions: u32, transform_function: FunctionParam, extrude_group_set: ExtrudeGroupSet) -> [ExtrudeGroup]
```
### Examples
```js
// Parameters
const r = 50 // base radius
const h = 10 // layer height
const t = 0.005 // taper factor [0-1)
// Defines how to modify each layer of the vase.
// Each replica is shifted up the Z axis, and has a smoothly-varying radius
fn transform = (replicaId) => {
let scale = r * abs(1 - (t * replicaId)) * (5 + cos(replicaId / 8))
return {
translate: [0, 0, replicaId * 10],
scale: [scale, scale, 0]
}
}
// Each layer is just a pretty thin cylinder.
fn layer = () => {
return startSketchOn("XY")
// or some other plane idk
|> circle([0, 0], 1, %, $tag1)
|> extrude(h, %)
}
// The vase is 100 layers tall.
// The 100 layers are replica of each other, with a slight transformation applied to each.
let vase = layer()
|> patternTransform(100, transform, %)
```
![Rendered example of patternTransform 0](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABQAAAALQCAYAAADPfd1WAAU0bElEQVR4Ae3gAZAkSZIkSRKLqpm7R0REZmZmVlVVVVV3d3d3d/fMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMdHd3d3dXV1VVVVVmZkZGRIS7m5kKz0xmV3d1d3dPz8zMzMxMYn3Qgx7EVVddddVVV1111VVXXXXVVVddddVVV131fxKVq6666qqrrrrqqquuuuqqq6666qqrrrrq/yoqV1111VVXXXXVVVddddVVV1111VVXXXXV/1VUrrrqqquuuuqqq6666qqrrrrqqquuuuqq/6uoXHXVVVddddVVV1111VVXXXXVVVddddVV/1dRueqqq6666qqrrrrqqquuuuqqq6666qqr/q+ictVVV1111VVXXXXVVVddddVVV1111VVX/V9F5aqrrrrqqquuuuqqq6666qqrrrrqqquu+r+KylVXXXXVVVddddVVV1111VVXXXXVVVdd9X8Vlauuuuqqq6666qqrrrrqqquuuuqqq6666v8qKlddddVVV1111VVXXXXVVVddddVVV1111f9VVK666qqrrrrqqquuuuqqq6666qqrrrrqqv+rqFx11VVXXXXVVVddddVVV1111VVXXXXVVf9XUbnqqquuuuqqq6666qqrrrrqqquuuuqqq/6vonLVVVddddVVV1111VVXXXXVVVddddVVV/1fReWqq6666qqrrrrqqquuuuqqq6666qqrrvq/ispVV1111VVXXXXVVVddddVVV1111VVXXfV/FZWrrrrqqquuuuqqq6666qqrrrrqqquuuur/KipXXXXVVVddddVVV1111VVXXXXVVVddddX/VVSuuuqqq6666qqrrrrqqquuuuqqq6666qr/q6hcddVVV1111VVXXXXVVVddddVVV1111VX/V1G56qqrrrrqqquuuuqqq6666qqrrrrqqqv+r6Jy1VVXXXXVVVddddVVV1111VVXXXXVVVf9X0Xlqquuuuqqq6666qqrrrrqqquuuuqqq676v4rKVVddddVVV1111VVXXXXVVVddddVVV131fxWVq6666qqrrrrqqquuuuqqq6666qqrrrrq/yoqV1111VVXXXXVVVddddVVV1111VVXXXXV/1VUrrrqqquuuuqqq6666qqrrrrqqquuuuqq/6uoXHXVVVddddVVV1111VVXXXXVVVddddVV/1dRueqqq6666qqrrrrqqquuuuqqq6666qqr/q+ictVVV1111VVXXXXVVVddddVVV1111VVX/V9F5aqrrrrqqquuuuqqq6666qqrrrrqqquu+r+KylVXXXXVVVddddVVV1111VVXXXXVVVdd9X8Vlauuuuqqq6666qqrrrrqqquuuuqqq6666v8qKlddddVVV1111VVXXXXVVVddddVVV1111f9VVK666qqrrrrqqquuuuqqq6666qqrrrrqqv+rqFx11VVXXXXVVVddddVVV1111VVXXXXVVf9XUbnqqquuuuqqq6666qqrrrrqqquuuuqqq/6vonLVVVddddVVV1111VVXXXXVVVddddVVV/1fReWqq6666qqrrrrqqquuuuqqq6666qqrrvq/ispVV1111VVXXXXVVVddddVVV1111VVXXfV/FZWrrrrqqquuuuqqq6666qqrrrrqqquuuur/KipXXXXVVVddddVVV1111VVXXXXVVVddddX/VVSuuuqqq6666qqrrvoPdc011zyYZzpz5syDeaZrrrnmwTzAmTNnHsRzueaaax7Mc7nmmmsezAtx5syZB/Of7OzZs7fyAtx33323Atx33323XnPNNQ/mme67775beYCzZ88+gwe47777buUBzp49eyvAfffddytXXXXVVVddddVVV/1HQQ960IO46qqrrrrqqquuugquueaaBwOcOXPmwQDXXHPNg8+cOfMgnumaa655MMA111zzYJ7pzJkzDwa45pprHsy/0R/+4R/y3C5dusRz29vb44WRxP0uXbrEv9WxY8d4Uezs7PD87OzsACAJgFd5lVfh3+q+++67lWc6e/bsrQD33XffrTzTfffdd+vZs2efwTPdd999twKcPXv21vvuu+9Wrrrqqquuuuqqq65CD3rQg7jqqquuuuqqq676v+aaa655MM/0Yi/2Yq995syZB/FM11xzzYOvueaaB585c+bBANdcc82DeQH+4i/+gosXL7KxsQHApUuXANjb2+N+ly5dAmBvb4//bJL4n0QS/1l2dna4387ODgDHjh3jfjs7O/R9D8DLvdzL8YLcd999twKcPXv21vvuu+9WgPvuu+/Ws2fPPgPgvvvuuxXgH/7hH36bq6666qqrrrrqqv970IMe9CCuuuqqq6666qqr/je55pprHgzwYi/2Yq8NcObMmQddc801D77mmmsefObMmQdfc801D+a5/OVf/iXL5RKAvb09Ll26BMDe3h57e3v8TyKJ/2kk8T+NJP4lOzs7AOzs7ACws7MDwM0338xyueTlXu7leKD77rvvVoCzZ8/eet99990K8A//8A+/A3Dffffdevbs2Vvvu+++W7nqqquuuuqqq6763wM96EEP4qqrrrrqqquuuup/mmuuuebBZ86cefCLvdiLvRbAi7/4i782wIu92Iu9Ng/wl3/5lyyXS/b29rh06RIAt99+O89NEv/TSOJ/Ekn8TyOJ/0o7OzsA7OzssLOzw87ODrPZjJd92Zflfvfdd9+tAGfPnr31vvvuu/Uf/uEffue+++679ezZs7fed999t3LVVVddddVVV131Pwt60IMexFVXXXXVVVddddV/l2uuuebBZ86cefCLvdiLvdY111zz4GuuuebBZ86cefA111zzYIC//Mu/ZLlcsre3x6VLl7j99tt5YSTxP4kk/qeRxP80kvifSBLPbWdnh52dHXZ2dgA4ffo0L/uyLwvAfffddyvAP/zDP/z2b/3Wb30PwD/8wz/8NlddddVVV1111VX/fdCDHvQgrrrqqquuuuqqq/6rXHPNNQ9+7dd+7fcCeKd3eqfP5pl+4zd+g/l8zu23387tt9/Ov0QS/5NI4n8aSfxPJIn/aSTxH2FnZ4ednR12dnY4ffo0L/uyLwvAfffdd+s//MM//PY//MM//M5999136z/8wz/8NlddddVVV1111VX/NdCDHvQgrrrqqquuuuqqq/4zXXPNNQ9+sRd7sdf+8A//8O8CePrTn85dd93F7bffzu23384LIon/aSTxP40k/ieSxP9EkvivtLOzA8BNN93E6dOnedmXfVnuu+++W3/rt37ru//hH/7hd/7hH/7ht7nqqquuuuqqq676z4Me9KAHcdVVV1111VVXXfWf4R3f8R0/63Ve53Xe+5prrnnwH/zBH3D77bdz++2389wk8T+NJP4nksT/NJL4n0oS/xMdO3aMxzzmMbzyK78y9913362/9Vu/9d0/+qM/+jlcddVVV1111VVX/cdDD3rQg7jqqquuuuqqq676j/aO7/iOn/UyL/My7/3Upz71wX//938PgCT+p5HE/0SS+J9IEv8TSeJ/Kkm8MDs7O7z2a782m5ubt37Ih3zIQ7jqqquuuuqqq676j4Ue9KAHcdVVV1111VVXXfUf6R3f8R0/6+abb/7sP/zDP+R/Ekn8TySJ/4kk8T+RJP6nksS/1Su90iuxvb3925/5mZ/5Olx11VVXXXXVVVf9xyG46qqrrrrqqquu+g90zTXXPPgRj3jEZ/PfSBKSkIQkJCGJ/26SkIQkJCEJSfxPIAlJSEISkvifQBKSkIQkJPE/hSQkIQlJSOLf64Ybbnjta6655sFcddVVV1111VVX/cchuOqqq6666qqrrvoPNpvNfvvmm2/mnd7pndjZ2eE/kyQkIQlJSOJ/AklIQhKSkMT/BJKQhCQkIQlJ/E8gCUlIQhK
### Arguments
* `num_repetitions`: `u32` (REQUIRED)
* `transform_function`: `FunctionParam` (REQUIRED)
* `extrude_group_set`: `ExtrudeGroupSet` - A extrude group or a group of extrude groups. (REQUIRED)
```js
{
// The id of the extrusion end cap
endCapId: uuid,
// Chamfers or fillets on this extrude group.
filletOrChamfers: [{
// The engine id of the edge to fillet.
edge_id: uuid,
// The id of the engine command that called this fillet.
id: uuid,
radius: number,
type: "fillet",
} |
{
// The engine id of the edge to chamfer.
edge_id: uuid,
// The id of the engine command that called this chamfer.
id: uuid,
length: number,
tag: {
end: number,
start: number,
value: string,
},
type: "chamfer",
}],
// The height of the extrude group.
height: number,
// The id of the extrude group.
id: uuid,
// The sketch group.
sketchGroup: {
// The id of the sketch group.
id: uuid,
// What the sketch is on (can be a plane or a face).
on: {
// The id of the plane.
id: uuid,
// Origin of the plane.
origin: {
x: number,
y: number,
z: number,
},
type: "plane",
// Type for a plane.
value: "XY" | "XZ" | "YZ" | "Custom",
// What should the planes X axis be?
xAxis: {
x: number,
y: number,
z: number,
},
// What should the planes Y axis be?
yAxis: {
x: number,
y: number,
z: number,
},
// The z-axis (normal).
zAxis: {
x: number,
y: number,
z: number,
},
} |
{
// The extrude group the face is on.
extrudeGroup: {
// The id of the extrusion end cap
endCapId: uuid,
// Chamfers or fillets on this extrude group.
filletOrChamfers: [{
// The engine id of the edge to fillet.
edge_id: uuid,
// The id of the engine command that called this fillet.
id: uuid,
radius: number,
type: "fillet",
} |
{
// The engine id of the edge to chamfer.
edge_id: uuid,
// The id of the engine command that called this chamfer.
id: uuid,
length: number,
tag: {
end: number,
start: number,
value: string,
},
type: "chamfer",
}],
// The height of the extrude group.
height: number,
// The id of the extrude group.
id: uuid,
// The sketch group.
sketchGroup: SketchGroup,
// The id of the extrusion start cap
startCapId: uuid,
// The extrude surfaces.
value: [{
// The face id for the extrude plane.
faceId: uuid,
// The id of the geometry.
id: uuid,
// The source range.
sourceRange: [number, number],
// The tag.
tag: {
end: number,
start: number,
value: string,
},
type: "extrudePlane",
} |
{
// The face id for the extrude plane.
faceId: uuid,
// The id of the geometry.
id: uuid,
// The source range.
sourceRange: [number, number],
// The tag.
tag: {
end: number,
start: number,
value: string,
},
type: "extrudeArc",
}],
},
// The id of the face.
id: uuid,
type: "face",
// The tag of the face.
value: string,
// What should the faces X axis be?
xAxis: {
x: number,
y: number,
z: number,
},
// What should the faces Y axis be?
yAxis: {
x: number,
y: number,
z: number,
},
// The z-axis (normal).
zAxis: {
x: number,
y: number,
z: number,
},
},
// The starting path.
start: {
// The from point.
from: [number, number],
// The tag of the path.
tag: {
end: number,
start: number,
value: string,
},
// The to point.
to: [number, number],
},
// The paths in the sketch group.
value: [{
// The from point.
from: [number, number],
// The tag of the path.
tag: {
end: number,
start: number,
value: string,
},
// The to point.
to: [number, number],
type: "ToPoint",
} |
{
// arc's direction
ccw: string,
// the arc's center
center: [number, number],
// The from point.
from: [number, number],
// The tag of the path.
tag: {
end: number,
start: number,
value: string,
},
// The to point.
to: [number, number],
type: "TangentialArcTo",
} |
{
// The from point.
from: [number, number],
// The tag of the path.
tag: {
end: number,
start: number,
value: string,
},
// The to point.
to: [number, number],
type: "TangentialArc",
} |
{
// The from point.
from: [number, number],
// The tag of the path.
tag: {
end: number,
start: number,
value: string,
},
// The to point.
to: [number, number],
type: "Horizontal",
// The x coordinate.
x: number,
} |
{
// The from point.
from: [number, number],
// The tag of the path.
tag: {
end: number,
start: number,
value: string,
},
// The to point.
to: [number, number],
type: "AngledLineTo",
// The x coordinate.
x: number,
// The y coordinate.
y: number,
} |
{
// The from point.
from: [number, number],
// The tag of the path.
tag: {
end: number,
start: number,
value: string,
},
// The to point.
to: [number, number],
type: "Base",
}],
},
// The id of the extrusion start cap
startCapId: uuid,
type: "extrudeGroup",
// The extrude surfaces.
value: [{
// The face id for the extrude plane.
faceId: uuid,
// The id of the geometry.
id: uuid,
// The source range.
sourceRange: [number, number],
// The tag.
tag: {
end: number,
start: number,
value: string,
},
type: "extrudePlane",
} |
{
// The face id for the extrude plane.
faceId: uuid,
// The id of the geometry.
id: uuid,
// The source range.
sourceRange: [number, number],
// The tag.
tag: {
end: number,
start: number,
value: string,
},
type: "extrudeArc",
}],
} |
{
type: "extrudeGroups",
}
```
### Returns
`[ExtrudeGroup]`