KCL: Line and Extrude use kw args

This commit is contained in:
Adam Chalmers
2024-12-16 09:57:56 -06:00
committed by Nick Cameron
parent e7203b9e7a
commit a186517bd0
262 changed files with 7963 additions and 8167 deletions

2
.helix/config.toml Normal file
View File

@ -0,0 +1,2 @@
[editor]
auto-format = true

10
.helix/languages.toml Normal file
View File

@ -0,0 +1,10 @@
[language-server.eslint]
args = ["--stdio"]
command = "vscode-eslint-language-server"
[[language]]
name = "typescript"
auto-format = true
formatter = { command = "node_modules/.bin/prettier", args = ["--parser", "typescript"] }
language-servers = [ { name = "eslint", only-features = [ "diagnostics" ] }, "typescript-language-server" ]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -31,12 +31,12 @@ appearance(data: AppearanceData, solid_set: SolidSet) -> SolidSet
// Add color to an extruded solid. // Add color to an extruded solid.
exampleSketch = startSketchOn("XZ") exampleSketch = startSketchOn("XZ")
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> lineTo([10, 0], %) |> line(endAbsolute = [10, 0])
|> lineTo([0, 10], %) |> line(endAbsolute = [0, 10])
|> lineTo([-10, 0], %) |> line(endAbsolute = [-10, 0])
|> close(%) |> close()
example = extrude(5, exampleSketch) example = extrude(exampleSketch, length = 5)
|> appearance({ |> appearance({
color = '#ff0000', color = '#ff0000',
metalness = 50, metalness = 50,
@ -65,11 +65,11 @@ sketch001 = startSketchOn('XY')
fn cube(center) { fn cube(center) {
return startSketchOn('XY') return startSketchOn('XY')
|> startProfileAt([center[0] - 10, center[1] - 10], %) |> startProfileAt([center[0] - 10, center[1] - 10], %)
|> lineTo([center[0] + 10, center[1] - 10], %) |> line(endAbsolute = [center[0] + 10, center[1] - 10])
|> lineTo([center[0] + 10, center[1] + 10], %) |> line(endAbsolute = [center[0] + 10, center[1] + 10])
|> lineTo([center[0] - 10, center[1] + 10], %) |> line(endAbsolute = [center[0] - 10, center[1] + 10])
|> close(%) |> close()
|> extrude(10, %) |> extrude(length = 10)
} }
example0 = cube([0, 0]) example0 = cube([0, 0])
@ -95,11 +95,11 @@ appearance({
// This example shows setting the appearance _after_ the shell. // This example shows setting the appearance _after_ the shell.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line([24, 0], %) |> line(end = [24, 0])
|> line([0, -24], %) |> line(end = [0, -24])
|> line([-24, 0], %) |> line(end = [-24, 0])
|> close(%) |> close()
|> extrude(6, %) |> extrude(length = 6)
shell({ faces = ['end'], thickness = 0.25 }, firstSketch) shell({ faces = ['end'], thickness = 0.25 }, firstSketch)
|> appearance({ |> appearance({
@ -116,11 +116,11 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch)
// This example shows setting the appearance _before_ the shell. // This example shows setting the appearance _before_ the shell.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line([24, 0], %) |> line(end = [24, 0])
|> line([0, -24], %) |> line(end = [0, -24])
|> line([-24, 0], %) |> line(end = [-24, 0])
|> close(%) |> close()
|> extrude(6, %) |> extrude(length = 6)
|> appearance({ |> appearance({
color = '#ff0000', color = '#ff0000',
metalness = 90, metalness = 90,
@ -137,12 +137,12 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch)
// This example shows _before_ the pattern. // This example shows _before_ the pattern.
exampleSketch = startSketchOn('XZ') exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line([0, 2], %) |> line(end = [0, 2])
|> line([3, 1], %) |> line(end = [3, 1])
|> line([0, -4], %) |> line(end = [0, -4])
|> close(%) |> close()
example = extrude(1, exampleSketch) example = extrude(exampleSketch, length = 1)
|> appearance({ |> appearance({
color = '#ff0000', color = '#ff0000',
metalness = 90, metalness = 90,
@ -162,12 +162,12 @@ example = extrude(1, exampleSketch)
// This example shows _after_ the pattern. // This example shows _after_ the pattern.
exampleSketch = startSketchOn('XZ') exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line([0, 2], %) |> line(end = [0, 2])
|> line([3, 1], %) |> line(end = [3, 1])
|> line([0, -4], %) |> line(end = [0, -4])
|> close(%) |> close()
example = extrude(1, exampleSketch) example = extrude(exampleSketch, length = 1)
|> patternLinear3d({ |> patternLinear3d({
axis = [1, 0, 1], axis = [1, 0, 1],
instances = 7, instances = 7,
@ -186,10 +186,10 @@ example = extrude(1, exampleSketch)
// Color the result of a 2D pattern that was extruded. // Color the result of a 2D pattern that was extruded.
exampleSketch = startSketchOn('XZ') exampleSketch = startSketchOn('XZ')
|> startProfileAt([.5, 25], %) |> startProfileAt([.5, 25], %)
|> line([0, 5], %) |> line(end = [0, 5])
|> line([-1, 0], %) |> line(end = [-1, 0])
|> line([0, -5], %) |> line(end = [0, -5])
|> close(%) |> close()
|> patternCircular2d({ |> patternCircular2d({
center = [0, 0], center = [0, 0],
instances = 13, instances = 13,
@ -197,7 +197,7 @@ exampleSketch = startSketchOn('XZ')
rotateDuplicates = true rotateDuplicates = true
}, %) }, %)
example = extrude(1, exampleSketch) example = extrude(exampleSketch, length = 1)
|> appearance({ |> appearance({
color = '#ff0000', color = '#ff0000',
metalness = 90, metalness = 90,
@ -214,11 +214,11 @@ example = extrude(1, exampleSketch)
// Create a path for the sweep. // Create a path for the sweep.
sweepPath = startSketchOn('XZ') sweepPath = startSketchOn('XZ')
|> startProfileAt([0.05, 0.05], %) |> startProfileAt([0.05, 0.05], %)
|> line([0, 7], %) |> line(end = [0, 7])
|> tangentialArc({ offset = 90, radius = 5 }, %) |> tangentialArc({ offset = 90, radius = 5 }, %)
|> line([-3, 0], %) |> line(end = [-3, 0])
|> tangentialArc({ offset = -90, radius = 5 }, %) |> tangentialArc({ offset = -90, radius = 5 }, %)
|> line([0, 7], %) |> line(end = [0, 7])
pipeHole = startSketchOn('XY') pipeHole = startSketchOn('XY')
|> circle({ center = [0, 0], radius = 1.5 }, %) |> circle({ center = [0, 0], radius = 1.5 }, %)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -36,12 +36,12 @@ filletRadius = 2
mountingPlateSketch = startSketchOn("XY") mountingPlateSketch = startSketchOn("XY")
|> startProfileAt([-width / 2, -length / 2], %) |> startProfileAt([-width / 2, -length / 2], %)
|> lineTo([width / 2, -length / 2], %, $edge1) |> line(endAbsolute = [width / 2, -length / 2], tag = $edge1)
|> lineTo([width / 2, length / 2], %, $edge2) |> line(endAbsolute = [width / 2, length / 2], tag = $edge2)
|> lineTo([-width / 2, length / 2], %, $edge3) |> line(endAbsolute = [-width / 2, length / 2], tag = $edge3)
|> close(%, $edge4) |> close(tag = $edge4)
mountingPlate = extrude(thickness, mountingPlateSketch) mountingPlate = extrude(mountingPlateSketch, length = thickness)
|> fillet({ |> fillet({
radius = filletRadius, radius = filletRadius,
tags = [ tags = [
@ -63,12 +63,12 @@ filletRadius = 1
mountingPlateSketch = startSketchOn("XY") mountingPlateSketch = startSketchOn("XY")
|> startProfileAt([-width / 2, -length / 2], %) |> startProfileAt([-width / 2, -length / 2], %)
|> lineTo([width / 2, -length / 2], %, $edge1) |> line(endAbsolute = [width / 2, -length / 2], tag = $edge1)
|> lineTo([width / 2, length / 2], %, $edge2) |> line(endAbsolute = [width / 2, length / 2], tag = $edge2)
|> lineTo([-width / 2, length / 2], %, $edge3) |> line(endAbsolute = [-width / 2, length / 2], tag = $edge3)
|> close(%, $edge4) |> close(tag = $edge4)
mountingPlate = extrude(thickness, mountingPlateSketch) mountingPlate = extrude(mountingPlateSketch, length = thickness)
|> fillet({ |> fillet({
radius = filletRadius, radius = filletRadius,
tolerance = 0.000001, tolerance = 0.000001,

File diff suppressed because one or more lines are too long

View File

@ -29,14 +29,14 @@ getNextAdjacentEdge(tag: TagIdentifier) -> Uuid
```js ```js
exampleSketch = startSketchOn('XZ') exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line([10, 0], %) |> line(end = [10, 0])
|> angledLine({ angle = 60, length = 10 }, %) |> angledLine({ angle = 60, length = 10 }, %)
|> angledLine({ angle = 120, length = 10 }, %) |> angledLine({ angle = 120, length = 10 }, %)
|> line([-10, 0], %) |> line(end = [-10, 0])
|> angledLine({ angle = 240, length = 10 }, %, $referenceEdge) |> angledLine({ angle = 240, length = 10 }, %, $referenceEdge)
|> close(%) |> close()
example = extrude(5, exampleSketch) example = extrude(exampleSketch, length = 5)
|> fillet({ |> fillet({
radius = 3, radius = 3,
tags = [getNextAdjacentEdge(referenceEdge)] tags = [getNextAdjacentEdge(referenceEdge)]

View File

@ -29,14 +29,14 @@ getOppositeEdge(tag: TagIdentifier) -> Uuid
```js ```js
exampleSketch = startSketchOn('XZ') exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line([10, 0], %) |> line(end = [10, 0])
|> angledLine({ angle = 60, length = 10 }, %) |> angledLine({ angle = 60, length = 10 }, %)
|> angledLine({ angle = 120, length = 10 }, %) |> angledLine({ angle = 120, length = 10 }, %)
|> line([-10, 0], %) |> line(end = [-10, 0])
|> angledLine({ angle = 240, length = 10 }, %, $referenceEdge) |> angledLine({ angle = 240, length = 10 }, %, $referenceEdge)
|> close(%) |> close()
example = extrude(5, exampleSketch) example = extrude(exampleSketch, length = 5)
|> fillet({ |> fillet({
radius = 3, radius = 3,
tags = [getOppositeEdge(referenceEdge)] tags = [getOppositeEdge(referenceEdge)]

View File

@ -29,14 +29,14 @@ getPreviousAdjacentEdge(tag: TagIdentifier) -> Uuid
```js ```js
exampleSketch = startSketchOn('XZ') exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line([10, 0], %) |> line(end = [10, 0])
|> angledLine({ angle = 60, length = 10 }, %) |> angledLine({ angle = 60, length = 10 }, %)
|> angledLine({ angle = 120, length = 10 }, %) |> angledLine({ angle = 120, length = 10 }, %)
|> line([-10, 0], %) |> line(end = [-10, 0])
|> angledLine({ angle = 240, length = 10 }, %, $referenceEdge) |> angledLine({ angle = 240, length = 10 }, %, $referenceEdge)
|> close(%) |> close()
example = extrude(5, exampleSketch) example = extrude(exampleSketch, length = 5)
|> fillet({ |> fillet({
radius = 3, radius = 3,
tags = [getPreviousAdjacentEdge(referenceEdge)] tags = [getPreviousAdjacentEdge(referenceEdge)]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -31,11 +31,11 @@ hollow(thickness: number, solid: Solid) -> Solid
// Hollow a basic sketch. // Hollow a basic sketch.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line([24, 0], %) |> line(end = [24, 0])
|> line([0, -24], %) |> line(end = [0, -24])
|> line([-24, 0], %) |> line(end = [-24, 0])
|> close(%) |> close()
|> extrude(6, %) |> extrude(length = 6)
|> hollow(0.25, %) |> hollow(0.25, %)
``` ```
@ -45,11 +45,11 @@ firstSketch = startSketchOn('XY')
// Hollow a basic sketch. // Hollow a basic sketch.
firstSketch = startSketchOn('-XZ') firstSketch = startSketchOn('-XZ')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line([24, 0], %) |> line(end = [24, 0])
|> line([0, -24], %) |> line(end = [0, -24])
|> line([-24, 0], %) |> line(end = [-24, 0])
|> close(%) |> close()
|> extrude(6, %) |> extrude(length = 6)
|> hollow(0.5, %) |> hollow(0.5, %)
``` ```
@ -60,25 +60,25 @@ firstSketch = startSketchOn('-XZ')
size = 100 size = 100
case = startSketchOn('-XZ') case = startSketchOn('-XZ')
|> startProfileAt([-size, -size], %) |> startProfileAt([-size, -size], %)
|> line([2 * size, 0], %) |> line(end = [2 * size, 0])
|> line([0, 2 * size], %) |> line(end = [0, 2 * size])
|> tangentialArcTo([-size, size], %) |> tangentialArcTo([-size, size], %)
|> close(%) |> close()
|> extrude(65, %) |> extrude(length = 65)
thing1 = startSketchOn(case, 'end') thing1 = startSketchOn(case, 'end')
|> circle({ |> circle({
center = [-size / 2, -size / 2], center = [-size / 2, -size / 2],
radius = 25 radius = 25
}, %) }, %)
|> extrude(50, %) |> extrude(length = 50)
thing2 = startSketchOn(case, 'end') thing2 = startSketchOn(case, 'end')
|> circle({ |> circle({
center = [size / 2, -size / 2], center = [size / 2, -size / 2],
radius = 25 radius = 25
}, %) }, %)
|> extrude(50, %) |> extrude(length = 50)
hollow(0.5, case) hollow(0.5, case)
``` ```

View File

@ -59,7 +59,6 @@ layout: manual
* [`legAngY`](kcl/legAngY) * [`legAngY`](kcl/legAngY)
* [`legLen`](kcl/legLen) * [`legLen`](kcl/legLen)
* [`line`](kcl/line) * [`line`](kcl/line)
* [`lineTo`](kcl/lineTo)
* [`ln`](kcl/ln) * [`ln`](kcl/ln)
* [`loft`](kcl/loft) * [`loft`](kcl/loft)
* [`log`](kcl/log) * [`log`](kcl/log)

View File

@ -38,7 +38,7 @@ assertEqual(n, 3, 0.0001, "5/2 = 2.5, rounded up makes 3")
// Draw n cylinders. // Draw n cylinders.
startSketchOn('XZ') startSketchOn('XZ')
|> circle({ center = [0, 0], radius = 2 }, %) |> circle({ center = [0, 0], radius = 2 }, %)
|> extrude(5, %) |> extrude(length = 5)
|> patternTransform(n, fn(id) { |> patternTransform(n, fn(id) {
return { translate = [4 * id, 0, 0] } return { translate = [4 * id, 0, 0] }
}, %) }, %)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -34,18 +34,18 @@ loft(sketches: [Sketch], v_degree: NonZeroU32, bez_approximate_rational: bool, b
// Loft a square and a triangle. // Loft a square and a triangle.
squareSketch = startSketchOn('XY') squareSketch = startSketchOn('XY')
|> startProfileAt([-100, 200], %) |> startProfileAt([-100, 200], %)
|> line([200, 0], %) |> line(end = [200, 0])
|> line([0, -200], %) |> line(end = [0, -200])
|> line([-200, 0], %) |> line(end = [-200, 0])
|> lineTo([profileStartX(%), profileStartY(%)], %) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close(%) |> close()
triangleSketch = startSketchOn(offsetPlane('XY', 75)) triangleSketch = startSketchOn(offsetPlane('XY', 75))
|> startProfileAt([0, 125], %) |> startProfileAt([0, 125], %)
|> line([-15, -30], %) |> line(end = [-15, -30])
|> line([30, 0], %) |> line(end = [30, 0])
|> lineTo([profileStartX(%), profileStartY(%)], %) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close(%) |> close()
loft([squareSketch, triangleSketch]) loft([squareSketch, triangleSketch])
``` ```
@ -56,11 +56,11 @@ loft([squareSketch, triangleSketch])
// Loft a square, a circle, and another circle. // Loft a square, a circle, and another circle.
squareSketch = startSketchOn('XY') squareSketch = startSketchOn('XY')
|> startProfileAt([-100, 200], %) |> startProfileAt([-100, 200], %)
|> line([200, 0], %) |> line(end = [200, 0])
|> line([0, -200], %) |> line(end = [0, -200])
|> line([-200, 0], %) |> line(end = [-200, 0])
|> lineTo([profileStartX(%), profileStartY(%)], %) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close(%) |> close()
circleSketch0 = startSketchOn(offsetPlane('XY', 75)) circleSketch0 = startSketchOn(offsetPlane('XY', 75))
|> circle({ center = [0, 100], radius = 50 }, %) |> circle({ center = [0, 100], radius = 50 }, %)
@ -81,11 +81,11 @@ loft([
// Loft a square, a circle, and another circle with options. // Loft a square, a circle, and another circle with options.
squareSketch = startSketchOn('XY') squareSketch = startSketchOn('XY')
|> startProfileAt([-100, 200], %) |> startProfileAt([-100, 200], %)
|> line([200, 0], %) |> line(end = [200, 0])
|> line([0, -200], %) |> line(end = [0, -200])
|> line([-200, 0], %) |> line(end = [-200, 0])
|> lineTo([profileStartX(%), profileStartY(%)], %) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close(%) |> close()
circleSketch0 = startSketchOn(offsetPlane('XY', 75)) circleSketch0 = startSketchOn(offsetPlane('XY', 75))
|> circle({ center = [0, 100], radius = 50 }, %) |> circle({ center = [0, 100], radius = 50 }, %)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -31,7 +31,7 @@ patternCircular3d(data: CircularPattern3dData, solid_set: SolidSet) -> [Solid]
exampleSketch = startSketchOn('XZ') exampleSketch = startSketchOn('XZ')
|> circle({ center = [0, 0], radius = 1 }, %) |> circle({ center = [0, 0], radius = 1 }, %)
example = extrude(-5, exampleSketch) example = extrude(exampleSketch, length = -5)
|> patternCircular3d({ |> patternCircular3d({
axis = [1, -1, 0], axis = [1, -1, 0],
center = [10, -20, 0], center = [10, -20, 0],

File diff suppressed because one or more lines are too long

View File

@ -30,12 +30,12 @@ patternLinear3d(data: LinearPattern3dData, solid_set: SolidSet) -> [Solid]
```js ```js
exampleSketch = startSketchOn('XZ') exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line([0, 2], %) |> line(end = [0, 2])
|> line([3, 1], %) |> line(end = [3, 1])
|> line([0, -4], %) |> line(end = [0, -4])
|> close(%) |> close()
example = extrude(1, exampleSketch) example = extrude(exampleSketch, length = 1)
|> patternLinear3d({ |> patternLinear3d({
axis = [1, 0, 1], axis = [1, 0, 1],
instances = 7, instances = 7,

View File

@ -63,7 +63,7 @@ fn transform(id) {
// Sketch 4 cylinders. // Sketch 4 cylinders.
sketch001 = startSketchOn('XZ') sketch001 = startSketchOn('XZ')
|> circle({ center = [0, 0], radius = 2 }, %) |> circle({ center = [0, 0], radius = 2 }, %)
|> extrude(5, %) |> extrude(length = 5)
|> patternTransform(4, transform, %) |> patternTransform(4, transform, %)
``` ```
@ -79,7 +79,7 @@ fn transform(id) {
sketch001 = startSketchOn('XZ') sketch001 = startSketchOn('XZ')
|> circle({ center = [0, 0], radius = 2 }, %) |> circle({ center = [0, 0], radius = 2 }, %)
|> extrude(5, %) |> extrude(length = 5)
|> patternTransform(4, transform, %) |> patternTransform(4, transform, %)
``` ```
@ -97,12 +97,12 @@ fn cube(length, center) {
return startSketchOn('XY') return startSketchOn('XY')
|> startProfileAt(p0, %) |> startProfileAt(p0, %)
|> lineTo(p1, %) |> line(endAbsolute = p1)
|> lineTo(p2, %) |> line(endAbsolute = p2)
|> lineTo(p3, %) |> line(endAbsolute = p3)
|> lineTo(p0, %) |> line(endAbsolute = p0)
|> close(%) |> close()
|> extrude(length, %) |> extrude(length = length)
} }
width = 20 width = 20
@ -135,12 +135,12 @@ fn cube(length, center) {
return startSketchOn('XY') return startSketchOn('XY')
|> startProfileAt(p0, %) |> startProfileAt(p0, %)
|> lineTo(p1, %) |> line(endAbsolute = p1)
|> lineTo(p2, %) |> line(endAbsolute = p2)
|> lineTo(p3, %) |> line(endAbsolute = p3)
|> lineTo(p0, %) |> line(endAbsolute = p0)
|> close(%) |> close()
|> extrude(length, %) |> extrude(length = length)
} }
width = 20 width = 20
@ -179,7 +179,7 @@ fn layer() {
return startSketchOn("XY") return startSketchOn("XY")
// or some other plane idk // or some other plane idk
|> circle({ center = [0, 0], radius = 1 }, %, $tag1) |> circle({ center = [0, 0], radius = 1 }, %, $tag1)
|> extrude(h, %) |> extrude(length = h)
} }
// The vase is 100 layers tall. // The vase is 100 layers tall.
// The 100 layers are replica of each other, with a slight transformation applied to each. // The 100 layers are replica of each other, with a slight transformation applied to each.
@ -205,7 +205,7 @@ startSketchOn('XY')
center = [0, 0], center = [0, 0],
inscribed = false inscribed = false
}, %) }, %)
|> extrude(4, %) |> extrude(length = 4)
|> patternTransform(3, transform, %) |> patternTransform(3, transform, %)
``` ```

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -30,12 +30,12 @@ segEnd(tag: TagIdentifier) -> [number]
w = 15 w = 15
cube = startSketchOn('XY') cube = startSketchOn('XY')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line([w, 0], %, $line1) |> line(end = [w, 0], tag = $line1)
|> line([0, w], %, $line2) |> line(end = [0, w], tag = $line2)
|> line([-w, 0], %, $line3) |> line(end = [-w, 0], tag = $line3)
|> line([0, -w], %, $line4) |> line(end = [0, -w], tag = $line4)
|> close(%) |> close()
|> extrude(5, %) |> extrude(length = 5)
fn cylinder(radius, tag) { fn cylinder(radius, tag) {
return startSketchOn('XY') return startSketchOn('XY')
@ -44,7 +44,7 @@ fn cylinder(radius, tag) {
radius = radius, radius = radius,
center = segEnd(tag) center = segEnd(tag)
}, %) }, %)
|> extrude(radius, %) |> extrude(length = radius)
} }
cylinder(1, line1) cylinder(1, line1)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -30,12 +30,12 @@ segStart(tag: TagIdentifier) -> [number]
w = 15 w = 15
cube = startSketchOn('XY') cube = startSketchOn('XY')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line([w, 0], %, $line1) |> line(end = [w, 0], tag = $line1)
|> line([0, w], %, $line2) |> line(end = [0, w], tag = $line2)
|> line([-w, 0], %, $line3) |> line(end = [-w, 0], tag = $line3)
|> line([0, -w], %, $line4) |> line(end = [0, -w], tag = $line4)
|> close(%) |> close()
|> extrude(5, %) |> extrude(length = 5)
fn cylinder(radius, tag) { fn cylinder(radius, tag) {
return startSketchOn('XY') return startSketchOn('XY')
@ -44,7 +44,7 @@ fn cylinder(radius, tag) {
radius = radius, radius = radius,
center = segStart(tag) center = segStart(tag)
}, %) }, %)
|> extrude(radius, %) |> extrude(length = radius)
} }
cylinder(1, line1) cylinder(1, line1)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -31,11 +31,11 @@ shell(data: ShellData, solid_set: SolidSet) -> SolidSet
// Remove the end face for the extrusion. // Remove the end face for the extrusion.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line([24, 0], %) |> line(end = [24, 0])
|> line([0, -24], %) |> line(end = [0, -24])
|> line([-24, 0], %) |> line(end = [-24, 0])
|> close(%) |> close()
|> extrude(6, %) |> extrude(length = 6)
// Remove the end face for the extrusion. // Remove the end face for the extrusion.
shell({ faces = ['end'], thickness = 0.25 }, firstSketch) shell({ faces = ['end'], thickness = 0.25 }, firstSketch)
@ -47,11 +47,11 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch)
// Remove the start face for the extrusion. // Remove the start face for the extrusion.
firstSketch = startSketchOn('-XZ') firstSketch = startSketchOn('-XZ')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line([24, 0], %) |> line(end = [24, 0])
|> line([0, -24], %) |> line(end = [0, -24])
|> line([-24, 0], %) |> line(end = [-24, 0])
|> close(%) |> close()
|> extrude(6, %) |> extrude(length = 6)
// Remove the start face for the extrusion. // Remove the start face for the extrusion.
shell({ faces = ['start'], thickness = 0.25 }, firstSketch) shell({ faces = ['start'], thickness = 0.25 }, firstSketch)
@ -63,11 +63,11 @@ shell({ faces = ['start'], thickness = 0.25 }, firstSketch)
// Remove a tagged face and the end face for the extrusion. // Remove a tagged face and the end face for the extrusion.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line([24, 0], %) |> line(end = [24, 0])
|> line([0, -24], %) |> line(end = [0, -24])
|> line([-24, 0], %, $myTag) |> line(end = [-24, 0], tag = $myTag)
|> close(%) |> close()
|> extrude(6, %) |> extrude(length = 6)
// Remove a tagged face for the extrusion. // Remove a tagged face for the extrusion.
shell({ faces = [myTag], thickness = 0.25 }, firstSketch) shell({ faces = [myTag], thickness = 0.25 }, firstSketch)
@ -79,11 +79,11 @@ shell({ faces = [myTag], thickness = 0.25 }, firstSketch)
// Remove multiple faces at once. // Remove multiple faces at once.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line([24, 0], %) |> line(end = [24, 0])
|> line([0, -24], %) |> line(end = [0, -24])
|> line([-24, 0], %, $myTag) |> line(end = [-24, 0], tag = $myTag)
|> close(%) |> close()
|> extrude(6, %) |> extrude(length = 6)
// Remove a tagged face and the end face for the extrusion. // Remove a tagged face and the end face for the extrusion.
shell({ shell({
@ -99,25 +99,25 @@ shell({
size = 100 size = 100
case = startSketchOn('-XZ') case = startSketchOn('-XZ')
|> startProfileAt([-size, -size], %) |> startProfileAt([-size, -size], %)
|> line([2 * size, 0], %) |> line(end = [2 * size, 0])
|> line([0, 2 * size], %) |> line(end = [0, 2 * size])
|> tangentialArcTo([-size, size], %) |> tangentialArcTo([-size, size], %)
|> close(%) |> close()
|> extrude(65, %) |> extrude(length = 65)
thing1 = startSketchOn(case, 'end') thing1 = startSketchOn(case, 'end')
|> circle({ |> circle({
center = [-size / 2, -size / 2], center = [-size / 2, -size / 2],
radius = 25 radius = 25
}, %) }, %)
|> extrude(50, %) |> extrude(length = 50)
thing2 = startSketchOn(case, 'end') thing2 = startSketchOn(case, 'end')
|> circle({ |> circle({
center = [size / 2, -size / 2], center = [size / 2, -size / 2],
radius = 25 radius = 25
}, %) }, %)
|> extrude(50, %) |> extrude(length = 50)
// We put "case" in the shell function to shell the entire object. // We put "case" in the shell function to shell the entire object.
shell({ faces = ['start'], thickness = 5 }, case) shell({ faces = ['start'], thickness = 5 }, case)
@ -130,25 +130,25 @@ shell({ faces = ['start'], thickness = 5 }, case)
size = 100 size = 100
case = startSketchOn('XY') case = startSketchOn('XY')
|> startProfileAt([-size, -size], %) |> startProfileAt([-size, -size], %)
|> line([2 * size, 0], %) |> line(end = [2 * size, 0])
|> line([0, 2 * size], %) |> line(end = [0, 2 * size])
|> tangentialArcTo([-size, size], %) |> tangentialArcTo([-size, size], %)
|> close(%) |> close()
|> extrude(65, %) |> extrude(length = 65)
thing1 = startSketchOn(case, 'end') thing1 = startSketchOn(case, 'end')
|> circle({ |> circle({
center = [-size / 2, -size / 2], center = [-size / 2, -size / 2],
radius = 25 radius = 25
}, %) }, %)
|> extrude(50, %) |> extrude(length = 50)
thing2 = startSketchOn(case, 'end') thing2 = startSketchOn(case, 'end')
|> circle({ |> circle({
center = [size / 2, -size / 2], center = [size / 2, -size / 2],
radius = 25 radius = 25
}, %) }, %)
|> extrude(50, %) |> extrude(length = 50)
// We put "thing1" in the shell function to shell the end face of the object. // We put "thing1" in the shell function to shell the end face of the object.
shell({ faces = ['end'], thickness = 5 }, thing1) shell({ faces = ['end'], thickness = 5 }, thing1)
@ -164,25 +164,25 @@ shell({ faces = ['end'], thickness = 5 }, thing1)
size = 100 size = 100
case = startSketchOn('XY') case = startSketchOn('XY')
|> startProfileAt([-size, -size], %) |> startProfileAt([-size, -size], %)
|> line([2 * size, 0], %) |> line(end = [2 * size, 0])
|> line([0, 2 * size], %) |> line(end = [0, 2 * size])
|> tangentialArcTo([-size, size], %) |> tangentialArcTo([-size, size], %)
|> close(%) |> close()
|> extrude(65, %) |> extrude(length = 65)
thing1 = startSketchOn(case, 'end') thing1 = startSketchOn(case, 'end')
|> circle({ |> circle({
center = [-size / 2, -size / 2], center = [-size / 2, -size / 2],
radius = 25 radius = 25
}, %) }, %)
|> extrude(50, %) |> extrude(length = 50)
thing2 = startSketchOn(case, 'end') thing2 = startSketchOn(case, 'end')
|> circle({ |> circle({
center = [size / 2, -size / 2], center = [size / 2, -size / 2],
radius = 25 radius = 25
}, %) }, %)
|> extrude(50, %) |> extrude(length = 50)
// We put "thing1" and "thing2" in the shell function to shell the end face of the object. // We put "thing1" and "thing2" in the shell function to shell the end face of the object.
shell({ faces = ['end'], thickness = 5 }, [thing1, thing2]) shell({ faces = ['end'], thickness = 5 }, [thing1, thing2])

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -34,11 +34,11 @@ sweep(data: SweepData, sketch: Sketch) -> Solid
// Create a path for the sweep. // Create a path for the sweep.
sweepPath = startSketchOn('XZ') sweepPath = startSketchOn('XZ')
|> startProfileAt([0.05, 0.05], %) |> startProfileAt([0.05, 0.05], %)
|> line([0, 7], %) |> line(end = [0, 7])
|> tangentialArc({ offset = 90, radius = 5 }, %) |> tangentialArc({ offset = 90, radius = 5 }, %)
|> line([-3, 0], %) |> line(end = [-3, 0])
|> tangentialArc({ offset = -90, radius = 5 }, %) |> tangentialArc({ offset = -90, radius = 5 }, %)
|> line([0, 7], %) |> line(end = [0, 7])
// Create a hole for the pipe. // Create a hole for the pipe.
pipeHole = startSketchOn('XY') pipeHole = startSketchOn('XY')

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -13,8 +13,8 @@ export fn buildSketch = (plane, offset) => {
h = height() h = height()
return startSketchOn(plane) return startSketchOn(plane)
|> startProfileAt(offset, %) |> startProfileAt(offset, %)
|> line([w, 0], %) |> line(end = [w, 0])
|> line([0, h], %) |> line(end = [0, h])
|> line([-w, 0], %) |> line(end = [-w, 0])
|> close(%) |> close()
} }

View File

@ -2957,20 +2957,20 @@ fn hmm = (x) => {
return x return x
} }
const yo = 5 + 6 yo = 5 + 6
const abc = 3 abc = 3
const identifierGuy = 5 identifierGuy = 5
const part001 = startSketchOn('XY') part001 = startSketchOn('XY')
|> startProfileAt([-1.2, 4.83], %) |> startProfileAt([-1.2, 4.83], %)
|> line([2.8, 0], %) |> line(end = [2.8, 0])
|> angledLine([100 + 100, 3.01], %) |> angledLine([100 + 100, 3.01], %)
|> angledLine([abc, 3.02], %) |> angledLine([abc, 3.02], %)
|> angledLine([def(yo), 3.03], %) |> angledLine([def(yo), 3.03], %)
|> angledLine([ghi(2), 3.04], %) |> angledLine([ghi(2), 3.04], %)
|> angledLine([jkl(yo) + 2, 3.05], %) |> angledLine([jkl(yo) + 2, 3.05], %)
|> close(%) |> close()
const yo2 = hmm([identifierGuy + 5])"#; yo2 = hmm([identifierGuy + 5])"#;
parse_execute(ast).await.unwrap(); parse_execute(ast).await.unwrap();
} }
@ -2980,11 +2980,11 @@ const yo2 = hmm([identifierGuy + 5])"#;
let ast = r#"const myVar = 3 let ast = r#"const myVar = 3
const part001 = startSketchOn('XY') const part001 = startSketchOn('XY')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line([3, 4], %, $seg01) |> line(end = [3, 4], tag = $seg01)
|> line([ |> line(end = [
min(segLen(seg01), myVar), min(segLen(seg01), myVar),
-legLen(segLen(seg01), myVar) -legLen(segLen(seg01), myVar)
], %) ])
"#; "#;
parse_execute(ast).await.unwrap(); parse_execute(ast).await.unwrap();
@ -2995,11 +2995,11 @@ const part001 = startSketchOn('XY')
let ast = r#"const myVar = 3 let ast = r#"const myVar = 3
const part001 = startSketchOn('XY') const part001 = startSketchOn('XY')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line([3, 4], %, $seg01) |> line(end = [3, 4], tag = $seg01)
|> line([ |> line(end = [
min(segLen(seg01), myVar), min(segLen(seg01), myVar),
legLen(segLen(seg01), myVar) legLen(segLen(seg01), myVar)
], %) ])
"#; "#;
parse_execute(ast).await.unwrap(); parse_execute(ast).await.unwrap();
@ -3039,11 +3039,11 @@ fn thing = () => {
const firstExtrude = startSketchOn('XY') const firstExtrude = startSketchOn('XY')
|> startProfileAt([0,0], %) |> startProfileAt([0,0], %)
|> line([0, l], %) |> line(end = [0, l])
|> line([w, 0], %) |> line(end = [w, 0])
|> line([0, thing()], %) |> line(end = [0, thing()])
|> close(%) |> close()
|> extrude(h, %)"#; |> extrude(length = h)"#;
parse_execute(ast).await.unwrap(); parse_execute(ast).await.unwrap();
} }
@ -3060,11 +3060,11 @@ fn thing = (x) => {
const firstExtrude = startSketchOn('XY') const firstExtrude = startSketchOn('XY')
|> startProfileAt([0,0], %) |> startProfileAt([0,0], %)
|> line([0, l], %) |> line(end = [0, l])
|> line([w, 0], %) |> line(end = [w, 0])
|> line([0, thing(8)], %) |> line(end = [0, thing(8)])
|> close(%) |> close()
|> extrude(h, %)"#; |> extrude(length = h)"#;
parse_execute(ast).await.unwrap(); parse_execute(ast).await.unwrap();
} }
@ -3081,11 +3081,11 @@ fn thing = (x) => {
const firstExtrude = startSketchOn('XY') const firstExtrude = startSketchOn('XY')
|> startProfileAt([0,0], %) |> startProfileAt([0,0], %)
|> line([0, l], %) |> line(end = [0, l])
|> line([w, 0], %) |> line(end = [w, 0])
|> line(thing(8), %) |> line(end = thing(8))
|> close(%) |> close()
|> extrude(h, %)"#; |> extrude(length = h)"#;
parse_execute(ast).await.unwrap(); parse_execute(ast).await.unwrap();
} }
@ -3106,11 +3106,11 @@ fn thing = (x) => {
const firstExtrude = startSketchOn('XY') const firstExtrude = startSketchOn('XY')
|> startProfileAt([0,0], %) |> startProfileAt([0,0], %)
|> line([0, l], %) |> line(end = [0, l])
|> line([w, 0], %) |> line(end = [w, 0])
|> line([0, thing(8)], %) |> line(end = [0, thing(8)])
|> close(%) |> close()
|> extrude(h, %)"#; |> extrude(length = h)"#;
parse_execute(ast).await.unwrap(); parse_execute(ast).await.unwrap();
} }
@ -3120,11 +3120,11 @@ const firstExtrude = startSketchOn('XY')
let ast = r#"fn box = (h, l, w) => { let ast = r#"fn box = (h, l, w) => {
const myBox = startSketchOn('XY') const myBox = startSketchOn('XY')
|> startProfileAt([0,0], %) |> startProfileAt([0,0], %)
|> line([0, l], %) |> line(end = [0, l])
|> line([w, 0], %) |> line(end = [w, 0])
|> line([0, -l], %) |> line(end = [0, -l])
|> close(%) |> close()
|> extrude(h, %) |> extrude(length = h)
return myBox return myBox
} }
@ -3139,11 +3139,11 @@ const fnBox = box(3, 6, 10)"#;
let ast = r#"fn box = (obj) => { let ast = r#"fn box = (obj) => {
let myBox = startSketchOn('XY') let myBox = startSketchOn('XY')
|> startProfileAt(obj.start, %) |> startProfileAt(obj.start, %)
|> line([0, obj.l], %) |> line(end = [0, obj.l])
|> line([obj.w, 0], %) |> line(end = [obj.w, 0])
|> line([0, -obj.l], %) |> line(end = [0, -obj.l])
|> close(%) |> close()
|> extrude(obj.h, %) |> extrude(length = obj.h)
return myBox return myBox
} }
@ -3158,11 +3158,11 @@ const thisBox = box({start: [0,0], l: 6, w: 10, h: 3})
let ast = r#"fn box = (obj) => { let ast = r#"fn box = (obj) => {
let myBox = startSketchOn('XY') let myBox = startSketchOn('XY')
|> startProfileAt(obj["start"], %) |> startProfileAt(obj["start"], %)
|> line([0, obj["l"]], %) |> line(end = [0, obj["l"]])
|> line([obj["w"], 0], %) |> line(end = [obj["w"], 0])
|> line([0, -obj["l"]], %) |> line(end = [0, -obj["l"]])
|> close(%) |> close()
|> extrude(obj["h"], %) |> extrude(length = obj["h"])
return myBox return myBox
} }
@ -3177,11 +3177,11 @@ const thisBox = box({start: [0,0], l: 6, w: 10, h: 3})
let ast = r#"fn box = (obj) => { let ast = r#"fn box = (obj) => {
let myBox = startSketchOn('XY') let myBox = startSketchOn('XY')
|> startProfileAt(obj["start"], %) |> startProfileAt(obj["start"], %)
|> line([0, obj["l"]], %) |> line(end = [0, obj["l"]])
|> line([obj["w"], 0], %) |> line(end = [obj["w"], 0])
|> line([10 - obj["w"], -obj.l], %) |> line(end = [10 - obj["w"], -obj.l])
|> close(%) |> close()
|> extrude(obj["h"], %) |> extrude(length = obj["h"])
return myBox return myBox
} }
@ -3199,17 +3199,17 @@ fn test2 = () => {
return { return {
thing: startSketchOn('XY') thing: startSketchOn('XY')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line([0, 1], %) |> line(end = [0, 1])
|> line([1, 0], %) |> line(end = [1, 0])
|> line([0, -1], %) |> line(end = [0, -1])
|> close(%) |> close()
} }
} }
const x2 = test2() const x2 = test2()
x2.thing x2.thing
|> extrude(10, %) |> extrude(length = 10)
"#; "#;
parse_execute(ast).await.unwrap(); parse_execute(ast).await.unwrap();
} }
@ -3220,11 +3220,11 @@ x2.thing
let ast = r#"fn box = (obj) => { let ast = r#"fn box = (obj) => {
let myBox = startSketchOn('XY') let myBox = startSketchOn('XY')
|> startProfileAt(obj.start, %) |> startProfileAt(obj.start, %)
|> line([0, obj.l], %) |> line(end = [0, obj.l])
|> line([obj.w, 0], %) |> line(end = [obj.w, 0])
|> line([0, -obj.l], %) |> line(end = [0, -obj.l])
|> close(%) |> close()
|> extrude(obj.h, %) |> extrude(length = obj.h)
return myBox return myBox
} }
@ -3242,11 +3242,11 @@ for var in [{start: [0,0], l: 6, w: 10, h: 3}, {start: [-10,-10], l: 3, w: 5, h:
let ast = r#"fn box = (h, l, w, start) => { let ast = r#"fn box = (h, l, w, start) => {
const myBox = startSketchOn('XY') const myBox = startSketchOn('XY')
|> startProfileAt([0,0], %) |> startProfileAt([0,0], %)
|> line([0, l], %) |> line(end = [0, l])
|> line([w, 0], %) |> line(end = [w, 0])
|> line([0, -l], %) |> line(end = [0, -l])
|> close(%) |> close()
|> extrude(h, %) |> extrude(length = h)
return myBox return myBox
} }
@ -3264,11 +3264,11 @@ for var in [[3, 6, 10, [0,0]], [1.5, 3, 5, [-10,-10]]] {
let ast = r#"fn box = (arr) => { let ast = r#"fn box = (arr) => {
let myBox =startSketchOn('XY') let myBox =startSketchOn('XY')
|> startProfileAt(arr[0], %) |> startProfileAt(arr[0], %)
|> line([0, arr[1]], %) |> line(end = [0, arr[1]])
|> line([arr[2], 0], %) |> line(end = [arr[2], 0])
|> line([0, -arr[1]], %) |> line(end = [0, -arr[1]])
|> close(%) |> close()
|> extrude(arr[3], %) |> extrude(length = arr[3])
return myBox return myBox
} }
@ -3342,7 +3342,7 @@ fn transform = (replicaId) => {
fn layer = () => { fn layer = () => {
return startSketchOn("XY") return startSketchOn("XY")
|> circle({ center: [0, 0], radius: 1 }, %, $tag1) |> circle({ center: [0, 0], radius: 1 }, %, $tag1)
|> extrude(10, %) |> extrude(length = 10)
} }
const x = 5 const x = 5
@ -3430,10 +3430,10 @@ fn thickness = () => { return 0.56 }
const bracket = startSketchOn('XY') const bracket = startSketchOn('XY')
|> startProfileAt([0,0], %) |> startProfileAt([0,0], %)
|> line([0, leg1], %) |> line(end = [0, leg1])
|> line([leg2, 0], %) |> line(end = [leg2, 0])
|> line([0, -thickness()], %) |> line(end = [0, -thickness()])
|> line([-leg2 + thickness(), 0], %) |> line(end = [-leg2 + thickness(), 0])
"#; "#;
parse_execute(ast).await.unwrap(); parse_execute(ast).await.unwrap();
} }
@ -3621,10 +3621,10 @@ const thickness = 0.56 // inches. App does not support square root function yet
const bracket = startSketchOn('XY') const bracket = startSketchOn('XY')
|> startProfileAt([0,0], %) |> startProfileAt([0,0], %)
|> line([0, leg1], %) |> line(end = [0, leg1])
|> line([leg2, 0], %) |> line(end = [leg2, 0])
|> line([0, -thickness], %) |> line(end = [0, -thickness])
|> line([-leg2 + thickness, 0], %) |> line(end = [-leg2 + thickness, 0])
"#; "#;
parse_execute(ast).await.unwrap(); parse_execute(ast).await.unwrap();
} }
@ -3658,13 +3658,13 @@ const thickness_squared = (distance * p * FOS * 6 / (sigmaAllow - width))
const thickness = 0.32 // inches. App does not support square root function yet const thickness = 0.32 // inches. App does not support square root function yet
const bracket = startSketchOn('XY') const bracket = startSketchOn('XY')
|> startProfileAt([0,0], %) |> startProfileAt([0,0], %)
|> line([0, leg1], %) |> line(end = [0, leg1])
|> line([leg2, 0], %) |> line(end = [leg2, 0])
|> line([0, -thickness], %) |> line(end = [0, -thickness])
|> line([-1 * leg2 + thickness, 0], %) |> line(end = [-1 * leg2 + thickness, 0])
|> line([0, -1 * leg1 + thickness], %) |> line(end = [0, -1 * leg1 + thickness])
|> close(%) |> close()
|> extrude(width, %) |> extrude(length = width)
"#; "#;
parse_execute(ast).await.unwrap(); parse_execute(ast).await.unwrap();
} }
@ -3682,13 +3682,13 @@ const thickness_squared = distance * p * FOS * 6 / (sigmaAllow - width)
const thickness = 0.32 // inches. App does not support square root function yet const thickness = 0.32 // inches. App does not support square root function yet
const bracket = startSketchOn('XY') const bracket = startSketchOn('XY')
|> startProfileAt([0,0], %) |> startProfileAt([0,0], %)
|> line([0, leg1], %) |> line(end = [0, leg1])
|> line([leg2, 0], %) |> line(end = [leg2, 0])
|> line([0, -thickness], %) |> line(end = [0, -thickness])
|> line([-1 * leg2 + thickness, 0], %) |> line(end = [-1 * leg2 + thickness, 0])
|> line([0, -1 * leg1 + thickness], %) |> line(end = [0, -1 * leg1 + thickness])
|> close(%) |> close()
|> extrude(width, %) |> extrude(length = width)
"#; "#;
parse_execute(ast).await.unwrap(); parse_execute(ast).await.unwrap();
} }
@ -3849,11 +3849,11 @@ let w = f() + f()
let new = r#"// Remove the end face for the extrusion. let new = r#"// Remove the end face for the extrusion.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line([24, 0], %) |> line(end = [24, 0])
|> line([0, -24], %) |> line(end = [0, -24])
|> line([-24, 0], %) |> line(end = [-24, 0])
|> close(%) |> close()
|> extrude(6, %) |> extrude(length = 6)
// Remove the end face for the extrusion. // Remove the end face for the extrusion.
shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#; shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
@ -3879,11 +3879,11 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
let new = r#"// Remove the end face for the extrusion. let new = r#"// Remove the end face for the extrusion.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line([24, 0], %) |> line(end = [24, 0])
|> line([0, -24], %) |> line(end = [0, -24])
|> line([-24, 0], %) |> line(end = [-24, 0])
|> close(%) |> close()
|> extrude(6, %) |> extrude(length = 6)
// Remove the end face for the extrusion. // Remove the end face for the extrusion.
shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#; shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
@ -3909,11 +3909,11 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
let old = r#" // Remove the end face for the extrusion. let old = r#" // Remove the end face for the extrusion.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line([24, 0], %) |> line(end = [24, 0])
|> line([0, -24], %) |> line(end = [0, -24])
|> line([-24, 0], %) |> line(end = [-24, 0])
|> close(%) |> close()
|> extrude(6, %) |> extrude(length = 6)
// Remove the end face for the extrusion. // Remove the end face for the extrusion.
shell({ faces = ['end'], thickness = 0.25 }, firstSketch) "#; shell({ faces = ['end'], thickness = 0.25 }, firstSketch) "#;
@ -3921,11 +3921,11 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch) "#;
let new = r#"// Remove the end face for the extrusion. let new = r#"// Remove the end face for the extrusion.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line([24, 0], %) |> line(end = [24, 0])
|> line([0, -24], %) |> line(end = [0, -24])
|> line([-24, 0], %) |> line(end = [-24, 0])
|> close(%) |> close()
|> extrude(6, %) |> extrude(length = 6)
// Remove the end face for the extrusion. // Remove the end face for the extrusion.
shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#; shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
@ -3953,11 +3953,11 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
let old = r#" // Removed the end face for the extrusion. let old = r#" // Removed the end face for the extrusion.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line([24, 0], %) |> line(end = [24, 0])
|> line([0, -24], %) |> line(end = [0, -24])
|> line([-24, 0], %) |> line(end = [-24, 0])
|> close(%) |> close()
|> extrude(6, %) |> extrude(length = 6)
// Remove the end face for the extrusion. // Remove the end face for the extrusion.
shell({ faces = ['end'], thickness = 0.25 }, firstSketch) "#; shell({ faces = ['end'], thickness = 0.25 }, firstSketch) "#;
@ -3965,11 +3965,11 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch) "#;
let new = r#"// Remove the end face for the extrusion. let new = r#"// Remove the end face for the extrusion.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line([24, 0], %) |> line(end = [24, 0])
|> line([0, -24], %) |> line(end = [0, -24])
|> line([-24, 0], %) |> line(end = [-24, 0])
|> close(%) |> close()
|> extrude(6, %) |> extrude(length = 6)
// Remove the end face for the extrusion. // Remove the end face for the extrusion.
shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#; shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
@ -3997,11 +3997,11 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
let old = r#" // Removed the end face for the extrusion. let old = r#" // Removed the end face for the extrusion.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line([24, 0], %) |> line(end = [24, 0])
|> line([0, -24], %) |> line(end = [0, -24])
|> line([-24, 0], %) // my thing |> line(end = [-24, 0]) // my thing
|> close(%) |> close()
|> extrude(6, %) |> extrude(length = 6)
// Remove the end face for the extrusion. // Remove the end face for the extrusion.
shell({ faces = ['end'], thickness = 0.25 }, firstSketch) "#; shell({ faces = ['end'], thickness = 0.25 }, firstSketch) "#;
@ -4009,11 +4009,11 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch) "#;
let new = r#"// Remove the end face for the extrusion. let new = r#"// Remove the end face for the extrusion.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line([24, 0], %) |> line(end = [24, 0])
|> line([0, -24], %) |> line(end = [0, -24])
|> line([-24, 0], %) |> line(end = [-24, 0])
|> close(%) |> close()
|> extrude(6, %) |> extrude(length = 6)
// Remove the end face for the extrusion. // Remove the end face for the extrusion.
shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#; shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
@ -4042,11 +4042,11 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
let new = r#"// Remove the end face for the extrusion. let new = r#"// Remove the end face for the extrusion.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line([24, 0], %) |> line(end = [24, 0])
|> line([0, -24], %) |> line(end = [0, -24])
|> line([-24, 0], %) |> line(end = [-24, 0])
|> close(%) |> close()
|> extrude(6, %) |> extrude(length = 6)
// Remove the end face for the extrusion. // Remove the end face for the extrusion.
shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#; shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
@ -4081,11 +4081,11 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
let new = r#"// Remove the end face for the extrusion. let new = r#"// Remove the end face for the extrusion.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line([24, 0], %) |> line(end = [24, 0])
|> line([0, -24], %) |> line(end = [0, -24])
|> line([-24, 0], %) |> line(end = [-24, 0])
|> close(%) |> close()
|> extrude(6, %) |> extrude(length = 6)
// Remove the end face for the extrusion. // Remove the end face for the extrusion.
shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#; shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
@ -4115,11 +4115,11 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
let new = r#"// Remove the end face for the extrusion. let new = r#"// Remove the end face for the extrusion.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line([24, 0], %) |> line(end = [24, 0])
|> line([0, -24], %) |> line(end = [0, -24])
|> line([-24, 0], %) |> line(end = [-24, 0])
|> close(%) |> close()
|> extrude(6, %) |> extrude(length = 6)
// Remove the end face for the extrusion. // Remove the end face for the extrusion.
shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#; shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
@ -4150,9 +4150,9 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
|> xLine(305.11, %, $seg01) |> xLine(305.11, %, $seg01)
|> yLine(-291.85, %) |> yLine(-291.85, %)
|> xLine(-segLen(seg01), %) |> xLine(-segLen(seg01), %)
|> lineTo([profileStartX(%), profileStartY(%)], %) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close(%) |> close()
|> extrude(40.14, %) |> extrude(length = 40.14)
|> shell({ |> shell({
faces: [seg01], faces: [seg01],
thickness: 3.14, thickness: 3.14,
@ -4179,9 +4179,9 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
|> xLine(305.11, %, $seg01) |> xLine(305.11, %, $seg01)
|> yLine(-291.85, %) |> yLine(-291.85, %)
|> xLine(-segLen(seg01), %) |> xLine(-segLen(seg01), %)
|> lineTo([profileStartX(%), profileStartY(%)], %) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close(%) |> close()
|> extrude(40.14, %) |> extrude(length = 40.14)
|> shell({ |> shell({
faces: [seg01], faces: [seg01],
thickness: 3.14, thickness: 3.14,

View File

@ -18,7 +18,7 @@ use crate::{
Program, Program,
}; };
use super::types::LiteralValue; use super::types::{CallExpressionKw, Identifier, LabeledArg, LiteralValue};
type Point3d = kcmc::shared::Point3d<f64>; type Point3d = kcmc::shared::Point3d<f64>;
@ -219,16 +219,21 @@ fn create_start_sketch_on(
current_position.x += end[0]; current_position.x += end[0];
current_position.y += end[1]; current_position.y += end[1];
let initial_line = CallExpression::new( let expr = ArrayExpression::new(vec![
Literal::new(LiteralValue::from_f64_no_uom(round_before_recast(end[0]))).into(),
Literal::new(LiteralValue::from_f64_no_uom(round_before_recast(end[1]))).into(),
])
.into();
let initial_line = CallExpressionKw::new(
"line", "line",
vec![ None,
ArrayExpression::new(vec![ vec![LabeledArg {
Literal::new(LiteralValue::from_f64_no_uom(round_before_recast(end[0]))).into(), label: super::types::Identifier {
Literal::new(LiteralValue::from_f64_no_uom(round_before_recast(end[1]))).into(), name: "end".to_owned(),
]) digest: None,
.into(), },
PipeSubstitution::new().into(), arg: expr,
], }],
)?; )?;
let mut pipe_body = vec![start_sketch_on.into(), start_profile_at.into(), initial_line.into()]; let mut pipe_body = vec![start_sketch_on.into(), start_profile_at.into(), initial_line.into()];
@ -245,23 +250,28 @@ fn create_start_sketch_on(
// This is a bit more lenient if you look at the value of epsilon. // This is a bit more lenient if you look at the value of epsilon.
if diff_x <= EPSILON && diff_y <= EPSILON { if diff_x <= EPSILON && diff_y <= EPSILON {
// We have to close the sketch. // We have to close the sketch.
let close = CallExpression::new("close", vec![PipeSubstitution::new().into()])?; let close = CallExpressionKw::new("close", None, vec![])?;
pipe_body.push(close.into()); pipe_body.push(close.into());
break; break;
} }
} }
// TODO: we should check if we should close the sketch. // TODO: we should check if we should close the sketch.
let line = CallExpression::new( let expr = ArrayExpression::new(vec![
Literal::new(LiteralValue::from_f64_no_uom(round_before_recast(line[0]))).into(),
Literal::new(LiteralValue::from_f64_no_uom(round_before_recast(line[1]))).into(),
])
.into();
let line = CallExpressionKw::new(
"line", "line",
vec![ None,
ArrayExpression::new(vec![ vec![LabeledArg {
Literal::new(LiteralValue::from_f64_no_uom(round_before_recast(line[0]))).into(), arg: expr,
Literal::new(LiteralValue::from_f64_no_uom(round_before_recast(line[1]))).into(), label: Identifier {
]) name: "end".to_owned(),
.into(), digest: None,
PipeSubstitution::new().into(), },
], }],
)?; )?;
pipe_body.push(line.into()); pipe_body.push(line.into());
} }

View File

@ -4485,6 +4485,7 @@ mod snapshot_tests {
#[test] #[test]
fn $func_name() { fn $func_name() {
let module_id = crate::ModuleId::default(); let module_id = crate::ModuleId::default();
println!("{}", $test_kcl_program);
let tokens = crate::parsing::token::lex($test_kcl_program, module_id).unwrap(); let tokens = crate::parsing::token::lex($test_kcl_program, module_id).unwrap();
print_tokens(tokens.as_slice()); print_tokens(tokens.as_slice());
ParseContext::init(); ParseContext::init();

View File

@ -68,12 +68,12 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result<KclVa
/// // Add color to an extruded solid. /// // Add color to an extruded solid.
/// exampleSketch = startSketchOn("XZ") /// exampleSketch = startSketchOn("XZ")
/// |> startProfileAt([0, 0], %) /// |> startProfileAt([0, 0], %)
/// |> lineTo([10, 0], %) /// |> line(endAbsolute = [10, 0])
/// |> lineTo([0, 10], %) /// |> line(endAbsolute = [0, 10])
/// |> lineTo([-10, 0], %) /// |> line(endAbsolute = [-10, 0])
/// |> close(%) /// |> close()
/// ///
/// example = extrude(5, exampleSketch) /// example = extrude(exampleSketch, length = 5)
/// |> appearance({color= '#ff0000', metalness= 50, roughness= 50}, %) /// |> appearance({color= '#ff0000', metalness= 50, roughness= 50}, %)
/// ``` /// ```
/// ///
@ -94,11 +94,11 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result<KclVa
/// fn cube(center) { /// fn cube(center) {
/// return startSketchOn('XY') /// return startSketchOn('XY')
/// |> startProfileAt([center[0] - 10, center[1] - 10], %) /// |> startProfileAt([center[0] - 10, center[1] - 10], %)
/// |> lineTo([center[0] + 10, center[1] - 10], %) /// |> line(endAbsolute = [center[0] + 10, center[1] - 10])
/// |> lineTo([center[0] + 10, center[1] + 10], %) /// |> line(endAbsolute = [center[0] + 10, center[1] + 10])
/// |> lineTo([center[0] - 10, center[1] + 10], %) /// |> line(endAbsolute = [center[0] - 10, center[1] + 10])
/// |> close(%) /// |> close()
/// |> extrude(10, %) /// |> extrude(length = 10)
/// } /// }
/// ///
/// example0 = cube([0, 0]) /// example0 = cube([0, 0])
@ -114,11 +114,11 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result<KclVa
/// // This example shows setting the appearance _after_ the shell. /// // This example shows setting the appearance _after_ the shell.
/// firstSketch = startSketchOn('XY') /// firstSketch = startSketchOn('XY')
/// |> startProfileAt([-12, 12], %) /// |> startProfileAt([-12, 12], %)
/// |> line([24, 0], %) /// |> line(end = [24, 0])
/// |> line([0, -24], %) /// |> line(end = [0, -24])
/// |> line([-24, 0], %) /// |> line(end = [-24, 0])
/// |> close(%) /// |> close()
/// |> extrude(6, %) /// |> extrude(length = 6)
/// ///
/// shell({ /// shell({
/// faces = ['end'], /// faces = ['end'],
@ -136,11 +136,11 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result<KclVa
/// // This example shows setting the appearance _before_ the shell. /// // This example shows setting the appearance _before_ the shell.
/// firstSketch = startSketchOn('XY') /// firstSketch = startSketchOn('XY')
/// |> startProfileAt([-12, 12], %) /// |> startProfileAt([-12, 12], %)
/// |> line([24, 0], %) /// |> line(end = [24, 0])
/// |> line([0, -24], %) /// |> line(end = [0, -24])
/// |> line([-24, 0], %) /// |> line(end = [-24, 0])
/// |> close(%) /// |> close()
/// |> extrude(6, %) /// |> extrude(length = 6)
/// |> appearance({ /// |> appearance({
/// color = '#ff0000', /// color = '#ff0000',
/// metalness = 90, /// metalness = 90,
@ -158,12 +158,12 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result<KclVa
/// // This example shows _before_ the pattern. /// // This example shows _before_ the pattern.
/// exampleSketch = startSketchOn('XZ') /// exampleSketch = startSketchOn('XZ')
/// |> startProfileAt([0, 0], %) /// |> startProfileAt([0, 0], %)
/// |> line([0, 2], %) /// |> line(end = [0, 2])
/// |> line([3, 1], %) /// |> line(end = [3, 1])
/// |> line([0, -4], %) /// |> line(end = [0, -4])
/// |> close(%) /// |> close()
/// ///
/// example = extrude(1, exampleSketch) /// example = extrude(exampleSketch, length = 1)
/// |> appearance({ /// |> appearance({
/// color = '#ff0000', /// color = '#ff0000',
/// metalness = 90, /// metalness = 90,
@ -181,12 +181,12 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result<KclVa
/// // This example shows _after_ the pattern. /// // This example shows _after_ the pattern.
/// exampleSketch = startSketchOn('XZ') /// exampleSketch = startSketchOn('XZ')
/// |> startProfileAt([0, 0], %) /// |> startProfileAt([0, 0], %)
/// |> line([0, 2], %) /// |> line(end = [0, 2])
/// |> line([3, 1], %) /// |> line(end = [3, 1])
/// |> line([0, -4], %) /// |> line(end = [0, -4])
/// |> close(%) /// |> close()
/// ///
/// example = extrude(1, exampleSketch) /// example = extrude(exampleSketch, length = 1)
/// |> patternLinear3d({ /// |> patternLinear3d({
/// axis = [1, 0, 1], /// axis = [1, 0, 1],
/// instances = 7, /// instances = 7,
@ -203,10 +203,10 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result<KclVa
/// // Color the result of a 2D pattern that was extruded. /// // Color the result of a 2D pattern that was extruded.
/// exampleSketch = startSketchOn('XZ') /// exampleSketch = startSketchOn('XZ')
/// |> startProfileAt([.5, 25], %) /// |> startProfileAt([.5, 25], %)
/// |> line([0, 5], %) /// |> line(end = [0, 5])
/// |> line([-1, 0], %) /// |> line(end = [-1, 0])
/// |> line([0, -5], %) /// |> line(end = [0, -5])
/// |> close(%) /// |> close()
/// |> patternCircular2d({ /// |> patternCircular2d({
/// center = [0, 0], /// center = [0, 0],
/// instances = 13, /// instances = 13,
@ -214,7 +214,7 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result<KclVa
/// rotateDuplicates = true /// rotateDuplicates = true
/// }, %) /// }, %)
/// ///
/// example = extrude(1, exampleSketch) /// example = extrude(exampleSketch, length = 1)
/// |> appearance({ /// |> appearance({
/// color = '#ff0000', /// color = '#ff0000',
/// metalness = 90, /// metalness = 90,
@ -228,17 +228,17 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result<KclVa
/// // Create a path for the sweep. /// // Create a path for the sweep.
/// sweepPath = startSketchOn('XZ') /// sweepPath = startSketchOn('XZ')
/// |> startProfileAt([0.05, 0.05], %) /// |> startProfileAt([0.05, 0.05], %)
/// |> line([0, 7], %) /// |> line(end = [0, 7])
/// |> tangentialArc({ /// |> tangentialArc({
/// offset: 90, /// offset: 90,
/// radius: 5 /// radius: 5
/// }, %) /// }, %)
/// |> line([-3, 0], %) /// |> line(end = [-3, 0])
/// |> tangentialArc({ /// |> tangentialArc({
/// offset: -90, /// offset: -90,
/// radius: 5 /// radius: 5
/// }, %) /// }, %)
/// |> line([0, 7], %) /// |> line(end = [0, 7])
/// ///
/// pipeHole = startSketchOn('XY') /// pipeHole = startSketchOn('XY')
/// |> circle({ /// |> circle({

View File

@ -395,10 +395,6 @@ impl Args {
FromArgs::from_args(self, 0) FromArgs::from_args(self, 0)
} }
pub(crate) fn get_sketch_and_optional_tag(&self) -> Result<(Sketch, Option<TagNode>), KclError> {
FromArgs::from_args(self, 0)
}
pub(crate) fn get_data_and_optional_tag<'a, T>(&'a self) -> Result<(T, Option<FaceTag>), KclError> pub(crate) fn get_data_and_optional_tag<'a, T>(&'a self) -> Result<(T, Option<FaceTag>), KclError>
where where
T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized, T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
@ -466,10 +462,6 @@ impl Args {
FromArgs::from_args(self, 0) FromArgs::from_args(self, 0)
} }
pub(crate) fn get_number_sketch_set(&self) -> Result<(f64, SketchSet), KclError> {
FromArgs::from_args(self, 0)
}
pub(crate) async fn get_adjacent_face_to_tag( pub(crate) async fn get_adjacent_face_to_tag(
&self, &self,
exec_state: &mut ExecState, exec_state: &mut ExecState,

View File

@ -154,7 +154,7 @@ pub async fn reduce(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// // Draw one edge of the decagon. /// // Draw one edge of the decagon.
/// x = cos(stepAngle * i) * radius /// x = cos(stepAngle * i) * radius
/// y = sin(stepAngle * i) * radius /// y = sin(stepAngle * i) * radius
/// return lineTo([x, y], partialDecagon) /// return line(partialDecagon, end = [x, y])
/// }) /// })
/// ///
/// return fullDecagon /// return fullDecagon
@ -173,13 +173,13 @@ pub async fn reduce(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// for i in [1..10]: /// for i in [1..10]:
/// x = cos(stepAngle * i) * radius /// x = cos(stepAngle * i) * radius
/// y = sin(stepAngle * i) * radius /// y = sin(stepAngle * i) * radius
/// partialDecagon = lineTo([x, y], partialDecagon) /// partialDecagon = line(partialDecagon, end = [x, y])
/// fullDecagon = partialDecagon // it's now full /// fullDecagon = partialDecagon // it's now full
/// return fullDecagon /// return fullDecagon
/// */ /// */
/// ///
/// // Use the `decagon` function declared above, to sketch a decagon with radius 5. /// // Use the `decagon` function declared above, to sketch a decagon with radius 5.
/// decagon(5.0) |> close(%) /// decagon(5.0) |> close()
/// ``` /// ```
#[stdlib { #[stdlib {
name = "reduce", name = "reduce",

View File

@ -50,12 +50,12 @@ pub async fn chamfer(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// ///
/// mountingPlateSketch = startSketchOn("XY") /// mountingPlateSketch = startSketchOn("XY")
/// |> startProfileAt([-width/2, -length/2], %) /// |> startProfileAt([-width/2, -length/2], %)
/// |> lineTo([width/2, -length/2], %, $edge1) /// |> line(endAbsolute = [width/2, -length/2], tag = $edge1)
/// |> lineTo([width/2, length/2], %, $edge2) /// |> line(endAbsolute = [width/2, length/2], tag = $edge2)
/// |> lineTo([-width/2, length/2], %, $edge3) /// |> line(endAbsolute = [-width/2, length/2], tag = $edge3)
/// |> close(%, $edge4) /// |> close(tag = $edge4)
/// ///
/// mountingPlate = extrude(thickness, mountingPlateSketch) /// mountingPlate = extrude(mountingPlateSketch, length = thickness)
/// |> chamfer({ /// |> chamfer({
/// length = chamferLength, /// length = chamferLength,
/// tags = [ /// tags = [
@ -72,16 +72,16 @@ pub async fn chamfer(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// fn cube(pos, scale) { /// fn cube(pos, scale) {
/// sg = startSketchOn('XY') /// sg = startSketchOn('XY')
/// |> startProfileAt(pos, %) /// |> startProfileAt(pos, %)
/// |> line([0, scale], %) /// |> line(end = [0, scale])
/// |> line([scale, 0], %) /// |> line(end = [scale, 0])
/// |> line([0, -scale], %) /// |> line(end = [0, -scale])
/// ///
/// return sg /// return sg
/// } /// }
/// ///
/// part001 = cube([0,0], 20) /// part001 = cube([0,0], 20)
/// |> close(%, $line1) /// |> close(tag = $line1)
/// |> extrude(20, %) /// |> extrude(length = 20)
/// |> chamfer({ /// |> chamfer({
/// length = 10, /// length = 10,
/// tags = [getOppositeEdge(line1)] /// tags = [getOppositeEdge(line1)]
@ -89,12 +89,12 @@ pub async fn chamfer(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// ///
/// sketch001 = startSketchOn(part001, chamfer1) /// sketch001 = startSketchOn(part001, chamfer1)
/// |> startProfileAt([10, 10], %) /// |> startProfileAt([10, 10], %)
/// |> line([2, 0], %) /// |> line(end = [2, 0])
/// |> line([0, 2], %) /// |> line(end = [0, 2])
/// |> line([-2, 0], %) /// |> line(end = [-2, 0])
/// |> lineTo([profileStartX(%), profileStartY(%)], %) /// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
/// |> close(%) /// |> close()
/// |> extrude(10, %) /// |> extrude(length = 10)
/// ``` /// ```
#[stdlib { #[stdlib {
name = "chamfer", name = "chamfer",

View File

@ -26,7 +26,7 @@ pub async fn int(_exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kc
/// // Draw n cylinders. /// // Draw n cylinders.
/// startSketchOn('XZ') /// startSketchOn('XZ')
/// |> circle({ center = [0, 0], radius = 2 }, %) /// |> circle({ center = [0, 0], radius = 2 }, %)
/// |> extrude(5, %) /// |> extrude(length = 5)
/// |> patternTransform(n, fn(id) { /// |> patternTransform(n, fn(id) {
/// return { translate = [4 * id, 0, 0] } /// return { translate = [4 * id, 0, 0] }
/// }, %) /// }, %)

View File

@ -21,9 +21,10 @@ use crate::{
/// Extrudes by a given amount. /// Extrudes by a given amount.
pub async fn extrude(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> { pub async fn extrude(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let (length, sketch_set) = args.get_number_sketch_set()?; let sketch_set = args.get_unlabeled_kw_arg("sketch_set")?;
let length = args.get_kw_arg("length")?;
let result = inner_extrude(length, sketch_set, exec_state, args).await?; let result = inner_extrude(sketch_set, length, exec_state, args).await?;
Ok(result.into()) Ok(result.into())
} }
@ -35,22 +36,22 @@ pub async fn extrude(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// ```no_run /// ```no_run
/// example = startSketchOn('XZ') /// example = startSketchOn('XZ')
/// |> startProfileAt([0, 0], %) /// |> startProfileAt([0, 0], %)
/// |> line([10, 0], %) /// |> line(end = [10, 0])
/// |> arc({ /// |> arc({
/// angleStart = 120, /// angleStart = 120,
/// angleEnd = 0, /// angleEnd = 0,
/// radius = 5, /// radius = 5,
/// }, %) /// }, %)
/// |> line([5, 0], %) /// |> line(end = [5, 0])
/// |> line([0, 10], %) /// |> line(end = [0, 10])
/// |> bezierCurve({ /// |> bezierCurve({
/// control1 = [-10, 0], /// control1 = [-10, 0],
/// control2 = [2, 10], /// control2 = [2, 10],
/// to = [-5, 10], /// to = [-5, 10],
/// }, %) /// }, %)
/// |> line([-5, -2], %) /// |> line(end = [-5, -2])
/// |> close(%) /// |> close()
/// |> extrude(10, %) /// |> extrude(length = 10)
/// ``` /// ```
/// ///
/// ```no_run /// ```no_run
@ -61,26 +62,32 @@ pub async fn extrude(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// angleEnd = -60, /// angleEnd = -60,
/// radius = 5, /// radius = 5,
/// }, %) /// }, %)
/// |> line([10, 0], %) /// |> line(end = [10, 0])
/// |> line([5, 0], %) /// |> line(end = [5, 0])
/// |> bezierCurve({ /// |> bezierCurve({
/// control1 = [-3, 0], /// control1 = [-3, 0],
/// control2 = [2, 10], /// control2 = [2, 10],
/// to = [-5, 10], /// to = [-5, 10],
/// }, %) /// }, %)
/// |> line([-4, 10], %) /// |> line(end = [-4, 10])
/// |> line([-5, -2], %) /// |> line(end = [-5, -2])
/// |> close(%) /// |> close()
/// ///
/// example = extrude(10, exampleSketch) /// example = extrude(exampleSketch, length = 10)
/// ``` /// ```
#[stdlib { #[stdlib {
name = "extrude", name = "extrude",
feature_tree_operation = true, feature_tree_operation = true,
keywords = true,
unlabeled_first = true,
arg_docs = {
sketch_set = "Which sketches should be extruded",
length = "How far to extrude the given sketches",
}
}] }]
async fn inner_extrude( async fn inner_extrude(
length: f64,
sketch_set: SketchSet, sketch_set: SketchSet,
length: f64,
exec_state: &mut ExecState, exec_state: &mut ExecState,
args: Args, args: Args,
) -> Result<SolidSet, KclError> { ) -> Result<SolidSet, KclError> {

View File

@ -75,12 +75,12 @@ pub async fn fillet(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// ///
/// mountingPlateSketch = startSketchOn("XY") /// mountingPlateSketch = startSketchOn("XY")
/// |> startProfileAt([-width/2, -length/2], %) /// |> startProfileAt([-width/2, -length/2], %)
/// |> lineTo([width/2, -length/2], %, $edge1) /// |> line(endAbsolute = [width/2, -length/2], tag = $edge1)
/// |> lineTo([width/2, length/2], %, $edge2) /// |> line(endAbsolute = [width/2, length/2], tag = $edge2)
/// |> lineTo([-width/2, length/2], %, $edge3) /// |> line(endAbsolute = [-width/2, length/2], tag = $edge3)
/// |> close(%, $edge4) /// |> close(tag = $edge4)
/// ///
/// mountingPlate = extrude(thickness, mountingPlateSketch) /// mountingPlate = extrude(mountingPlateSketch, length = thickness)
/// |> fillet({ /// |> fillet({
/// radius = filletRadius, /// radius = filletRadius,
/// tags = [ /// tags = [
@ -100,12 +100,12 @@ pub async fn fillet(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// ///
/// mountingPlateSketch = startSketchOn("XY") /// mountingPlateSketch = startSketchOn("XY")
/// |> startProfileAt([-width/2, -length/2], %) /// |> startProfileAt([-width/2, -length/2], %)
/// |> lineTo([width/2, -length/2], %, $edge1) /// |> line(endAbsolute = [width/2, -length/2], tag = $edge1)
/// |> lineTo([width/2, length/2], %, $edge2) /// |> line(endAbsolute = [width/2, length/2], tag = $edge2)
/// |> lineTo([-width/2, length/2], %, $edge3) /// |> line(endAbsolute = [-width/2, length/2], tag = $edge3)
/// |> close(%, $edge4) /// |> close(tag = $edge4)
/// ///
/// mountingPlate = extrude(thickness, mountingPlateSketch) /// mountingPlate = extrude(mountingPlateSketch, length = thickness)
/// |> fillet({ /// |> fillet({
/// radius = filletRadius, /// radius = filletRadius,
/// tolerance = 0.000001, /// tolerance = 0.000001,
@ -198,7 +198,7 @@ pub async fn get_opposite_edge(exec_state: &mut ExecState, args: Args) -> Result
/// ```no_run /// ```no_run
/// exampleSketch = startSketchOn('XZ') /// exampleSketch = startSketchOn('XZ')
/// |> startProfileAt([0, 0], %) /// |> startProfileAt([0, 0], %)
/// |> line([10, 0], %) /// |> line(end = [10, 0])
/// |> angledLine({ /// |> angledLine({
/// angle = 60, /// angle = 60,
/// length = 10, /// length = 10,
@ -207,14 +207,14 @@ pub async fn get_opposite_edge(exec_state: &mut ExecState, args: Args) -> Result
/// angle = 120, /// angle = 120,
/// length = 10, /// length = 10,
/// }, %) /// }, %)
/// |> line([-10, 0], %) /// |> line(end = [-10, 0])
/// |> angledLine({ /// |> angledLine({
/// angle = 240, /// angle = 240,
/// length = 10, /// length = 10,
/// }, %, $referenceEdge) /// }, %, $referenceEdge)
/// |> close(%) /// |> close()
/// ///
/// example = extrude(5, exampleSketch) /// example = extrude(exampleSketch, length = 5)
/// |> fillet({ /// |> fillet({
/// radius = 3, /// radius = 3,
/// tags = [getOppositeEdge(referenceEdge)], /// tags = [getOppositeEdge(referenceEdge)],
@ -271,7 +271,7 @@ pub async fn get_next_adjacent_edge(exec_state: &mut ExecState, args: Args) -> R
/// ```no_run /// ```no_run
/// exampleSketch = startSketchOn('XZ') /// exampleSketch = startSketchOn('XZ')
/// |> startProfileAt([0, 0], %) /// |> startProfileAt([0, 0], %)
/// |> line([10, 0], %) /// |> line(end = [10, 0])
/// |> angledLine({ /// |> angledLine({
/// angle = 60, /// angle = 60,
/// length = 10, /// length = 10,
@ -280,14 +280,14 @@ pub async fn get_next_adjacent_edge(exec_state: &mut ExecState, args: Args) -> R
/// angle = 120, /// angle = 120,
/// length = 10, /// length = 10,
/// }, %) /// }, %)
/// |> line([-10, 0], %) /// |> line(end = [-10, 0])
/// |> angledLine({ /// |> angledLine({
/// angle = 240, /// angle = 240,
/// length = 10, /// length = 10,
/// }, %, $referenceEdge) /// }, %, $referenceEdge)
/// |> close(%) /// |> close()
/// ///
/// example = extrude(5, exampleSketch) /// example = extrude(exampleSketch, length = 5)
/// |> fillet({ /// |> fillet({
/// radius = 3, /// radius = 3,
/// tags = [getNextAdjacentEdge(referenceEdge)], /// tags = [getNextAdjacentEdge(referenceEdge)],
@ -356,7 +356,7 @@ pub async fn get_previous_adjacent_edge(exec_state: &mut ExecState, args: Args)
/// ```no_run /// ```no_run
/// exampleSketch = startSketchOn('XZ') /// exampleSketch = startSketchOn('XZ')
/// |> startProfileAt([0, 0], %) /// |> startProfileAt([0, 0], %)
/// |> line([10, 0], %) /// |> line(end = [10, 0])
/// |> angledLine({ /// |> angledLine({
/// angle = 60, /// angle = 60,
/// length = 10, /// length = 10,
@ -365,14 +365,14 @@ pub async fn get_previous_adjacent_edge(exec_state: &mut ExecState, args: Args)
/// angle = 120, /// angle = 120,
/// length = 10, /// length = 10,
/// }, %) /// }, %)
/// |> line([-10, 0], %) /// |> line(end = [-10, 0])
/// |> angledLine({ /// |> angledLine({
/// angle = 240, /// angle = 240,
/// length = 10, /// length = 10,
/// }, %, $referenceEdge) /// }, %, $referenceEdge)
/// |> close(%) /// |> close()
/// ///
/// example = extrude(5, exampleSketch) /// example = extrude(exampleSketch, length = 5)
/// |> fillet({ /// |> fillet({
/// radius = 3, /// radius = 3,
/// tags = [getPreviousAdjacentEdge(referenceEdge)], /// tags = [getPreviousAdjacentEdge(referenceEdge)],

Some files were not shown because too many files have changed in this diff Show More