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.
exampleSketch = startSketchOn("XZ")
|> startProfileAt([0, 0], %)
|> lineTo([10, 0], %)
|> lineTo([0, 10], %)
|> lineTo([-10, 0], %)
|> close(%)
|> line(endAbsolute = [10, 0])
|> line(endAbsolute = [0, 10])
|> line(endAbsolute = [-10, 0])
|> close()
example = extrude(5, exampleSketch)
example = extrude(exampleSketch, length = 5)
|> appearance({
color = '#ff0000',
metalness = 50,
@ -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(endAbsolute = [center[0] + 10, center[1] - 10])
|> line(endAbsolute = [center[0] + 10, center[1] + 10])
|> line(endAbsolute = [center[0] - 10, center[1] + 10])
|> close()
|> extrude(length = 10)
}
example0 = cube([0, 0])
@ -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(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0])
|> close()
|> extrude(length = 6)
shell({ faces = ['end'], thickness = 0.25 }, firstSketch)
|> appearance({
@ -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(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0])
|> close()
|> extrude(length = 6)
|> appearance({
color = '#ff0000',
metalness = 90,
@ -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(end = [0, 2])
|> line(end = [3, 1])
|> line(end = [0, -4])
|> close()
example = extrude(1, exampleSketch)
example = extrude(exampleSketch, length = 1)
|> appearance({
color = '#ff0000',
metalness = 90,
@ -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(end = [0, 2])
|> line(end = [3, 1])
|> line(end = [0, -4])
|> close()
example = extrude(1, exampleSketch)
example = extrude(exampleSketch, length = 1)
|> patternLinear3d({
axis = [1, 0, 1],
instances = 7,
@ -186,10 +186,10 @@ 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(end = [0, 5])
|> line(end = [-1, 0])
|> line(end = [0, -5])
|> close()
|> patternCircular2d({
center = [0, 0],
instances = 13,
@ -197,7 +197,7 @@ exampleSketch = startSketchOn('XZ')
rotateDuplicates = true
}, %)
example = extrude(1, exampleSketch)
example = extrude(exampleSketch, length = 1)
|> appearance({
color = '#ff0000',
metalness = 90,
@ -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(end = [0, 7])
|> tangentialArc({ offset = 90, radius = 5 }, %)
|> line([-3, 0], %)
|> line(end = [-3, 0])
|> tangentialArc({ offset = -90, radius = 5 }, %)
|> line([0, 7], %)
|> line(end = [0, 7])
pipeHole = startSketchOn('XY')
|> 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")
|> 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(endAbsolute = [width / 2, -length / 2], tag = $edge1)
|> line(endAbsolute = [width / 2, length / 2], tag = $edge2)
|> line(endAbsolute = [-width / 2, length / 2], tag = $edge3)
|> close(tag = $edge4)
mountingPlate = extrude(thickness, mountingPlateSketch)
mountingPlate = extrude(mountingPlateSketch, length = thickness)
|> fillet({
radius = filletRadius,
tags = [
@ -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(endAbsolute = [width / 2, -length / 2], tag = $edge1)
|> line(endAbsolute = [width / 2, length / 2], tag = $edge2)
|> line(endAbsolute = [-width / 2, length / 2], tag = $edge3)
|> close(tag = $edge4)
mountingPlate = extrude(thickness, mountingPlateSketch)
mountingPlate = extrude(mountingPlateSketch, length = thickness)
|> fillet({
radius = filletRadius,
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
exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> line([10, 0], %)
|> line(end = [10, 0])
|> angledLine({ angle = 60, length = 10 }, %)
|> angledLine({ angle = 120, length = 10 }, %)
|> line([-10, 0], %)
|> line(end = [-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)]

View File

@ -29,14 +29,14 @@ getOppositeEdge(tag: TagIdentifier) -> Uuid
```js
exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> line([10, 0], %)
|> line(end = [10, 0])
|> angledLine({ angle = 60, length = 10 }, %)
|> angledLine({ angle = 120, length = 10 }, %)
|> line([-10, 0], %)
|> line(end = [-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)]

View File

@ -29,14 +29,14 @@ getPreviousAdjacentEdge(tag: TagIdentifier) -> Uuid
```js
exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> line([10, 0], %)
|> line(end = [10, 0])
|> angledLine({ angle = 60, length = 10 }, %)
|> angledLine({ angle = 120, length = 10 }, %)
|> line([-10, 0], %)
|> line(end = [-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)]

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.
firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %)
|> close(%)
|> extrude(6, %)
|> line(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0])
|> close()
|> extrude(length = 6)
|> hollow(0.25, %)
```
@ -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(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0])
|> close()
|> extrude(length = 6)
|> hollow(0.5, %)
```
@ -60,25 +60,25 @@ firstSketch = startSketchOn('-XZ')
size = 100
case = startSketchOn('-XZ')
|> startProfileAt([-size, -size], %)
|> line([2 * size, 0], %)
|> line([0, 2 * size], %)
|> line(end = [2 * size, 0])
|> line(end = [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)
```

View File

@ -59,7 +59,6 @@ layout: manual
* [`legAngY`](kcl/legAngY)
* [`legLen`](kcl/legLen)
* [`line`](kcl/line)
* [`lineTo`](kcl/lineTo)
* [`ln`](kcl/ln)
* [`loft`](kcl/loft)
* [`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.
startSketchOn('XZ')
|> circle({ center = [0, 0], radius = 2 }, %)
|> extrude(5, %)
|> extrude(length = 5)
|> patternTransform(n, fn(id) {
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.
squareSketch = startSketchOn('XY')
|> startProfileAt([-100, 200], %)
|> line([200, 0], %)
|> line([0, -200], %)
|> line([-200, 0], %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
|> line(end = [200, 0])
|> line(end = [0, -200])
|> line(end = [-200, 0])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
triangleSketch = startSketchOn(offsetPlane('XY', 75))
|> startProfileAt([0, 125], %)
|> line([-15, -30], %)
|> line([30, 0], %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
|> line(end = [-15, -30])
|> line(end = [30, 0])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
loft([squareSketch, triangleSketch])
```
@ -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(end = [200, 0])
|> line(end = [0, -200])
|> line(end = [-200, 0])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
circleSketch0 = startSketchOn(offsetPlane('XY', 75))
|> circle({ center = [0, 100], radius = 50 }, %)
@ -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(end = [200, 0])
|> line(end = [0, -200])
|> line(end = [-200, 0])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
circleSketch0 = startSketchOn(offsetPlane('XY', 75))
|> 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')
|> circle({ center = [0, 0], radius = 1 }, %)
example = extrude(-5, exampleSketch)
example = extrude(exampleSketch, length = -5)
|> patternCircular3d({
axis = [1, -1, 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
exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> line([0, 2], %)
|> line([3, 1], %)
|> line([0, -4], %)
|> close(%)
|> line(end = [0, 2])
|> line(end = [3, 1])
|> line(end = [0, -4])
|> close()
example = extrude(1, exampleSketch)
example = extrude(exampleSketch, length = 1)
|> patternLinear3d({
axis = [1, 0, 1],
instances = 7,

View File

@ -63,7 +63,7 @@ fn transform(id) {
// Sketch 4 cylinders.
sketch001 = startSketchOn('XZ')
|> circle({ center = [0, 0], radius = 2 }, %)
|> extrude(5, %)
|> extrude(length = 5)
|> patternTransform(4, transform, %)
```
@ -79,7 +79,7 @@ fn transform(id) {
sketch001 = startSketchOn('XZ')
|> circle({ center = [0, 0], radius = 2 }, %)
|> extrude(5, %)
|> extrude(length = 5)
|> patternTransform(4, transform, %)
```
@ -97,12 +97,12 @@ fn cube(length, center) {
return startSketchOn('XY')
|> startProfileAt(p0, %)
|> lineTo(p1, %)
|> lineTo(p2, %)
|> lineTo(p3, %)
|> lineTo(p0, %)
|> close(%)
|> extrude(length, %)
|> line(endAbsolute = p1)
|> line(endAbsolute = p2)
|> line(endAbsolute = p3)
|> line(endAbsolute = p0)
|> close()
|> extrude(length = length)
}
width = 20
@ -135,12 +135,12 @@ fn cube(length, center) {
return startSketchOn('XY')
|> startProfileAt(p0, %)
|> lineTo(p1, %)
|> lineTo(p2, %)
|> lineTo(p3, %)
|> lineTo(p0, %)
|> close(%)
|> extrude(length, %)
|> line(endAbsolute = p1)
|> line(endAbsolute = p2)
|> line(endAbsolute = p3)
|> line(endAbsolute = p0)
|> close()
|> extrude(length = length)
}
width = 20
@ -179,7 +179,7 @@ fn layer() {
return startSketchOn("XY")
// or some other plane idk
|> circle({ center = [0, 0], radius = 1 }, %, $tag1)
|> extrude(h, %)
|> extrude(length = h)
}
// The vase is 100 layers tall.
// The 100 layers are replica of each other, with a slight transformation applied to each.
@ -205,7 +205,7 @@ startSketchOn('XY')
center = [0, 0],
inscribed = false
}, %)
|> extrude(4, %)
|> extrude(length = 4)
|> 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
cube = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([w, 0], %, $line1)
|> line([0, w], %, $line2)
|> line([-w, 0], %, $line3)
|> line([0, -w], %, $line4)
|> close(%)
|> extrude(5, %)
|> line(end = [w, 0], tag = $line1)
|> line(end = [0, w], tag = $line2)
|> line(end = [-w, 0], tag = $line3)
|> line(end = [0, -w], tag = $line4)
|> close()
|> extrude(length = 5)
fn cylinder(radius, tag) {
return startSketchOn('XY')
@ -44,7 +44,7 @@ fn cylinder(radius, tag) {
radius = radius,
center = segEnd(tag)
}, %)
|> extrude(radius, %)
|> extrude(length = radius)
}
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
cube = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([w, 0], %, $line1)
|> line([0, w], %, $line2)
|> line([-w, 0], %, $line3)
|> line([0, -w], %, $line4)
|> close(%)
|> extrude(5, %)
|> line(end = [w, 0], tag = $line1)
|> line(end = [0, w], tag = $line2)
|> line(end = [-w, 0], tag = $line3)
|> line(end = [0, -w], tag = $line4)
|> close()
|> extrude(length = 5)
fn cylinder(radius, tag) {
return startSketchOn('XY')
@ -44,7 +44,7 @@ fn cylinder(radius, tag) {
radius = radius,
center = segStart(tag)
}, %)
|> extrude(radius, %)
|> extrude(length = radius)
}
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.
firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %)
|> close(%)
|> extrude(6, %)
|> line(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0])
|> close()
|> extrude(length = 6)
// Remove the end face for the extrusion.
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.
firstSketch = startSketchOn('-XZ')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %)
|> close(%)
|> extrude(6, %)
|> line(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0])
|> close()
|> extrude(length = 6)
// Remove the start face for the extrusion.
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.
firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %, $myTag)
|> close(%)
|> extrude(6, %)
|> line(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0], tag = $myTag)
|> close()
|> extrude(length = 6)
// Remove a tagged face for the extrusion.
shell({ faces = [myTag], thickness = 0.25 }, firstSketch)
@ -79,11 +79,11 @@ shell({ faces = [myTag], thickness = 0.25 }, firstSketch)
// Remove multiple faces at once.
firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %, $myTag)
|> close(%)
|> extrude(6, %)
|> line(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0], tag = $myTag)
|> close()
|> extrude(length = 6)
// Remove a tagged face and the end face for the extrusion.
shell({
@ -99,25 +99,25 @@ shell({
size = 100
case = startSketchOn('-XZ')
|> startProfileAt([-size, -size], %)
|> line([2 * size, 0], %)
|> line([0, 2 * size], %)
|> line(end = [2 * size, 0])
|> line(end = [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)
// We put "case" in the shell function to shell the entire object.
shell({ faces = ['start'], thickness = 5 }, case)
@ -130,25 +130,25 @@ shell({ faces = ['start'], thickness = 5 }, case)
size = 100
case = startSketchOn('XY')
|> startProfileAt([-size, -size], %)
|> line([2 * size, 0], %)
|> line([0, 2 * size], %)
|> line(end = [2 * size, 0])
|> line(end = [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)
// We put "thing1" in the shell function to shell the end face of the object.
shell({ faces = ['end'], thickness = 5 }, thing1)
@ -164,25 +164,25 @@ shell({ faces = ['end'], thickness = 5 }, thing1)
size = 100
case = startSketchOn('XY')
|> startProfileAt([-size, -size], %)
|> line([2 * size, 0], %)
|> line([0, 2 * size], %)
|> line(end = [2 * size, 0])
|> line(end = [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)
// We put "thing1" and "thing2" in the shell function to shell the end face of the object.
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.
sweepPath = startSketchOn('XZ')
|> startProfileAt([0.05, 0.05], %)
|> line([0, 7], %)
|> line(end = [0, 7])
|> tangentialArc({ offset = 90, radius = 5 }, %)
|> line([-3, 0], %)
|> line(end = [-3, 0])
|> tangentialArc({ offset = -90, radius = 5 }, %)
|> line([0, 7], %)
|> line(end = [0, 7])
// Create a hole for the pipe.
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()
return startSketchOn(plane)
|> startProfileAt(offset, %)
|> line([w, 0], %)
|> line([0, h], %)
|> line([-w, 0], %)
|> close(%)
|> line(end = [w, 0])
|> line(end = [0, h])
|> line(end = [-w, 0])
|> close()
}

View File

@ -2957,20 +2957,20 @@ fn hmm = (x) => {
return x
}
const yo = 5 + 6
yo = 5 + 6
const abc = 3
const identifierGuy = 5
const part001 = startSketchOn('XY')
abc = 3
identifierGuy = 5
part001 = startSketchOn('XY')
|> startProfileAt([-1.2, 4.83], %)
|> line([2.8, 0], %)
|> line(end = [2.8, 0])
|> angledLine([100 + 100, 3.01], %)
|> angledLine([abc, 3.02], %)
|> angledLine([def(yo), 3.03], %)
|> angledLine([ghi(2), 3.04], %)
|> angledLine([jkl(yo) + 2, 3.05], %)
|> close(%)
const yo2 = hmm([identifierGuy + 5])"#;
|> close()
yo2 = hmm([identifierGuy + 5])"#;
parse_execute(ast).await.unwrap();
}
@ -2980,11 +2980,11 @@ const yo2 = hmm([identifierGuy + 5])"#;
let ast = r#"const myVar = 3
const part001 = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([3, 4], %, $seg01)
|> line([
|> line(end = [3, 4], tag = $seg01)
|> line(end = [
min(segLen(seg01), myVar),
-legLen(segLen(seg01), myVar)
], %)
])
"#;
parse_execute(ast).await.unwrap();
@ -2995,11 +2995,11 @@ const part001 = startSketchOn('XY')
let ast = r#"const myVar = 3
const part001 = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([3, 4], %, $seg01)
|> line([
|> line(end = [3, 4], tag = $seg01)
|> line(end = [
min(segLen(seg01), myVar),
legLen(segLen(seg01), myVar)
], %)
])
"#;
parse_execute(ast).await.unwrap();
@ -3039,11 +3039,11 @@ fn thing = () => {
const firstExtrude = startSketchOn('XY')
|> startProfileAt([0,0], %)
|> line([0, l], %)
|> line([w, 0], %)
|> line([0, thing()], %)
|> close(%)
|> extrude(h, %)"#;
|> line(end = [0, l])
|> line(end = [w, 0])
|> line(end = [0, thing()])
|> close()
|> extrude(length = h)"#;
parse_execute(ast).await.unwrap();
}
@ -3060,11 +3060,11 @@ fn thing = (x) => {
const firstExtrude = startSketchOn('XY')
|> startProfileAt([0,0], %)
|> line([0, l], %)
|> line([w, 0], %)
|> line([0, thing(8)], %)
|> close(%)
|> extrude(h, %)"#;
|> line(end = [0, l])
|> line(end = [w, 0])
|> line(end = [0, thing(8)])
|> close()
|> extrude(length = h)"#;
parse_execute(ast).await.unwrap();
}
@ -3081,11 +3081,11 @@ fn thing = (x) => {
const firstExtrude = startSketchOn('XY')
|> startProfileAt([0,0], %)
|> line([0, l], %)
|> line([w, 0], %)
|> line(thing(8), %)
|> close(%)
|> extrude(h, %)"#;
|> line(end = [0, l])
|> line(end = [w, 0])
|> line(end = thing(8))
|> close()
|> extrude(length = h)"#;
parse_execute(ast).await.unwrap();
}
@ -3106,11 +3106,11 @@ fn thing = (x) => {
const firstExtrude = startSketchOn('XY')
|> startProfileAt([0,0], %)
|> line([0, l], %)
|> line([w, 0], %)
|> line([0, thing(8)], %)
|> close(%)
|> extrude(h, %)"#;
|> line(end = [0, l])
|> line(end = [w, 0])
|> line(end = [0, thing(8)])
|> close()
|> extrude(length = h)"#;
parse_execute(ast).await.unwrap();
}
@ -3120,11 +3120,11 @@ const firstExtrude = startSketchOn('XY')
let ast = r#"fn box = (h, l, w) => {
const myBox = startSketchOn('XY')
|> startProfileAt([0,0], %)
|> line([0, l], %)
|> line([w, 0], %)
|> line([0, -l], %)
|> close(%)
|> extrude(h, %)
|> line(end = [0, l])
|> line(end = [w, 0])
|> line(end = [0, -l])
|> close()
|> extrude(length = h)
return myBox
}
@ -3139,11 +3139,11 @@ const fnBox = box(3, 6, 10)"#;
let ast = r#"fn box = (obj) => {
let myBox = startSketchOn('XY')
|> startProfileAt(obj.start, %)
|> line([0, obj.l], %)
|> line([obj.w, 0], %)
|> line([0, -obj.l], %)
|> close(%)
|> extrude(obj.h, %)
|> line(end = [0, obj.l])
|> line(end = [obj.w, 0])
|> line(end = [0, -obj.l])
|> close()
|> extrude(length = obj.h)
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 myBox = startSketchOn('XY')
|> startProfileAt(obj["start"], %)
|> line([0, obj["l"]], %)
|> line([obj["w"], 0], %)
|> line([0, -obj["l"]], %)
|> close(%)
|> extrude(obj["h"], %)
|> line(end = [0, obj["l"]])
|> line(end = [obj["w"], 0])
|> line(end = [0, -obj["l"]])
|> close()
|> extrude(length = obj["h"])
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 myBox = startSketchOn('XY')
|> startProfileAt(obj["start"], %)
|> line([0, obj["l"]], %)
|> line([obj["w"], 0], %)
|> line([10 - obj["w"], -obj.l], %)
|> close(%)
|> extrude(obj["h"], %)
|> line(end = [0, obj["l"]])
|> line(end = [obj["w"], 0])
|> line(end = [10 - obj["w"], -obj.l])
|> close()
|> extrude(length = obj["h"])
return myBox
}
@ -3199,17 +3199,17 @@ fn test2 = () => {
return {
thing: startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([0, 1], %)
|> line([1, 0], %)
|> line([0, -1], %)
|> close(%)
|> line(end = [0, 1])
|> line(end = [1, 0])
|> line(end = [0, -1])
|> close()
}
}
const x2 = test2()
x2.thing
|> extrude(10, %)
|> extrude(length = 10)
"#;
parse_execute(ast).await.unwrap();
}
@ -3220,11 +3220,11 @@ x2.thing
let ast = r#"fn box = (obj) => {
let myBox = startSketchOn('XY')
|> startProfileAt(obj.start, %)
|> line([0, obj.l], %)
|> line([obj.w, 0], %)
|> line([0, -obj.l], %)
|> close(%)
|> extrude(obj.h, %)
|> line(end = [0, obj.l])
|> line(end = [obj.w, 0])
|> line(end = [0, -obj.l])
|> close()
|> extrude(length = obj.h)
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) => {
const myBox = startSketchOn('XY')
|> startProfileAt([0,0], %)
|> line([0, l], %)
|> line([w, 0], %)
|> line([0, -l], %)
|> close(%)
|> extrude(h, %)
|> line(end = [0, l])
|> line(end = [w, 0])
|> line(end = [0, -l])
|> close()
|> extrude(length = h)
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 myBox =startSketchOn('XY')
|> startProfileAt(arr[0], %)
|> line([0, arr[1]], %)
|> line([arr[2], 0], %)
|> line([0, -arr[1]], %)
|> close(%)
|> extrude(arr[3], %)
|> line(end = [0, arr[1]])
|> line(end = [arr[2], 0])
|> line(end = [0, -arr[1]])
|> close()
|> extrude(length = arr[3])
return myBox
}
@ -3342,7 +3342,7 @@ fn transform = (replicaId) => {
fn layer = () => {
return startSketchOn("XY")
|> circle({ center: [0, 0], radius: 1 }, %, $tag1)
|> extrude(10, %)
|> extrude(length = 10)
}
const x = 5
@ -3430,10 +3430,10 @@ fn thickness = () => { return 0.56 }
const bracket = startSketchOn('XY')
|> startProfileAt([0,0], %)
|> line([0, leg1], %)
|> line([leg2, 0], %)
|> line([0, -thickness()], %)
|> line([-leg2 + thickness(), 0], %)
|> line(end = [0, leg1])
|> line(end = [leg2, 0])
|> line(end = [0, -thickness()])
|> line(end = [-leg2 + thickness(), 0])
"#;
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')
|> startProfileAt([0,0], %)
|> line([0, leg1], %)
|> line([leg2, 0], %)
|> line([0, -thickness], %)
|> line([-leg2 + thickness, 0], %)
|> line(end = [0, leg1])
|> line(end = [leg2, 0])
|> line(end = [0, -thickness])
|> line(end = [-leg2 + thickness, 0])
"#;
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 bracket = startSketchOn('XY')
|> startProfileAt([0,0], %)
|> line([0, leg1], %)
|> line([leg2, 0], %)
|> line([0, -thickness], %)
|> line([-1 * leg2 + thickness, 0], %)
|> line([0, -1 * leg1 + thickness], %)
|> close(%)
|> extrude(width, %)
|> line(end = [0, leg1])
|> line(end = [leg2, 0])
|> line(end = [0, -thickness])
|> line(end = [-1 * leg2 + thickness, 0])
|> line(end = [0, -1 * leg1 + thickness])
|> close()
|> extrude(length = width)
"#;
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 bracket = startSketchOn('XY')
|> startProfileAt([0,0], %)
|> line([0, leg1], %)
|> line([leg2, 0], %)
|> line([0, -thickness], %)
|> line([-1 * leg2 + thickness, 0], %)
|> line([0, -1 * leg1 + thickness], %)
|> close(%)
|> extrude(width, %)
|> line(end = [0, leg1])
|> line(end = [leg2, 0])
|> line(end = [0, -thickness])
|> line(end = [-1 * leg2 + thickness, 0])
|> line(end = [0, -1 * leg1 + thickness])
|> close()
|> extrude(length = width)
"#;
parse_execute(ast).await.unwrap();
}
@ -3849,11 +3849,11 @@ let w = f() + f()
let new = r#"// Remove the end face for the extrusion.
firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %)
|> close(%)
|> extrude(6, %)
|> line(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0])
|> close()
|> extrude(length = 6)
// Remove the end face for the extrusion.
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.
firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %)
|> close(%)
|> extrude(6, %)
|> line(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0])
|> close()
|> extrude(length = 6)
// Remove the end face for the extrusion.
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.
firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %)
|> close(%)
|> extrude(6, %)
|> line(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0])
|> close()
|> extrude(length = 6)
// Remove the end face for the extrusion.
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.
firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %)
|> close(%)
|> extrude(6, %)
|> line(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0])
|> close()
|> extrude(length = 6)
// Remove the end face for the extrusion.
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.
firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %)
|> close(%)
|> extrude(6, %)
|> line(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0])
|> close()
|> extrude(length = 6)
// Remove the end face for the extrusion.
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.
firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %)
|> close(%)
|> extrude(6, %)
|> line(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0])
|> close()
|> extrude(length = 6)
// Remove the end face for the extrusion.
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.
firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %) // my thing
|> close(%)
|> extrude(6, %)
|> line(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0]) // my thing
|> close()
|> extrude(length = 6)
// Remove the end face for the extrusion.
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.
firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %)
|> close(%)
|> extrude(6, %)
|> line(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0])
|> close()
|> extrude(length = 6)
// Remove the end face for the extrusion.
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.
firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %)
|> close(%)
|> extrude(6, %)
|> line(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0])
|> close()
|> extrude(length = 6)
// Remove the end face for the extrusion.
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.
firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %)
|> close(%)
|> extrude(6, %)
|> line(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0])
|> close()
|> extrude(length = 6)
// Remove the end face for the extrusion.
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.
firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %)
|> line([24, 0], %)
|> line([0, -24], %)
|> line([-24, 0], %)
|> close(%)
|> extrude(6, %)
|> line(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0])
|> close()
|> extrude(length = 6)
// Remove the end face for the extrusion.
shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
@ -4150,9 +4150,9 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
|> xLine(305.11, %, $seg01)
|> yLine(-291.85, %)
|> xLine(-segLen(seg01), %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
|> extrude(40.14, %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
|> extrude(length = 40.14)
|> shell({
faces: [seg01],
thickness: 3.14,
@ -4179,9 +4179,9 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
|> xLine(305.11, %, $seg01)
|> yLine(-291.85, %)
|> xLine(-segLen(seg01), %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
|> extrude(40.14, %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
|> extrude(length = 40.14)
|> shell({
faces: [seg01],
thickness: 3.14,

View File

@ -18,7 +18,7 @@ use crate::{
Program,
};
use super::types::LiteralValue;
use super::types::{CallExpressionKw, Identifier, LabeledArg, LiteralValue};
type Point3d = kcmc::shared::Point3d<f64>;
@ -219,16 +219,21 @@ fn create_start_sketch_on(
current_position.x += end[0];
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",
vec![
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(),
PipeSubstitution::new().into(),
],
None,
vec![LabeledArg {
label: super::types::Identifier {
name: "end".to_owned(),
digest: None,
},
arg: expr,
}],
)?;
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.
if diff_x <= EPSILON && diff_y <= EPSILON {
// 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());
break;
}
}
// 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",
vec![
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(),
PipeSubstitution::new().into(),
],
None,
vec![LabeledArg {
arg: expr,
label: Identifier {
name: "end".to_owned(),
digest: None,
},
}],
)?;
pipe_body.push(line.into());
}

View File

@ -4485,6 +4485,7 @@ mod snapshot_tests {
#[test]
fn $func_name() {
let module_id = crate::ModuleId::default();
println!("{}", $test_kcl_program);
let tokens = crate::parsing::token::lex($test_kcl_program, module_id).unwrap();
print_tokens(tokens.as_slice());
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.
/// exampleSketch = startSketchOn("XZ")
/// |> startProfileAt([0, 0], %)
/// |> lineTo([10, 0], %)
/// |> lineTo([0, 10], %)
/// |> lineTo([-10, 0], %)
/// |> close(%)
/// |> line(endAbsolute = [10, 0])
/// |> line(endAbsolute = [0, 10])
/// |> line(endAbsolute = [-10, 0])
/// |> close()
///
/// example = extrude(5, exampleSketch)
/// example = extrude(exampleSketch, length = 5)
/// |> 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) {
/// 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(endAbsolute = [center[0] + 10, center[1] - 10])
/// |> line(endAbsolute = [center[0] + 10, center[1] + 10])
/// |> line(endAbsolute = [center[0] - 10, center[1] + 10])
/// |> close()
/// |> extrude(length = 10)
/// }
///
/// 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.
/// firstSketch = startSketchOn('XY')
/// |> startProfileAt([-12, 12], %)
/// |> line([24, 0], %)
/// |> line([0, -24], %)
/// |> line([-24, 0], %)
/// |> close(%)
/// |> extrude(6, %)
/// |> line(end = [24, 0])
/// |> line(end = [0, -24])
/// |> line(end = [-24, 0])
/// |> close()
/// |> extrude(length = 6)
///
/// shell({
/// 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.
/// firstSketch = startSketchOn('XY')
/// |> startProfileAt([-12, 12], %)
/// |> line([24, 0], %)
/// |> line([0, -24], %)
/// |> line([-24, 0], %)
/// |> close(%)
/// |> extrude(6, %)
/// |> line(end = [24, 0])
/// |> line(end = [0, -24])
/// |> line(end = [-24, 0])
/// |> close()
/// |> extrude(length = 6)
/// |> appearance({
/// color = '#ff0000',
/// metalness = 90,
@ -158,12 +158,12 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result<KclVa
/// // This example shows _before_ the pattern.
/// exampleSketch = startSketchOn('XZ')
/// |> startProfileAt([0, 0], %)
/// |> line([0, 2], %)
/// |> line([3, 1], %)
/// |> line([0, -4], %)
/// |> close(%)
/// |> line(end = [0, 2])
/// |> line(end = [3, 1])
/// |> line(end = [0, -4])
/// |> close()
///
/// example = extrude(1, exampleSketch)
/// example = extrude(exampleSketch, length = 1)
/// |> appearance({
/// color = '#ff0000',
/// metalness = 90,
@ -181,12 +181,12 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result<KclVa
/// // This example shows _after_ the pattern.
/// exampleSketch = startSketchOn('XZ')
/// |> startProfileAt([0, 0], %)
/// |> line([0, 2], %)
/// |> line([3, 1], %)
/// |> line([0, -4], %)
/// |> close(%)
/// |> line(end = [0, 2])
/// |> line(end = [3, 1])
/// |> line(end = [0, -4])
/// |> close()
///
/// example = extrude(1, exampleSketch)
/// example = extrude(exampleSketch, length = 1)
/// |> patternLinear3d({
/// axis = [1, 0, 1],
/// 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.
/// exampleSketch = startSketchOn('XZ')
/// |> startProfileAt([.5, 25], %)
/// |> line([0, 5], %)
/// |> line([-1, 0], %)
/// |> line([0, -5], %)
/// |> close(%)
/// |> line(end = [0, 5])
/// |> line(end = [-1, 0])
/// |> line(end = [0, -5])
/// |> close()
/// |> patternCircular2d({
/// center = [0, 0],
/// instances = 13,
@ -214,7 +214,7 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result<KclVa
/// rotateDuplicates = true
/// }, %)
///
/// example = extrude(1, exampleSketch)
/// example = extrude(exampleSketch, length = 1)
/// |> appearance({
/// color = '#ff0000',
/// metalness = 90,
@ -228,17 +228,17 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result<KclVa
/// // Create a path for the sweep.
/// sweepPath = startSketchOn('XZ')
/// |> startProfileAt([0.05, 0.05], %)
/// |> line([0, 7], %)
/// |> line(end = [0, 7])
/// |> tangentialArc({
/// offset: 90,
/// radius: 5
/// }, %)
/// |> line([-3, 0], %)
/// |> line(end = [-3, 0])
/// |> tangentialArc({
/// offset: -90,
/// radius: 5
/// }, %)
/// |> line([0, 7], %)
/// |> line(end = [0, 7])
///
/// pipeHole = startSketchOn('XY')
/// |> circle({

View File

@ -395,10 +395,6 @@ impl Args {
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>
where
T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
@ -466,10 +462,6 @@ impl Args {
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(
&self,
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.
/// x = cos(stepAngle * i) * radius
/// y = sin(stepAngle * i) * radius
/// return lineTo([x, y], partialDecagon)
/// return line(partialDecagon, end = [x, y])
/// })
///
/// return fullDecagon
@ -173,13 +173,13 @@ pub async fn reduce(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// for i in [1..10]:
/// x = cos(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
/// return fullDecagon
/// */
///
/// // Use the `decagon` function declared above, to sketch a decagon with radius 5.
/// decagon(5.0) |> close(%)
/// decagon(5.0) |> close()
/// ```
#[stdlib {
name = "reduce",

View File

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

View File

@ -26,7 +26,7 @@ pub async fn int(_exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kc
/// // 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] }
/// }, %)

View File

@ -21,9 +21,10 @@ use crate::{
/// Extrudes by a given amount.
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())
}
@ -35,22 +36,22 @@ pub async fn extrude(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// ```no_run
/// example = startSketchOn('XZ')
/// |> startProfileAt([0, 0], %)
/// |> line([10, 0], %)
/// |> line(end = [10, 0])
/// |> arc({
/// angleStart = 120,
/// angleEnd = 0,
/// radius = 5,
/// }, %)
/// |> line([5, 0], %)
/// |> line([0, 10], %)
/// |> line(end = [5, 0])
/// |> line(end = [0, 10])
/// |> bezierCurve({
/// control1 = [-10, 0],
/// control2 = [2, 10],
/// to = [-5, 10],
/// }, %)
/// |> line([-5, -2], %)
/// |> close(%)
/// |> extrude(10, %)
/// |> line(end = [-5, -2])
/// |> close()
/// |> extrude(length = 10)
/// ```
///
/// ```no_run
@ -61,26 +62,32 @@ pub async fn extrude(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// angleEnd = -60,
/// radius = 5,
/// }, %)
/// |> line([10, 0], %)
/// |> line([5, 0], %)
/// |> line(end = [10, 0])
/// |> line(end = [5, 0])
/// |> bezierCurve({
/// control1 = [-3, 0],
/// control2 = [2, 10],
/// to = [-5, 10],
/// }, %)
/// |> line([-4, 10], %)
/// |> line([-5, -2], %)
/// |> close(%)
/// |> line(end = [-4, 10])
/// |> line(end = [-5, -2])
/// |> close()
///
/// example = extrude(10, exampleSketch)
/// example = extrude(exampleSketch, length = 10)
/// ```
#[stdlib {
name = "extrude",
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(
length: f64,
sketch_set: SketchSet,
length: f64,
exec_state: &mut ExecState,
args: Args,
) -> Result<SolidSet, KclError> {

View File

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

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