Skip to content

Commit

Permalink
Update example code
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchalmers committed Dec 17, 2024
1 parent 5f6057f commit 356b257
Show file tree
Hide file tree
Showing 123 changed files with 1,539 additions and 1,377 deletions.
8 changes: 4 additions & 4 deletions docs/kcl/abs.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/kcl/acos.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/kcl/angleToMatchLengthX.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/kcl/angleToMatchLengthY.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/kcl/angledLine.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/kcl/angledLineOfXLength.md

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/kcl/angledLineOfYLength.md

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/kcl/angledLineThatIntersects.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/kcl/angledLineToX.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/kcl/angledLineToY.md

Large diffs are not rendered by default.

76 changes: 38 additions & 38 deletions docs/kcl/appearance.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ appearance(data: AppearanceData, solid_set: SolidSet) -> SolidSet
// Add color to an extruded solid.
exampleSketch = startSketchOn("XZ")
|> startProfileAt([0, 0], %)
|> lineTo([10, 0], %)
|> lineTo([0, 10], %)
|> lineTo([-10, 0], %)
|> close(%)
|> line(end = [10, 0])
|> line(end = [0, 10])
|> line(end = [-10, 0])
|> close()

example = extrude(5, exampleSketch)
example = extrude(exampleSketch, length = 5)
|> appearance({
color = '#ff0000',
metalness = 50,
Expand Down Expand Up @@ -65,11 +65,11 @@ sketch001 = startSketchOn('XY')
fn cube(center) {
return startSketchOn('XY')
|> startProfileAt([center[0] - 10, center[1] - 10], %)
|> lineTo([center[0] + 10, center[1] - 10], %)
|> lineTo([center[0] + 10, center[1] + 10], %)
|> lineTo([center[0] - 10, center[1] + 10], %)
|> close(%)
|> extrude(10, %)
|> line(end = [center[0] + 10, center[1] - 10])
|> line(end = [center[0] + 10, center[1] + 10])
|> line(end = [center[0] - 10, center[1] + 10])
|> close()
|> extrude(length = 10)
}

example0 = cube([0, 0])
Expand All @@ -95,11 +95,11 @@ appearance({
// This example shows setting the appearance _after_ the shell.
firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %)
|> close(%)
|> extrude(6, %)
|> line(to = [24, 0])
|> line(to = [0, -24])
|> line(to = [-24, 0])
|> close()
|> extrude(length = 6)

shell({ faces = ['end'], thickness = 0.25 }, firstSketch)
|> appearance({
Expand All @@ -116,11 +116,11 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch)
// This example shows setting the appearance _before_ the shell.
firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %)
|> close(%)
|> extrude(6, %)
|> line(to = [24, 0])
|> line(to = [0, -24])
|> line(to = [-24, 0])
|> close()
|> extrude(length = 6)
|> appearance({
color = '#ff0000',
metalness = 90,
Expand All @@ -137,12 +137,12 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch)
// This example shows _before_ the pattern.
exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> line([0, 2], %)
|> line([3, 1], %)
|> line([0, -4], %)
|> close(%)
|> line(to = [0, 2])
|> line(to = [3, 1])
|> line(to = [0, -4])
|> close()

example = extrude(1, exampleSketch)
example = extrude(exampleSketch, length = 1)
|> appearance({
color = '#ff0000',
metalness = 90,
Expand All @@ -162,12 +162,12 @@ example = extrude(1, exampleSketch)
// This example shows _after_ the pattern.
exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> line([0, 2], %)
|> line([3, 1], %)
|> line([0, -4], %)
|> close(%)
|> line(to = [0, 2])
|> line(to = [3, 1])
|> line(to = [0, -4])
|> close()

example = extrude(1, exampleSketch)
example = extrude(exampleSketch, length = 1)
|> patternLinear3d({
axis = [1, 0, 1],
instances = 7,
Expand All @@ -186,18 +186,18 @@ example = extrude(1, exampleSketch)
// Color the result of a 2D pattern that was extruded.
exampleSketch = startSketchOn('XZ')
|> startProfileAt([.5, 25], %)
|> line([0, 5], %)
|> line([-1, 0], %)
|> line([0, -5], %)
|> close(%)
|> line(to = [0, 5])
|> line(to = [-1, 0])
|> line(to = [0, -5])
|> close()
|> patternCircular2d({
center = [0, 0],
instances = 13,
arcDegrees = 360,
rotateDuplicates = true
}, %)

example = extrude(1, exampleSketch)
example = extrude(exampleSketch, length = 1)
|> appearance({
color = '#ff0000',
metalness = 90,
Expand All @@ -214,11 +214,11 @@ example = extrude(1, exampleSketch)
// Create a path for the sweep.
sweepPath = startSketchOn('XZ')
|> startProfileAt([0.05, 0.05], %)
|> line([0, 7], %)
|> line(to = [0, 7])
|> tangentialArc({ offset = 90, radius = 5 }, %)
|> line([-3, 0], %)
|> line(to = [-3, 0])
|> tangentialArc({ offset = -90, radius = 5 }, %)
|> line([0, 7], %)
|> line(to = [0, 7])

pipeHole = startSketchOn('XY')
|> circle({ center = [0, 0], radius = 1.5 }, %)
Expand Down
6 changes: 3 additions & 3 deletions docs/kcl/arc.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/kcl/arcTo.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/kcl/asin.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/kcl/atan.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/kcl/atan2.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/kcl/bezierCurve.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/kcl/ceil.md

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions docs/kcl/chamfer.md

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/kcl/circle.md

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/kcl/close.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/kcl/cos.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/kcl/e.md

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions docs/kcl/extrude.md

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions docs/kcl/fillet.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ filletRadius = 2

mountingPlateSketch = startSketchOn("XY")
|> startProfileAt([-width / 2, -length / 2], %)
|> lineTo([width / 2, -length / 2], %, $edge1)
|> lineTo([width / 2, length / 2], %, $edge2)
|> lineTo([-width / 2, length / 2], %, $edge3)
|> close(%, $edge4)
|> line(end = [width / 2, -length / 2], tag = $edge1)
|> line(end = [width / 2, length / 2], tag = $edge2)
|> line(end = [-width / 2, length / 2], tag = $edge3)
|> close(tag = $edge4)

mountingPlate = extrude(thickness, mountingPlateSketch)
mountingPlate = extrude(mountingPlateSketch, length = thickness)
|> fillet({
radius = filletRadius,
tags = [
Expand All @@ -63,12 +63,12 @@ filletRadius = 1

mountingPlateSketch = startSketchOn("XY")
|> startProfileAt([-width / 2, -length / 2], %)
|> lineTo([width / 2, -length / 2], %, $edge1)
|> lineTo([width / 2, length / 2], %, $edge2)
|> lineTo([-width / 2, length / 2], %, $edge3)
|> close(%, $edge4)
|> line(end = [width / 2, -length / 2], tag = $edge1)
|> line(end = [width / 2, length / 2], tag = $edge2)
|> line(end = [-width / 2, length / 2], tag = $edge3)
|> close(tag = $edge4)

mountingPlate = extrude(thickness, mountingPlateSketch)
mountingPlate = extrude(mountingPlateSketch, length = thickness)
|> fillet({
radius = filletRadius,
tolerance = 0.000001,
Expand Down
8 changes: 4 additions & 4 deletions docs/kcl/floor.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/kcl/getNextAdjacentEdge.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ getNextAdjacentEdge(tag: TagIdentifier) -> Uuid
```js
exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> line([10, 0], %)
|> line(to = [10, 0])
|> angledLine({ angle = 60, length = 10 }, %)
|> angledLine({ angle = 120, length = 10 }, %)
|> line([-10, 0], %)
|> line(to = [-10, 0])
|> angledLine({ angle = 240, length = 10 }, %, $referenceEdge)
|> close(%)
|> close()

example = extrude(5, exampleSketch)
example = extrude(exampleSketch, length = 5)
|> fillet({
radius = 3,
tags = [getNextAdjacentEdge(referenceEdge)]
Expand Down
8 changes: 4 additions & 4 deletions docs/kcl/getOppositeEdge.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ getOppositeEdge(tag: TagIdentifier) -> Uuid
```js
exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> line([10, 0], %)
|> line(to = [10, 0])
|> angledLine({ angle = 60, length = 10 }, %)
|> angledLine({ angle = 120, length = 10 }, %)
|> line([-10, 0], %)
|> line(to = [-10, 0])
|> angledLine({ angle = 240, length = 10 }, %, $referenceEdge)
|> close(%)
|> close()

example = extrude(5, exampleSketch)
example = extrude(exampleSketch, length = 5)
|> fillet({
radius = 3,
tags = [getOppositeEdge(referenceEdge)]
Expand Down
8 changes: 4 additions & 4 deletions docs/kcl/getPreviousAdjacentEdge.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ getPreviousAdjacentEdge(tag: TagIdentifier) -> Uuid
```js
exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> line([10, 0], %)
|> line(to = [10, 0])
|> angledLine({ angle = 60, length = 10 }, %)
|> angledLine({ angle = 120, length = 10 }, %)
|> line([-10, 0], %)
|> line(to = [-10, 0])
|> angledLine({ angle = 240, length = 10 }, %, $referenceEdge)
|> close(%)
|> close()

example = extrude(5, exampleSketch)
example = extrude(exampleSketch, length = 5)
|> fillet({
radius = 3,
tags = [getPreviousAdjacentEdge(referenceEdge)]
Expand Down
2 changes: 1 addition & 1 deletion docs/kcl/helix.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ helix(data: HelixData, solid: Solid) -> Solid
```js
part001 = startSketchOn('XY')
|> circle({ center = [5, 5], radius = 10 }, %)
|> extrude(10, %)
|> extrude(length = 10)
|> helix({
angleStart = 0,
ccw = true,
Expand Down
20 changes: 10 additions & 10 deletions docs/kcl/hole.md

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions docs/kcl/hollow.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ hollow(thickness: number, solid: Solid) -> Solid
// Hollow a basic sketch.
firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %)
|> close(%)
|> extrude(6, %)
|> line(to = [24, 0])
|> line(to = [0, -24])
|> line(to = [-24, 0])
|> close()
|> extrude(length = 6)
|> hollow(0.25, %)
```

Expand All @@ -45,11 +45,11 @@ firstSketch = startSketchOn('XY')
// Hollow a basic sketch.
firstSketch = startSketchOn('-XZ')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %)
|> close(%)
|> extrude(6, %)
|> line(to = [24, 0])
|> line(to = [0, -24])
|> line(to = [-24, 0])
|> close()
|> extrude(length = 6)
|> hollow(0.5, %)
```

Expand All @@ -60,25 +60,25 @@ firstSketch = startSketchOn('-XZ')
size = 100
case = startSketchOn('-XZ')
|> startProfileAt([-size, -size], %)
|> line([2 * size, 0], %)
|> line([0, 2 * size], %)
|> line(to = [2 * size, 0])
|> line(to = [0, 2 * size])
|> tangentialArcTo([-size, size], %)
|> close(%)
|> extrude(65, %)
|> close()
|> extrude(length = 65)

thing1 = startSketchOn(case, 'end')
|> circle({
center = [-size / 2, -size / 2],
radius = 25
}, %)
|> extrude(50, %)
|> extrude(length = 50)

thing2 = startSketchOn(case, 'end')
|> circle({
center = [size / 2, -size / 2],
radius = 25
}, %)
|> extrude(50, %)
|> extrude(length = 50)

hollow(0.5, case)
```
Expand Down
2 changes: 1 addition & 1 deletion docs/kcl/int.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ assertEqual(n, 3, 0.0001, "5/2 = 2.5, rounded up makes 3")
// Draw n cylinders.
startSketchOn('XZ')
|> circle({ center = [0, 0], radius = 2 }, %)
|> extrude(5, %)
|> extrude(length = 5)
|> patternTransform(n, fn(id) {
return { translate = [4 * id, 0, 0] }
}, %)
Expand Down
12 changes: 6 additions & 6 deletions docs/kcl/lastSegX.md

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/kcl/lastSegY.md

Large diffs are not rendered by default.

22 changes: 17 additions & 5 deletions docs/kcl/line.md

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/kcl/ln.md

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions docs/kcl/loft.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ loft(sketches: [Sketch], v_degree: NonZeroU32, bez_approximate_rational: bool, b
// Loft a square and a triangle.
squareSketch = startSketchOn('XY')
|> startProfileAt([-100, 200], %)
|> line([200, 0], %)
|> line([0, -200], %)
|> line([-200, 0], %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
|> line(to = [200, 0])
|> line(to = [0, -200])
|> line(to = [-200, 0])
|> line(end = [profileStartX(%), profileStartY(%)])
|> close()

triangleSketch = startSketchOn(offsetPlane('XY', 75))
|> startProfileAt([0, 125], %)
|> line([-15, -30], %)
|> line([30, 0], %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
|> line(to = [-15, -30])
|> line(to = [30, 0])
|> line(end = [profileStartX(%), profileStartY(%)])
|> close()

loft([squareSketch, triangleSketch])
```
Expand All @@ -56,11 +56,11 @@ loft([squareSketch, triangleSketch])
// Loft a square, a circle, and another circle.
squareSketch = startSketchOn('XY')
|> startProfileAt([-100, 200], %)
|> line([200, 0], %)
|> line([0, -200], %)
|> line([-200, 0], %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
|> line(to = [200, 0])
|> line(to = [0, -200])
|> line(to = [-200, 0])
|> line(end = [profileStartX(%), profileStartY(%)])
|> close()

circleSketch0 = startSketchOn(offsetPlane('XY', 75))
|> circle({ center = [0, 100], radius = 50 }, %)
Expand All @@ -81,11 +81,11 @@ loft([
// Loft a square, a circle, and another circle with options.
squareSketch = startSketchOn('XY')
|> startProfileAt([-100, 200], %)
|> line([200, 0], %)
|> line([0, -200], %)
|> line([-200, 0], %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
|> line(to = [200, 0])
|> line(to = [0, -200])
|> line(to = [-200, 0])
|> line(end = [profileStartX(%), profileStartY(%)])
|> close()

circleSketch0 = startSketchOn(offsetPlane('XY', 75))
|> circle({ center = [0, 100], radius = 50 }, %)
Expand Down
10 changes: 5 additions & 5 deletions docs/kcl/log.md

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/kcl/log10.md

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/kcl/log2.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/kcl/max.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/kcl/min.md

Large diffs are not rendered by default.

Loading

0 comments on commit 356b257

Please sign in to comment.