Remove backwards compatibility tags (#3139)
* start removing backwards compat Signed-off-by: Jess Frazelle <github@jessfraz.com> * more Signed-off-by: Jess Frazelle <github@jessfraz.com> * add more Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixups Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * std Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix one Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup other backwards compatible shit Signed-off-by: Jess Frazelle <github@jessfraz.com> * cargo.lock Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * update js tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix playwright Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
@ -22,7 +22,7 @@ const exampleSketch = startSketchOn('XZ')
|
|||||||
|> lineTo([0, 20], %)
|
|> lineTo([0, 20], %)
|
||||||
|> angledLineThatIntersects({
|
|> angledLineThatIntersects({
|
||||||
angle: 80,
|
angle: 80,
|
||||||
intersectTag: 'lineToIntersect',
|
intersectTag: lineToIntersect,
|
||||||
offset: 10
|
offset: 10
|
||||||
}, %)
|
}, %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|
@ -23,7 +23,7 @@ const box = startSketchOn('XZ')
|
|||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(10, %)
|
|> extrude(10, %)
|
||||||
|
|
||||||
const revolution = startSketchOn(box, "revolveAxis")
|
const revolution = startSketchOn(box, revolveAxis)
|
||||||
|> startProfileAt([5, 10], %)
|
|> startProfileAt([5, 10], %)
|
||||||
|> line([0, 10], %)
|
|> line([0, 10], %)
|
||||||
|> line([2, 0], %)
|
|> line([2, 0], %)
|
||||||
|
@ -55,7 +55,7 @@ const exampleSketch = startSketchOn("XY")
|
|||||||
|
|
||||||
const example = extrude(10, exampleSketch)
|
const example = extrude(10, exampleSketch)
|
||||||
|
|
||||||
const exampleSketch002 = startSketchOn(example, 'sketchingFace')
|
const exampleSketch002 = startSketchOn(example, sketchingFace)
|
||||||
|> startProfileAt([1, 1], %)
|
|> startProfileAt([1, 1], %)
|
||||||
|> line([8, 0], %)
|
|> line([8, 0], %)
|
||||||
|> line([0, 8], %)
|
|> line([0, 8], %)
|
||||||
@ -64,7 +64,7 @@ const exampleSketch002 = startSketchOn(example, 'sketchingFace')
|
|||||||
|
|
||||||
const example002 = extrude(10, exampleSketch002)
|
const example002 = extrude(10, exampleSketch002)
|
||||||
|
|
||||||
const exampleSketch003 = startSketchOn(example002, 'sketchingFace002')
|
const exampleSketch003 = startSketchOn(example002, sketchingFace002)
|
||||||
|> startProfileAt([-8, 12], %)
|
|> startProfileAt([-8, 12], %)
|
||||||
|> line([0, 6], %)
|
|> line([0, 6], %)
|
||||||
|> line([6, 0], %)
|
|> line([6, 0], %)
|
||||||
|
@ -23188,7 +23188,7 @@
|
|||||||
"unpublished": false,
|
"unpublished": false,
|
||||||
"deprecated": false,
|
"deprecated": false,
|
||||||
"examples": [
|
"examples": [
|
||||||
"const exampleSketch = startSketchOn('XZ')\n |> startProfileAt([0, 0], %)\n |> lineTo([5, 10], %)\n |> lineTo([-10, 10], %, $lineToIntersect)\n |> lineTo([0, 20], %)\n |> angledLineThatIntersects({\n angle: 80,\n intersectTag: 'lineToIntersect',\n offset: 10\n }, %)\n |> close(%)\n\nconst example = extrude(10, exampleSketch)"
|
"const exampleSketch = startSketchOn('XZ')\n |> startProfileAt([0, 0], %)\n |> lineTo([5, 10], %)\n |> lineTo([-10, 10], %, $lineToIntersect)\n |> lineTo([0, 20], %)\n |> angledLineThatIntersects({\n angle: 80,\n intersectTag: lineToIntersect,\n offset: 10\n }, %)\n |> close(%)\n\nconst example = extrude(10, exampleSketch)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -67935,7 +67935,7 @@
|
|||||||
"unpublished": false,
|
"unpublished": false,
|
||||||
"deprecated": false,
|
"deprecated": false,
|
||||||
"examples": [
|
"examples": [
|
||||||
"const box = startSketchOn('XZ')\n |> startProfileAt([0, 0], %)\n |> line([0, 10], %, $revolveAxis)\n |> line([10, 0], %)\n |> line([0, -10], %)\n |> close(%)\n |> extrude(10, %)\n\nconst revolution = startSketchOn(box, \"revolveAxis\")\n |> startProfileAt([5, 10], %)\n |> line([0, 10], %)\n |> line([2, 0], %)\n |> line([0, -10], %)\n |> close(%)\n |> revolve({\n axis: getEdge(revolveAxis, box),\n angle: 90\n }, %)"
|
"const box = startSketchOn('XZ')\n |> startProfileAt([0, 0], %)\n |> line([0, 10], %, $revolveAxis)\n |> line([10, 0], %)\n |> line([0, -10], %)\n |> close(%)\n |> extrude(10, %)\n\nconst revolution = startSketchOn(box, revolveAxis)\n |> startProfileAt([5, 10], %)\n |> line([0, 10], %)\n |> line([2, 0], %)\n |> line([0, -10], %)\n |> close(%)\n |> revolve({\n axis: getEdge(revolveAxis, box),\n angle: 90\n }, %)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -158522,7 +158522,7 @@
|
|||||||
"deprecated": false,
|
"deprecated": false,
|
||||||
"examples": [
|
"examples": [
|
||||||
"const exampleSketch = startSketchOn(\"XY\")\n |> startProfileAt([0, 0], %)\n |> line([10, 0], %)\n |> line([0, 10], %)\n |> line([-10, 0], %)\n |> close(%)\n\nconst example = extrude(5, exampleSketch)\n\nconst exampleSketch002 = startSketchOn(example, 'end')\n |> startProfileAt([1, 1], %)\n |> line([8, 0], %)\n |> line([0, 8], %)\n |> line([-8, 0], %)\n |> close(%)\n\nconst example002 = extrude(5, exampleSketch002)\n\nconst exampleSketch003 = startSketchOn(example002, 'end')\n |> startProfileAt([2, 2], %)\n |> line([6, 0], %)\n |> line([0, 6], %)\n |> line([-6, 0], %)\n |> close(%)\n\nconst example003 = extrude(5, exampleSketch003)",
|
"const exampleSketch = startSketchOn(\"XY\")\n |> startProfileAt([0, 0], %)\n |> line([10, 0], %)\n |> line([0, 10], %)\n |> line([-10, 0], %)\n |> close(%)\n\nconst example = extrude(5, exampleSketch)\n\nconst exampleSketch002 = startSketchOn(example, 'end')\n |> startProfileAt([1, 1], %)\n |> line([8, 0], %)\n |> line([0, 8], %)\n |> line([-8, 0], %)\n |> close(%)\n\nconst example002 = extrude(5, exampleSketch002)\n\nconst exampleSketch003 = startSketchOn(example002, 'end')\n |> startProfileAt([2, 2], %)\n |> line([6, 0], %)\n |> line([0, 6], %)\n |> line([-6, 0], %)\n |> close(%)\n\nconst example003 = extrude(5, exampleSketch003)",
|
||||||
"const exampleSketch = startSketchOn(\"XY\")\n |> startProfileAt([0, 0], %)\n |> line([10, 0], %)\n |> line([0, 10], %, $sketchingFace)\n |> line([-10, 0], %)\n |> close(%)\n\nconst example = extrude(10, exampleSketch)\n\nconst exampleSketch002 = startSketchOn(example, 'sketchingFace')\n |> startProfileAt([1, 1], %)\n |> line([8, 0], %)\n |> line([0, 8], %)\n |> line([-8, 0], %)\n |> close(%, $sketchingFace002)\n\nconst example002 = extrude(10, exampleSketch002)\n\nconst exampleSketch003 = startSketchOn(example002, 'sketchingFace002')\n |> startProfileAt([-8, 12], %)\n |> line([0, 6], %)\n |> line([6, 0], %)\n |> line([0, -6], %)\n |> close(%)\n\nconst example003 = extrude(5, exampleSketch003)",
|
"const exampleSketch = startSketchOn(\"XY\")\n |> startProfileAt([0, 0], %)\n |> line([10, 0], %)\n |> line([0, 10], %, $sketchingFace)\n |> line([-10, 0], %)\n |> close(%)\n\nconst example = extrude(10, exampleSketch)\n\nconst exampleSketch002 = startSketchOn(example, sketchingFace)\n |> startProfileAt([1, 1], %)\n |> line([8, 0], %)\n |> line([0, 8], %)\n |> line([-8, 0], %)\n |> close(%, $sketchingFace002)\n\nconst example002 = extrude(10, exampleSketch002)\n\nconst exampleSketch003 = startSketchOn(example002, sketchingFace002)\n |> startProfileAt([-8, 12], %)\n |> line([0, 6], %)\n |> line([6, 0], %)\n |> line([0, -6], %)\n |> close(%)\n\nconst example003 = extrude(5, exampleSketch003)",
|
||||||
"const exampleSketch = startSketchOn('XY')\n |> startProfileAt([4, 12], %)\n |> line([2, 0], %)\n |> line([0, -6], %)\n |> line([4, -6], %)\n |> line([0, -6], %)\n |> line([-3.75, -4.5], %)\n |> line([0, -5.5], %)\n |> line([-2, 0], %)\n |> close(%)\n\nconst example = revolve({ axis: 'y', angle: 180 }, exampleSketch)\n\nconst exampleSketch002 = startSketchOn(example, 'end')\n |> startProfileAt([4.5, -5], %)\n |> line([0, 5], %)\n |> line([5, 0], %)\n |> line([0, -5], %)\n |> close(%)\n\nconst example002 = extrude(5, exampleSketch002)",
|
"const exampleSketch = startSketchOn('XY')\n |> startProfileAt([4, 12], %)\n |> line([2, 0], %)\n |> line([0, -6], %)\n |> line([4, -6], %)\n |> line([0, -6], %)\n |> line([-3.75, -4.5], %)\n |> line([0, -5.5], %)\n |> line([-2, 0], %)\n |> close(%)\n\nconst example = revolve({ axis: 'y', angle: 180 }, exampleSketch)\n\nconst exampleSketch002 = startSketchOn(example, 'end')\n |> startProfileAt([4.5, -5], %)\n |> line([0, 5], %)\n |> line([5, 0], %)\n |> line([0, -5], %)\n |> close(%)\n\nconst example002 = extrude(5, exampleSketch002)",
|
||||||
"const a1 = startSketchOn({\n plane: {\n origin: { x: 0, y: 0, z: 0 },\n x_axis: { x: 1, y: 0, z: 0 },\n y_axis: { x: 0, y: 1, z: 0 },\n z_axis: { x: 0, y: 0, z: 1 }\n }\n })\n |> startProfileAt([0, 0], %)\n |> line([100.0, 0], %)\n |> yLine(-100.0, %)\n |> xLine(-100.0, %)\n |> yLine(100.0, %)\n |> close(%)\n |> extrude(3.14, %)"
|
"const a1 = startSketchOn({\n plane: {\n origin: { x: 0, y: 0, z: 0 },\n x_axis: { x: 1, y: 0, z: 0 },\n y_axis: { x: 0, y: 1, z: 0 },\n z_axis: { x: 0, y: 0, z: 1 }\n }\n })\n |> startProfileAt([0, 0], %)\n |> line([100.0, 0], %)\n |> yLine(-100.0, %)\n |> xLine(-100.0, %)\n |> yLine(100.0, %)\n |> close(%)\n |> extrude(3.14, %)"
|
||||||
]
|
]
|
||||||
|
@ -1016,18 +1016,18 @@ test.describe('Editor tests', () => {
|
|||||||
|> startProfileAt([0, 0], %)
|
|> startProfileAt([0, 0], %)
|
||||||
|> line([0, 10], %)
|
|> line([0, 10], %)
|
||||||
|> line([10, 0], %)
|
|> line([10, 0], %)
|
||||||
|> line([0, -10], %, 'revolveAxis')
|
|> line([0, -10], %, $revolveAxis)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(10, %)
|
|> extrude(10, %)
|
||||||
|
|
||||||
const sketch001 = startSketchOn(box, "revolveAxis")
|
const sketch001 = startSketchOn(box, revolveAxis)
|
||||||
|> startProfileAt([5, 10], %)
|
|> startProfileAt([5, 10], %)
|
||||||
|> line([0, -10], %)
|
|> line([0, -10], %)
|
||||||
|> line([2, 0], %)
|
|> line([2, 0], %)
|
||||||
|> line([0, -10], %)
|
|> line([0, -10], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> revolve({
|
|> revolve({
|
||||||
axis: getEdge('revolveAxis', box),
|
axis: getEdge(revolveAxis, box),
|
||||||
angle: 90
|
angle: 90
|
||||||
}, %)
|
}, %)
|
||||||
`
|
`
|
||||||
|
@ -71,7 +71,7 @@ export const TEST_CODE_GIZMO = `const part001 = startSketchOn('XZ')
|
|||||||
|> angledLine({ angle: 3 + 0, length: 3.14 + 0 }, %)
|
|> angledLine({ angle: 3 + 0, length: 3.14 + 0 }, %)
|
||||||
|> lineTo([20.14 + 0, -0.14 + 0], %)
|
|> lineTo([20.14 + 0, -0.14 + 0], %)
|
||||||
|> xLineTo(29 + 0, %)
|
|> xLineTo(29 + 0, %)
|
||||||
|> yLine(-3.14 + 0, %, 'a')
|
|> yLine(-3.14 + 0, %, $a)
|
||||||
|> xLine(1.63, %)
|
|> xLine(1.63, %)
|
||||||
|> angledLineOfXLength({ angle: 3 + 0, length: 3.14 }, %)
|
|> angledLineOfXLength({ angle: 3 + 0, length: 3.14 }, %)
|
||||||
|> angledLineOfYLength({ angle: 30, length: 3 + 0 }, %)
|
|> angledLineOfYLength({ angle: 30, length: 3 + 0 }, %)
|
||||||
@ -79,7 +79,7 @@ export const TEST_CODE_GIZMO = `const part001 = startSketchOn('XZ')
|
|||||||
|> angledLineToY({ angle: 30, to: 11.14 }, %)
|
|> angledLineToY({ angle: 30, to: 11.14 }, %)
|
||||||
|> angledLineThatIntersects({
|
|> angledLineThatIntersects({
|
||||||
angle: 3.14,
|
angle: 3.14,
|
||||||
intersectTag: 'a',
|
intersectTag: a,
|
||||||
offset: 0
|
offset: 0
|
||||||
}, %)
|
}, %)
|
||||||
|> tangentialArcTo([13.14 + 0, 13.14], %)
|
|> tangentialArcTo([13.14 + 0, 13.14], %)
|
||||||
|
30
src-tauri/Cargo.lock
generated
30
src-tauri/Cargo.lock
generated
@ -2571,7 +2571,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kcl-lib"
|
name = "kcl-lib"
|
||||||
version = "0.1.72"
|
version = "0.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"approx",
|
"approx",
|
||||||
@ -2930,13 +2930,14 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mio"
|
name = "mio"
|
||||||
version = "0.8.11"
|
version = "1.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c"
|
checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"hermit-abi",
|
||||||
"libc",
|
"libc",
|
||||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -3067,16 +3068,6 @@ dependencies = [
|
|||||||
"autocfg",
|
"autocfg",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num_cpus"
|
|
||||||
version = "1.16.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
|
|
||||||
dependencies = [
|
|
||||||
"hermit-abi",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num_enum"
|
name = "num_enum"
|
||||||
version = "0.5.11"
|
version = "0.5.11"
|
||||||
@ -5714,29 +5705,28 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.38.0"
|
version = "1.39.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a"
|
checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
"bytes",
|
"bytes",
|
||||||
"libc",
|
"libc",
|
||||||
"mio",
|
"mio",
|
||||||
"num_cpus",
|
|
||||||
"parking_lot 0.12.1",
|
"parking_lot 0.12.1",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"signal-hook-registry",
|
"signal-hook-registry",
|
||||||
"socket2",
|
"socket2",
|
||||||
"tokio-macros",
|
"tokio-macros",
|
||||||
"tracing",
|
"tracing",
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-macros"
|
name = "tokio-macros"
|
||||||
version = "2.3.0"
|
version = "2.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a"
|
checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -15,7 +15,7 @@ tauri-build = { version = "2.0.0-beta.18", features = [] }
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
kcl-lib = { version = "0.1.53", path = "../src/wasm-lib/kcl" }
|
kcl-lib = { version = "0.2", path = "../src/wasm-lib/kcl" }
|
||||||
kittycad = "0.3.7"
|
kittycad = "0.3.7"
|
||||||
log = "0.4.21"
|
log = "0.4.21"
|
||||||
oauth2 = "4.4.2"
|
oauth2 = "4.4.2"
|
||||||
|
@ -423,7 +423,7 @@ describe('testing pipe operator special', () => {
|
|||||||
test('pipe operator with sketch', () => {
|
test('pipe operator with sketch', () => {
|
||||||
let code = `const mySketch = startSketchAt([0, 0])
|
let code = `const mySketch = startSketchAt([0, 0])
|
||||||
|> lineTo([2, 3], %)
|
|> lineTo([2, 3], %)
|
||||||
|> lineTo([0, 1], %, "myPath")
|
|> lineTo([0, 1], %, $myPath)
|
||||||
|> lineTo([1, 1], %)
|
|> lineTo([1, 1], %)
|
||||||
|> rx(45, %)
|
|> rx(45, %)
|
||||||
`
|
`
|
||||||
@ -435,14 +435,14 @@ describe('testing pipe operator special', () => {
|
|||||||
{
|
{
|
||||||
type: 'VariableDeclaration',
|
type: 'VariableDeclaration',
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 132,
|
end: 131,
|
||||||
kind: 'const',
|
kind: 'const',
|
||||||
digest: null,
|
digest: null,
|
||||||
declarations: [
|
declarations: [
|
||||||
{
|
{
|
||||||
type: 'VariableDeclarator',
|
type: 'VariableDeclarator',
|
||||||
start: 6,
|
start: 6,
|
||||||
end: 132,
|
end: 131,
|
||||||
id: {
|
id: {
|
||||||
type: 'Identifier',
|
type: 'Identifier',
|
||||||
start: 6,
|
start: 6,
|
||||||
@ -454,7 +454,7 @@ describe('testing pipe operator special', () => {
|
|||||||
init: {
|
init: {
|
||||||
type: 'PipeExpression',
|
type: 'PipeExpression',
|
||||||
start: 17,
|
start: 17,
|
||||||
end: 132,
|
end: 131,
|
||||||
digest: null,
|
digest: null,
|
||||||
body: [
|
body: [
|
||||||
{
|
{
|
||||||
@ -546,7 +546,7 @@ describe('testing pipe operator special', () => {
|
|||||||
{
|
{
|
||||||
type: 'CallExpression',
|
type: 'CallExpression',
|
||||||
start: 67,
|
start: 67,
|
||||||
end: 94,
|
end: 93,
|
||||||
digest: null,
|
digest: null,
|
||||||
callee: {
|
callee: {
|
||||||
type: 'Identifier',
|
type: 'Identifier',
|
||||||
@ -589,7 +589,7 @@ describe('testing pipe operator special', () => {
|
|||||||
{
|
{
|
||||||
type: 'TagDeclarator',
|
type: 'TagDeclarator',
|
||||||
start: 85,
|
start: 85,
|
||||||
end: 93,
|
end: 92,
|
||||||
value: 'myPath',
|
value: 'myPath',
|
||||||
digest: null,
|
digest: null,
|
||||||
},
|
},
|
||||||
@ -598,35 +598,35 @@ describe('testing pipe operator special', () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'CallExpression',
|
type: 'CallExpression',
|
||||||
start: 100,
|
start: 99,
|
||||||
end: 117,
|
end: 116,
|
||||||
digest: null,
|
digest: null,
|
||||||
callee: {
|
callee: {
|
||||||
type: 'Identifier',
|
type: 'Identifier',
|
||||||
start: 100,
|
start: 99,
|
||||||
end: 106,
|
end: 105,
|
||||||
name: 'lineTo',
|
name: 'lineTo',
|
||||||
digest: null,
|
digest: null,
|
||||||
},
|
},
|
||||||
arguments: [
|
arguments: [
|
||||||
{
|
{
|
||||||
type: 'ArrayExpression',
|
type: 'ArrayExpression',
|
||||||
start: 107,
|
start: 106,
|
||||||
end: 113,
|
end: 112,
|
||||||
digest: null,
|
digest: null,
|
||||||
elements: [
|
elements: [
|
||||||
{
|
{
|
||||||
type: 'Literal',
|
type: 'Literal',
|
||||||
start: 108,
|
start: 107,
|
||||||
end: 109,
|
end: 108,
|
||||||
value: 1,
|
value: 1,
|
||||||
raw: '1',
|
raw: '1',
|
||||||
digest: null,
|
digest: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'Literal',
|
type: 'Literal',
|
||||||
start: 111,
|
start: 110,
|
||||||
end: 112,
|
end: 111,
|
||||||
value: 1,
|
value: 1,
|
||||||
raw: '1',
|
raw: '1',
|
||||||
digest: null,
|
digest: null,
|
||||||
@ -635,8 +635,8 @@ describe('testing pipe operator special', () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'PipeSubstitution',
|
type: 'PipeSubstitution',
|
||||||
start: 115,
|
start: 114,
|
||||||
end: 116,
|
end: 115,
|
||||||
digest: null,
|
digest: null,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -644,29 +644,29 @@ describe('testing pipe operator special', () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'CallExpression',
|
type: 'CallExpression',
|
||||||
start: 123,
|
start: 122,
|
||||||
end: 132,
|
end: 131,
|
||||||
digest: null,
|
digest: null,
|
||||||
callee: {
|
callee: {
|
||||||
type: 'Identifier',
|
type: 'Identifier',
|
||||||
start: 123,
|
start: 122,
|
||||||
end: 125,
|
end: 124,
|
||||||
name: 'rx',
|
name: 'rx',
|
||||||
digest: null,
|
digest: null,
|
||||||
},
|
},
|
||||||
arguments: [
|
arguments: [
|
||||||
{
|
{
|
||||||
type: 'Literal',
|
type: 'Literal',
|
||||||
start: 126,
|
start: 125,
|
||||||
end: 128,
|
end: 127,
|
||||||
value: 45,
|
value: 45,
|
||||||
raw: '45',
|
raw: '45',
|
||||||
digest: null,
|
digest: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'PipeSubstitution',
|
type: 'PipeSubstitution',
|
||||||
start: 130,
|
start: 129,
|
||||||
end: 131,
|
end: 130,
|
||||||
digest: null,
|
digest: null,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -1782,11 +1782,11 @@ const key = 'c'`
|
|||||||
})
|
})
|
||||||
it('comments nested within a block statement', () => {
|
it('comments nested within a block statement', () => {
|
||||||
const code = `const mySketch = startSketchAt([0,0])
|
const code = `const mySketch = startSketchAt([0,0])
|
||||||
|> lineTo([0, 1], %, 'myPath')
|
|> lineTo([0, 1], %, $myPath)
|
||||||
|> lineTo([1, 1], %) /* this is
|
|> lineTo([1, 1], %) /* this is
|
||||||
a comment
|
a comment
|
||||||
spanning a few lines */
|
spanning a few lines */
|
||||||
|> lineTo([1,0], %, "rightPath")
|
|> lineTo([1,0], %, $rightPath)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
`
|
`
|
||||||
|
|
||||||
@ -1798,8 +1798,8 @@ const key = 'c'`
|
|||||||
.nonCodeNodes
|
.nonCodeNodes
|
||||||
expect(sketchNonCodeMeta[indexOfSecondLineToExpression][0]).toEqual({
|
expect(sketchNonCodeMeta[indexOfSecondLineToExpression][0]).toEqual({
|
||||||
type: 'NonCodeNode',
|
type: 'NonCodeNode',
|
||||||
start: 93,
|
start: 92,
|
||||||
end: 150,
|
end: 149,
|
||||||
digest: null,
|
digest: null,
|
||||||
value: {
|
value: {
|
||||||
type: 'inlineComment',
|
type: 'inlineComment',
|
||||||
@ -1812,7 +1812,7 @@ const key = 'c'`
|
|||||||
const code = [
|
const code = [
|
||||||
'const mySk1 = startSketchAt([0, 0])',
|
'const mySk1 = startSketchAt([0, 0])',
|
||||||
' |> lineTo([1, 1], %)',
|
' |> lineTo([1, 1], %)',
|
||||||
' |> lineTo([0, 1], %, "myPath")',
|
' |> lineTo([0, 1], %, $myPath)',
|
||||||
' |> lineTo([1, 1], %)',
|
' |> lineTo([1, 1], %)',
|
||||||
'// a comment',
|
'// a comment',
|
||||||
' |> rx(90, %)',
|
' |> rx(90, %)',
|
||||||
@ -1825,8 +1825,8 @@ const key = 'c'`
|
|||||||
.nonCodeNodes[3][0]
|
.nonCodeNodes[3][0]
|
||||||
expect(sketchNonCodeMeta).toEqual({
|
expect(sketchNonCodeMeta).toEqual({
|
||||||
type: 'NonCodeNode',
|
type: 'NonCodeNode',
|
||||||
start: 114,
|
start: 113,
|
||||||
end: 127,
|
end: 126,
|
||||||
digest: null,
|
digest: null,
|
||||||
value: {
|
value: {
|
||||||
type: 'blockComment',
|
type: 'blockComment',
|
||||||
@ -1968,7 +1968,7 @@ describe('testing nested call expressions', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('should recognise callExpresions in binaryExpressions', () => {
|
describe('should recognise callExpresions in binaryExpressions', () => {
|
||||||
const code = "xLineTo(segEndX('seg02', %) + 1, %)"
|
const code = 'xLineTo(segEndX(seg02, %) + 1, %)'
|
||||||
it('should recognise the callExp', () => {
|
it('should recognise the callExp', () => {
|
||||||
const ast = parse(code)
|
const ast = parse(code)
|
||||||
if (err(ast)) throw ast
|
if (err(ast)) throw ast
|
||||||
@ -1979,12 +1979,12 @@ describe('should recognise callExpresions in binaryExpressions', () => {
|
|||||||
type: 'BinaryExpression',
|
type: 'BinaryExpression',
|
||||||
operator: '+',
|
operator: '+',
|
||||||
start: 8,
|
start: 8,
|
||||||
end: 31,
|
end: 29,
|
||||||
digest: null,
|
digest: null,
|
||||||
left: {
|
left: {
|
||||||
type: 'CallExpression',
|
type: 'CallExpression',
|
||||||
start: 8,
|
start: 8,
|
||||||
end: 27,
|
end: 25,
|
||||||
digest: null,
|
digest: null,
|
||||||
callee: {
|
callee: {
|
||||||
type: 'Identifier',
|
type: 'Identifier',
|
||||||
@ -1997,11 +1997,11 @@ describe('should recognise callExpresions in binaryExpressions', () => {
|
|||||||
{
|
{
|
||||||
type: 'Identifier',
|
type: 'Identifier',
|
||||||
start: 16,
|
start: 16,
|
||||||
end: 23,
|
end: 21,
|
||||||
name: 'seg02',
|
name: 'seg02',
|
||||||
digest: null,
|
digest: null,
|
||||||
},
|
},
|
||||||
{ type: 'PipeSubstitution', start: 25, end: 26, digest: null },
|
{ type: 'PipeSubstitution', start: 23, end: 24, digest: null },
|
||||||
],
|
],
|
||||||
optional: false,
|
optional: false,
|
||||||
},
|
},
|
||||||
@ -2009,12 +2009,12 @@ describe('should recognise callExpresions in binaryExpressions', () => {
|
|||||||
type: 'Literal',
|
type: 'Literal',
|
||||||
value: 1,
|
value: 1,
|
||||||
raw: '1',
|
raw: '1',
|
||||||
start: 30,
|
start: 28,
|
||||||
end: 31,
|
end: 29,
|
||||||
digest: null,
|
digest: null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ type: 'PipeSubstitution', start: 33, end: 34, digest: null },
|
{ type: 'PipeSubstitution', start: 31, end: 32, digest: null },
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -45,9 +45,9 @@ const newVar = myVar + 1`
|
|||||||
it('sketch declaration', async () => {
|
it('sketch declaration', async () => {
|
||||||
let code = `const mySketch = startSketchOn('XY')
|
let code = `const mySketch = startSketchOn('XY')
|
||||||
|> startProfileAt([0,0], %)
|
|> startProfileAt([0,0], %)
|
||||||
|> lineTo([0,2], %, "myPath")
|
|> lineTo([0,2], %, $myPath)
|
||||||
|> lineTo([2,3], %)
|
|> lineTo([2,3], %)
|
||||||
|> lineTo([5,-1], %, "rightPath")
|
|> lineTo([5,-1], %, $rightPath)
|
||||||
// |> close(%)
|
// |> close(%)
|
||||||
`
|
`
|
||||||
const mem = await exe(code)
|
const mem = await exe(code)
|
||||||
@ -59,11 +59,11 @@ const newVar = myVar + 1`
|
|||||||
to: [0, 2],
|
to: [0, 2],
|
||||||
from: [0, 0],
|
from: [0, 0],
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [72, 98],
|
sourceRange: [72, 97],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
tag: {
|
tag: {
|
||||||
end: 97,
|
end: 96,
|
||||||
start: 89,
|
start: 89,
|
||||||
type: 'TagDeclarator',
|
type: 'TagDeclarator',
|
||||||
value: 'myPath',
|
value: 'myPath',
|
||||||
@ -76,7 +76,7 @@ const newVar = myVar + 1`
|
|||||||
from: [0, 2],
|
from: [0, 2],
|
||||||
tag: null,
|
tag: null,
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [104, 120],
|
sourceRange: [103, 119],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -85,12 +85,12 @@ const newVar = myVar + 1`
|
|||||||
to: [5, -1],
|
to: [5, -1],
|
||||||
from: [2, 3],
|
from: [2, 3],
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [126, 156],
|
sourceRange: [125, 154],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
tag: {
|
tag: {
|
||||||
end: 155,
|
end: 153,
|
||||||
start: 144,
|
start: 143,
|
||||||
type: 'TagDeclarator',
|
type: 'TagDeclarator',
|
||||||
value: 'rightPath',
|
value: 'rightPath',
|
||||||
digest: null,
|
digest: null,
|
||||||
@ -140,7 +140,7 @@ const newVar = myVar + 1`
|
|||||||
"const mySk1 = startSketchOn('XY')",
|
"const mySk1 = startSketchOn('XY')",
|
||||||
' |> startProfileAt([0,0], %)',
|
' |> startProfileAt([0,0], %)',
|
||||||
' |> lineTo([1,1], %)',
|
' |> lineTo([1,1], %)',
|
||||||
' |> lineTo([0, 1], %, "myPath")',
|
' |> lineTo([0, 1], %, $myPath)',
|
||||||
' |> lineTo([1,1], %)',
|
' |> lineTo([1,1], %)',
|
||||||
// ' |> rx(90, %)',
|
// ' |> rx(90, %)',
|
||||||
].join('\n')
|
].join('\n')
|
||||||
@ -161,7 +161,7 @@ const newVar = myVar + 1`
|
|||||||
myPath: {
|
myPath: {
|
||||||
__meta: [
|
__meta: [
|
||||||
{
|
{
|
||||||
sourceRange: [109, 117],
|
sourceRange: [109, 116],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
type: 'TagIdentifier',
|
type: 'TagIdentifier',
|
||||||
@ -184,11 +184,11 @@ const newVar = myVar + 1`
|
|||||||
to: [0, 1],
|
to: [0, 1],
|
||||||
from: [1, 1],
|
from: [1, 1],
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [91, 118],
|
sourceRange: [91, 117],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
tag: {
|
tag: {
|
||||||
end: 117,
|
end: 116,
|
||||||
start: 109,
|
start: 109,
|
||||||
type: 'TagDeclarator',
|
type: 'TagDeclarator',
|
||||||
value: 'myPath',
|
value: 'myPath',
|
||||||
@ -201,7 +201,7 @@ const newVar = myVar + 1`
|
|||||||
from: [0, 1],
|
from: [0, 1],
|
||||||
tag: null,
|
tag: null,
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [124, 140],
|
sourceRange: [123, 139],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -367,10 +367,10 @@ describe('testing math operators', () => {
|
|||||||
`const myVar = 3`,
|
`const myVar = 3`,
|
||||||
`const part001 = startSketchOn('XY')`,
|
`const part001 = startSketchOn('XY')`,
|
||||||
` |> startProfileAt([0, 0], %)`,
|
` |> startProfileAt([0, 0], %)`,
|
||||||
` |> line([3, 4], %, 'seg01')`,
|
` |> line([3, 4], %, $seg01)`,
|
||||||
` |> line([`,
|
` |> line([`,
|
||||||
` min(segLen('seg01', %), myVar),`,
|
` min(segLen(seg01, %), myVar),`,
|
||||||
` -legLen(segLen('seg01', %), myVar)`,
|
` -legLen(segLen(seg01, %), myVar)`,
|
||||||
`], %)`,
|
`], %)`,
|
||||||
``,
|
``,
|
||||||
].join('\n')
|
].join('\n')
|
||||||
@ -380,8 +380,8 @@ describe('testing math operators', () => {
|
|||||||
expect((sketch as SketchGroup).value?.[1]?.from).toEqual([3, 4])
|
expect((sketch as SketchGroup).value?.[1]?.from).toEqual([3, 4])
|
||||||
expect((sketch as SketchGroup).value?.[1]?.to).toEqual([6, 0])
|
expect((sketch as SketchGroup).value?.[1]?.to).toEqual([6, 0])
|
||||||
const removedUnaryExp = code.replace(
|
const removedUnaryExp = code.replace(
|
||||||
`-legLen(segLen('seg01', %), myVar)`,
|
`-legLen(segLen(seg01, %), myVar)`,
|
||||||
`legLen(segLen('seg01', %), myVar)`
|
`legLen(segLen(seg01, %), myVar)`
|
||||||
)
|
)
|
||||||
const removedUnaryExpMem = await exe(removedUnaryExp)
|
const removedUnaryExpMem = await exe(removedUnaryExp)
|
||||||
const removedUnaryExpMemSketch = removedUnaryExpMem.get('part001')
|
const removedUnaryExpMemSketch = removedUnaryExpMem.get('part001')
|
||||||
|
@ -12,10 +12,10 @@ describe('testing getNodePathFromSourceRange', () => {
|
|||||||
const myVar = 5
|
const myVar = 5
|
||||||
const sk3 = startSketchAt([0, 0])
|
const sk3 = startSketchAt([0, 0])
|
||||||
|> lineTo([1, 2], %)
|
|> lineTo([1, 2], %)
|
||||||
|> lineTo([3, 4], %, 'yo')
|
|> lineTo([3, 4], %, $yo)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
`
|
`
|
||||||
const subStr = "lineTo([3, 4], %, 'yo')"
|
const subStr = 'lineTo([3, 4], %, $yo)'
|
||||||
const lineToSubstringIndex = code.indexOf(subStr)
|
const lineToSubstringIndex = code.indexOf(subStr)
|
||||||
const sourceRange: [number, number] = [
|
const sourceRange: [number, number] = [
|
||||||
lineToSubstringIndex,
|
lineToSubstringIndex,
|
||||||
|
@ -460,12 +460,12 @@ describe('Testing deleteSegmentFromPipeExpression', () => {
|
|||||||
const code = `const part001 = startSketchOn('-XZ')
|
const code = `const part001 = startSketchOn('-XZ')
|
||||||
|> startProfileAt([54.78, -95.91], %)
|
|> startProfileAt([54.78, -95.91], %)
|
||||||
|> line([306.21, 198.82], %)
|
|> line([306.21, 198.82], %)
|
||||||
|> line([306.21, 198.85], %, 'a')
|
|> line([306.21, 198.85], %, $a)
|
||||||
|> line([306.21, 198.87], %)`
|
|> line([306.21, 198.87], %)`
|
||||||
const ast = parse(code)
|
const ast = parse(code)
|
||||||
if (err(ast)) throw ast
|
if (err(ast)) throw ast
|
||||||
const programMemory = await enginelessExecutor(ast)
|
const programMemory = await enginelessExecutor(ast)
|
||||||
const lineOfInterest = "line([306.21, 198.85], %, 'a')"
|
const lineOfInterest = 'line([306.21, 198.85], %, $a)'
|
||||||
const range: [number, number] = [
|
const range: [number, number] = [
|
||||||
code.indexOf(lineOfInterest),
|
code.indexOf(lineOfInterest),
|
||||||
code.indexOf(lineOfInterest) + lineOfInterest.length,
|
code.indexOf(lineOfInterest) + lineOfInterest.length,
|
||||||
|
@ -272,10 +272,10 @@ describe('testing doesPipeHave', () => {
|
|||||||
it('finds close', () => {
|
it('finds close', () => {
|
||||||
const exampleCode = `const length001 = 2
|
const exampleCode = `const length001 = 2
|
||||||
const part001 = startSketchAt([-1.41, 3.46])
|
const part001 = startSketchAt([-1.41, 3.46])
|
||||||
|> line([19.49, 1.16], %, 'seg01')
|
|> line([19.49, 1.16], %, $seg01)
|
||||||
|> angledLine([-35, length001], %)
|
|> angledLine([-35, length001], %)
|
||||||
|> line([-3.22, -7.36], %)
|
|> line([-3.22, -7.36], %)
|
||||||
|> angledLine([-175, segLen('seg01', %)], %)
|
|> angledLine([-175, segLen(seg01, %)], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
`
|
`
|
||||||
const ast = parse(exampleCode)
|
const ast = parse(exampleCode)
|
||||||
@ -291,10 +291,10 @@ const part001 = startSketchAt([-1.41, 3.46])
|
|||||||
it('finds extrude', () => {
|
it('finds extrude', () => {
|
||||||
const exampleCode = `const length001 = 2
|
const exampleCode = `const length001 = 2
|
||||||
const part001 = startSketchAt([-1.41, 3.46])
|
const part001 = startSketchAt([-1.41, 3.46])
|
||||||
|> line([19.49, 1.16], %, 'seg01')
|
|> line([19.49, 1.16], %, $seg01)
|
||||||
|> angledLine([-35, length001], %)
|
|> angledLine([-35, length001], %)
|
||||||
|> line([-3.22, -7.36], %)
|
|> line([-3.22, -7.36], %)
|
||||||
|> angledLine([-175, segLen('seg01', %)], %)
|
|> angledLine([-175, segLen(seg01, %)], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(1, %)
|
|> extrude(1, %)
|
||||||
`
|
`
|
||||||
@ -311,10 +311,10 @@ const part001 = startSketchAt([-1.41, 3.46])
|
|||||||
it('does NOT find close', () => {
|
it('does NOT find close', () => {
|
||||||
const exampleCode = `const length001 = 2
|
const exampleCode = `const length001 = 2
|
||||||
const part001 = startSketchAt([-1.41, 3.46])
|
const part001 = startSketchAt([-1.41, 3.46])
|
||||||
|> line([19.49, 1.16], %, 'seg01')
|
|> line([19.49, 1.16], %, $seg01)
|
||||||
|> angledLine([-35, length001], %)
|
|> angledLine([-35, length001], %)
|
||||||
|> line([-3.22, -7.36], %)
|
|> line([-3.22, -7.36], %)
|
||||||
|> angledLine([-175, segLen('seg01', %)], %)
|
|> angledLine([-175, segLen(seg01, %)], %)
|
||||||
`
|
`
|
||||||
const ast = parse(exampleCode)
|
const ast = parse(exampleCode)
|
||||||
if (err(ast)) throw ast
|
if (err(ast)) throw ast
|
||||||
@ -344,10 +344,10 @@ describe('testing hasExtrudeSketchGroup', () => {
|
|||||||
it('find sketch group', async () => {
|
it('find sketch group', async () => {
|
||||||
const exampleCode = `const length001 = 2
|
const exampleCode = `const length001 = 2
|
||||||
const part001 = startSketchAt([-1.41, 3.46])
|
const part001 = startSketchAt([-1.41, 3.46])
|
||||||
|> line([19.49, 1.16], %, 'seg01')
|
|> line([19.49, 1.16], %, $seg01)
|
||||||
|> angledLine([-35, length001], %)
|
|> angledLine([-35, length001], %)
|
||||||
|> line([-3.22, -7.36], %)
|
|> line([-3.22, -7.36], %)
|
||||||
|> angledLine([-175, segLen('seg01', %)], %)`
|
|> angledLine([-175, segLen(seg01, %)], %)`
|
||||||
const ast = parse(exampleCode)
|
const ast = parse(exampleCode)
|
||||||
if (err(ast)) throw ast
|
if (err(ast)) throw ast
|
||||||
|
|
||||||
@ -362,10 +362,10 @@ const part001 = startSketchAt([-1.41, 3.46])
|
|||||||
it('find extrude group', async () => {
|
it('find extrude group', async () => {
|
||||||
const exampleCode = `const length001 = 2
|
const exampleCode = `const length001 = 2
|
||||||
const part001 = startSketchAt([-1.41, 3.46])
|
const part001 = startSketchAt([-1.41, 3.46])
|
||||||
|> line([19.49, 1.16], %, 'seg01')
|
|> line([19.49, 1.16], %, $seg01)
|
||||||
|> angledLine([-35, length001], %)
|
|> angledLine([-35, length001], %)
|
||||||
|> line([-3.22, -7.36], %)
|
|> line([-3.22, -7.36], %)
|
||||||
|> angledLine([-175, segLen('seg01', %)], %)
|
|> angledLine([-175, segLen(seg01, %)], %)
|
||||||
|> extrude(1, %)`
|
|> extrude(1, %)`
|
||||||
const ast = parse(exampleCode)
|
const ast = parse(exampleCode)
|
||||||
if (err(ast)) throw ast
|
if (err(ast)) throw ast
|
||||||
|
@ -512,11 +512,11 @@ const part001 = startSketchOn('XY')
|
|||||||
|> angledLine({
|
|> angledLine({
|
||||||
angle: halfArmAngle,
|
angle: halfArmAngle,
|
||||||
length: 2.45,
|
length: 2.45,
|
||||||
}, %, 'seg01bing') // partial
|
}, %, $seg01bing) // partial
|
||||||
|> xLine(4.4, %) // partial
|
|> xLine(4.4, %) // partial
|
||||||
|> yLine(-1, %) // partial
|
|> yLine(-1, %) // partial
|
||||||
|> xLine(-4.2 + 0, %) // full
|
|> xLine(-4.2 + 0, %) // full
|
||||||
|> angledLine([segAng('seg01bing', %) + 180, 1.79], %) // partial
|
|> angledLine([segAng(seg01bing, %) + 180, 1.79], %) // partial
|
||||||
|> line([1.44, -0.74], %) // free
|
|> line([1.44, -0.74], %) // free
|
||||||
|> xLine(3.36, %) // partial
|
|> xLine(3.36, %) // partial
|
||||||
|> line([-1.49, 1.06], %) // free
|
|> line([-1.49, 1.06], %) // free
|
||||||
|
@ -9,14 +9,14 @@ describe('testing angledLineThatIntersects', () => {
|
|||||||
it('angledLineThatIntersects should intersect with another line', async () => {
|
it('angledLineThatIntersects should intersect with another line', async () => {
|
||||||
const code = (offset: string) => `const part001 = startSketchOn('XY')
|
const code = (offset: string) => `const part001 = startSketchOn('XY')
|
||||||
|> startProfileAt([0, 0], %)
|
|> startProfileAt([0, 0], %)
|
||||||
|> lineTo([2, 2], %, "yo")
|
|> lineTo([2, 2], %, $yo)
|
||||||
|> lineTo([3, 1], %)
|
|> lineTo([3, 1], %)
|
||||||
|> angledLineThatIntersects({
|
|> angledLineThatIntersects({
|
||||||
angle: 180,
|
angle: 180,
|
||||||
intersectTag: 'yo',
|
intersectTag: yo,
|
||||||
offset: ${offset},
|
offset: ${offset},
|
||||||
}, %, "yo2")
|
}, %, $yo2)
|
||||||
const intersect = segEndX('yo2', part001)`
|
const intersect = segEndX(yo2, part001)`
|
||||||
const mem = await enginelessExecutor(parse(code('-1')))
|
const mem = await enginelessExecutor(parse(code('-1')))
|
||||||
expect(mem.get('intersect')?.value).toBe(1 + Math.sqrt(2))
|
expect(mem.get('intersect')?.value).toBe(1 + Math.sqrt(2))
|
||||||
const noOffset = await enginelessExecutor(parse(code('0')))
|
const noOffset = await enginelessExecutor(parse(code('0')))
|
||||||
|
2
src/wasm-lib/Cargo.lock
generated
2
src/wasm-lib/Cargo.lock
generated
@ -1391,7 +1391,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kcl-lib"
|
name = "kcl-lib"
|
||||||
version = "0.1.73"
|
version = "0.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"approx",
|
"approx",
|
||||||
|
@ -8,7 +8,7 @@ license = "MIT"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.86"
|
anyhow = "1.0.86"
|
||||||
hyper = { version = "0.14.29", features = ["server"] }
|
hyper = { version = "0.14.29", features = ["server"] }
|
||||||
kcl-lib = { version = "0.1.70", path = "../kcl" }
|
kcl-lib = { version = "0.2", path = "../kcl" }
|
||||||
pico-args = "0.5.0"
|
pico-args = "0.5.0"
|
||||||
serde = { version = "1.0.204", features = ["derive"] }
|
serde = { version = "1.0.204", features = ["derive"] }
|
||||||
serde_json = "1.0.120"
|
serde_json = "1.0.120"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "kcl-lib"
|
name = "kcl-lib"
|
||||||
description = "KittyCAD Language implementation and tools"
|
description = "KittyCAD Language implementation and tools"
|
||||||
version = "0.1.73"
|
version = "0.2.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/KittyCAD/modeling-app"
|
repository = "https://github.com/KittyCAD/modeling-app"
|
||||||
|
@ -742,19 +742,18 @@ impl MemoryItem {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Backwards compatibility for getting a tag from a memory item.
|
/// Get a tag identifier from a memory item.
|
||||||
pub fn get_tag_identifier(&self) -> Result<TagIdentifier, KclError> {
|
pub fn get_tag_identifier(&self) -> Result<TagIdentifier, KclError> {
|
||||||
match self {
|
match self {
|
||||||
MemoryItem::TagIdentifier(t) => Ok(*t.clone()),
|
MemoryItem::TagIdentifier(t) => Ok(*t.clone()),
|
||||||
MemoryItem::UserVal(u) => {
|
MemoryItem::UserVal(_) => {
|
||||||
if let Some(identifier) = self.get_json_opt::<TagIdentifier>()? {
|
if let Some(identifier) = self.get_json_opt::<TagIdentifier>()? {
|
||||||
Ok(identifier)
|
Ok(identifier)
|
||||||
} else {
|
} else {
|
||||||
let name: String = self.get_json()?;
|
Err(KclError::Semantic(KclErrorDetails {
|
||||||
Ok(TagIdentifier {
|
message: format!("Not a tag identifier: {:?}", self),
|
||||||
value: name,
|
source_ranges: self.clone().into(),
|
||||||
meta: u.meta.clone(),
|
}))
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => Err(KclError::Semantic(KclErrorDetails {
|
_ => Err(KclError::Semantic(KclErrorDetails {
|
||||||
@ -764,19 +763,10 @@ impl MemoryItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Backwards compatibility for getting a tag from a memory item.
|
/// Get a tag declarator from a memory item.
|
||||||
pub fn get_tag_declarator(&self) -> Result<TagDeclarator, KclError> {
|
pub fn get_tag_declarator(&self) -> Result<TagDeclarator, KclError> {
|
||||||
match self {
|
match self {
|
||||||
MemoryItem::TagDeclarator(t) => Ok(*t.clone()),
|
MemoryItem::TagDeclarator(t) => Ok(*t.clone()),
|
||||||
MemoryItem::UserVal(u) => {
|
|
||||||
let name: String = self.get_json()?;
|
|
||||||
Ok(TagDeclarator {
|
|
||||||
name,
|
|
||||||
start: u.meta[0].source_range.start(),
|
|
||||||
end: u.meta[0].source_range.end(),
|
|
||||||
digest: None,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
_ => Err(KclError::Semantic(KclErrorDetails {
|
_ => Err(KclError::Semantic(KclErrorDetails {
|
||||||
message: format!("Not a tag declarator: {:?}", self),
|
message: format!("Not a tag declarator: {:?}", self),
|
||||||
source_ranges: self.clone().into(),
|
source_ranges: self.clone().into(),
|
||||||
@ -784,22 +774,10 @@ impl MemoryItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Backwards compatibility for getting an optional tag from a memory item.
|
/// Get an optional tag from a memory item.
|
||||||
pub fn get_tag_declarator_opt(&self) -> Result<Option<TagDeclarator>, KclError> {
|
pub fn get_tag_declarator_opt(&self) -> Result<Option<TagDeclarator>, KclError> {
|
||||||
match self {
|
match self {
|
||||||
MemoryItem::TagDeclarator(t) => Ok(Some(*t.clone())),
|
MemoryItem::TagDeclarator(t) => Ok(Some(*t.clone())),
|
||||||
MemoryItem::UserVal(u) => {
|
|
||||||
if let Some(name) = self.get_json_opt::<String>()? {
|
|
||||||
Ok(Some(TagDeclarator {
|
|
||||||
name,
|
|
||||||
start: u.meta[0].source_range.start(),
|
|
||||||
end: u.meta[0].source_range.end(),
|
|
||||||
digest: None,
|
|
||||||
}))
|
|
||||||
} else {
|
|
||||||
Ok(None)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => Err(KclError::Semantic(KclErrorDetails {
|
_ => Err(KclError::Semantic(KclErrorDetails {
|
||||||
message: format!("Not a tag declarator: {:?}", self),
|
message: format!("Not a tag declarator: {:?}", self),
|
||||||
source_ranges: self.clone().into(),
|
source_ranges: self.clone().into(),
|
||||||
@ -1982,14 +1960,14 @@ const newVar = myVar + 1"#;
|
|||||||
format!(
|
format!(
|
||||||
r#"const part001 = startSketchOn('XY')
|
r#"const part001 = startSketchOn('XY')
|
||||||
|> startProfileAt([0, 0], %)
|
|> startProfileAt([0, 0], %)
|
||||||
|> lineTo([2, 2], %, "yo")
|
|> lineTo([2, 2], %, $yo)
|
||||||
|> lineTo([3, 1], %)
|
|> lineTo([3, 1], %)
|
||||||
|> angledLineThatIntersects({{
|
|> angledLineThatIntersects({{
|
||||||
angle: 180,
|
angle: 180,
|
||||||
intersectTag: 'yo',
|
intersectTag: yo,
|
||||||
offset: {},
|
offset: {},
|
||||||
}}, %, 'yo2')
|
}}, %, $yo2)
|
||||||
const intersect = segEndX('yo2', part001)"#,
|
const intersect = segEndX(yo2, part001)"#,
|
||||||
offset
|
offset
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
@ -2053,10 +2031,10 @@ 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([3, 4], %, $seg01)
|
||||||
|> line([
|
|> line([
|
||||||
min(segLen('seg01', %), myVar),
|
min(segLen(seg01, %), myVar),
|
||||||
-legLen(segLen('seg01', %), myVar)
|
-legLen(segLen(seg01, %), myVar)
|
||||||
], %)
|
], %)
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
@ -2068,10 +2046,10 @@ 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([3, 4], %, $seg01)
|
||||||
|> line([
|
|> line([
|
||||||
min(segLen('seg01', %), myVar),
|
min(segLen(seg01, %), myVar),
|
||||||
legLen(segLen('seg01', %), myVar)
|
legLen(segLen(seg01, %), myVar)
|
||||||
], %)
|
], %)
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
@ -2366,7 +2344,7 @@ fn transform = (replicaId) => {
|
|||||||
|
|
||||||
fn layer = () => {
|
fn layer = () => {
|
||||||
return startSketchOn("XY")
|
return startSketchOn("XY")
|
||||||
|> circle([0, 0], 1, %, 'tag1')
|
|> circle([0, 0], 1, %, $tag1)
|
||||||
|> extrude(10, %)
|
|> extrude(10, %)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2494,7 +2472,7 @@ fn transform = (replicaId) => {
|
|||||||
|
|
||||||
fn layer = () => {
|
fn layer = () => {
|
||||||
return startSketchOn("XY")
|
return startSketchOn("XY")
|
||||||
|> circle([0, 0], 1, %, 'tag1')
|
|> circle([0, 0], 1, %, $tag1)
|
||||||
|> extrude(10, %)
|
|> extrude(10, %)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1502,7 +1502,7 @@ fn binding_name(i: TokenSlice) -> PResult<Identifier> {
|
|||||||
fn fn_call(i: TokenSlice) -> PResult<CallExpression> {
|
fn fn_call(i: TokenSlice) -> PResult<CallExpression> {
|
||||||
let fn_name = identifier(i)?;
|
let fn_name = identifier(i)?;
|
||||||
let _ = terminated(open_paren, opt(whitespace)).parse_next(i)?;
|
let _ = terminated(open_paren, opt(whitespace)).parse_next(i)?;
|
||||||
let mut args = arguments(i)?;
|
let args = arguments(i)?;
|
||||||
if let Some(std_fn) = crate::std::get_stdlib_fn(&fn_name.name) {
|
if let Some(std_fn) = crate::std::get_stdlib_fn(&fn_name.name) {
|
||||||
// Type check the arguments.
|
// Type check the arguments.
|
||||||
for (i, spec_arg) in std_fn.args().iter().enumerate() {
|
for (i, spec_arg) in std_fn.args().iter().enumerate() {
|
||||||
@ -1511,8 +1511,7 @@ fn fn_call(i: TokenSlice) -> PResult<CallExpression> {
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
match spec_arg.type_.as_ref() {
|
match spec_arg.type_.as_ref() {
|
||||||
"TagDeclarator" => {
|
"TagDeclarator" => match &arg {
|
||||||
match &arg {
|
|
||||||
Value::Identifier(_) => {
|
Value::Identifier(_) => {
|
||||||
// These are fine since we want someone to be able to map a variable to a tag declarator.
|
// These are fine since we want someone to be able to map a variable to a tag declarator.
|
||||||
}
|
}
|
||||||
@ -1521,31 +1520,6 @@ fn fn_call(i: TokenSlice) -> PResult<CallExpression> {
|
|||||||
.into_valid_binding_name()
|
.into_valid_binding_name()
|
||||||
.map_err(|e| ErrMode::Cut(ContextError::from(e)))?;
|
.map_err(|e| ErrMode::Cut(ContextError::from(e)))?;
|
||||||
}
|
}
|
||||||
Value::Literal(literal) => {
|
|
||||||
let LiteralValue::String(name) = &literal.value else {
|
|
||||||
return Err(ErrMode::Cut(
|
|
||||||
KclError::Syntax(KclErrorDetails {
|
|
||||||
source_ranges: vec![SourceRange([arg.start(), arg.end()])],
|
|
||||||
message: format!("Expected a tag declarator like `$name`, found {:?}", literal),
|
|
||||||
})
|
|
||||||
.into(),
|
|
||||||
));
|
|
||||||
};
|
|
||||||
|
|
||||||
// Convert this to a TagDeclarator.
|
|
||||||
let tag = TagDeclarator {
|
|
||||||
start: literal.start,
|
|
||||||
end: literal.end,
|
|
||||||
name: name.to_string(),
|
|
||||||
digest: None,
|
|
||||||
};
|
|
||||||
let tag = tag
|
|
||||||
.into_valid_binding_name()
|
|
||||||
.map_err(|e| ErrMode::Cut(ContextError::from(e)))?;
|
|
||||||
|
|
||||||
// Replace the literal with the tag.
|
|
||||||
args[i] = Value::TagDeclarator(Box::new(tag));
|
|
||||||
}
|
|
||||||
e => {
|
e => {
|
||||||
return Err(ErrMode::Cut(
|
return Err(ErrMode::Cut(
|
||||||
KclError::Syntax(KclErrorDetails {
|
KclError::Syntax(KclErrorDetails {
|
||||||
@ -1555,33 +1529,9 @@ fn fn_call(i: TokenSlice) -> PResult<CallExpression> {
|
|||||||
.into(),
|
.into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
"TagIdentifier" => match &arg {
|
||||||
"TagIdentifier" => {
|
|
||||||
match &arg {
|
|
||||||
Value::Identifier(_) => {}
|
Value::Identifier(_) => {}
|
||||||
Value::Literal(literal) => {
|
|
||||||
let LiteralValue::String(name) = &literal.value else {
|
|
||||||
return Err(ErrMode::Cut(
|
|
||||||
KclError::Syntax(KclErrorDetails {
|
|
||||||
source_ranges: vec![SourceRange([arg.start(), arg.end()])],
|
|
||||||
message: format!("Expected a tag declarator like `$name`, found {:?}", literal),
|
|
||||||
})
|
|
||||||
.into(),
|
|
||||||
));
|
|
||||||
};
|
|
||||||
|
|
||||||
// Convert this to a TagDeclarator.
|
|
||||||
let tag = Identifier {
|
|
||||||
start: literal.start,
|
|
||||||
end: literal.end,
|
|
||||||
name: name.to_string(),
|
|
||||||
digest: None,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Replace the literal with the tag.
|
|
||||||
args[i] = Value::Identifier(Box::new(tag));
|
|
||||||
}
|
|
||||||
Value::MemberExpression(_) => {}
|
Value::MemberExpression(_) => {}
|
||||||
e => {
|
e => {
|
||||||
return Err(ErrMode::Cut(
|
return Err(ErrMode::Cut(
|
||||||
@ -1592,8 +1542,7 @@ fn fn_call(i: TokenSlice) -> PResult<CallExpression> {
|
|||||||
.into(),
|
.into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3289,9 +3238,9 @@ mod snapshot_tests {
|
|||||||
snapshot_test!(
|
snapshot_test!(
|
||||||
af,
|
af,
|
||||||
r#"const mySketch = startSketchAt([0,0])
|
r#"const mySketch = startSketchAt([0,0])
|
||||||
|> lineTo([0, 1], %, 'myPath')
|
|> lineTo([0, 1], %, $myPath)
|
||||||
|> lineTo([1, 1], %)
|
|> lineTo([1, 1], %)
|
||||||
|> lineTo([1, 0], %, 'rightPath')
|
|> lineTo([1, 0], %, $rightPath)
|
||||||
|> close(%)"#
|
|> close(%)"#
|
||||||
);
|
);
|
||||||
snapshot_test!(
|
snapshot_test!(
|
||||||
|
@ -4,18 +4,18 @@ expression: actual
|
|||||||
---
|
---
|
||||||
{
|
{
|
||||||
"start": 0,
|
"start": 0,
|
||||||
"end": 167,
|
"end": 165,
|
||||||
"body": [
|
"body": [
|
||||||
{
|
{
|
||||||
"type": "VariableDeclaration",
|
"type": "VariableDeclaration",
|
||||||
"type": "VariableDeclaration",
|
"type": "VariableDeclaration",
|
||||||
"start": 0,
|
"start": 0,
|
||||||
"end": 167,
|
"end": 165,
|
||||||
"declarations": [
|
"declarations": [
|
||||||
{
|
{
|
||||||
"type": "VariableDeclarator",
|
"type": "VariableDeclarator",
|
||||||
"start": 6,
|
"start": 6,
|
||||||
"end": 167,
|
"end": 165,
|
||||||
"id": {
|
"id": {
|
||||||
"type": "Identifier",
|
"type": "Identifier",
|
||||||
"start": 6,
|
"start": 6,
|
||||||
@ -27,7 +27,7 @@ expression: actual
|
|||||||
"type": "PipeExpression",
|
"type": "PipeExpression",
|
||||||
"type": "PipeExpression",
|
"type": "PipeExpression",
|
||||||
"start": 17,
|
"start": 17,
|
||||||
"end": 167,
|
"end": 165,
|
||||||
"body": [
|
"body": [
|
||||||
{
|
{
|
||||||
"type": "CallExpression",
|
"type": "CallExpression",
|
||||||
@ -77,7 +77,7 @@ expression: actual
|
|||||||
"type": "CallExpression",
|
"type": "CallExpression",
|
||||||
"type": "CallExpression",
|
"type": "CallExpression",
|
||||||
"start": 49,
|
"start": 49,
|
||||||
"end": 76,
|
"end": 75,
|
||||||
"callee": {
|
"callee": {
|
||||||
"type": "Identifier",
|
"type": "Identifier",
|
||||||
"start": 49,
|
"start": 49,
|
||||||
@ -124,7 +124,7 @@ expression: actual
|
|||||||
"type": "TagDeclarator",
|
"type": "TagDeclarator",
|
||||||
"type": "TagDeclarator",
|
"type": "TagDeclarator",
|
||||||
"start": 67,
|
"start": 67,
|
||||||
"end": 75,
|
"end": 74,
|
||||||
"value": "myPath",
|
"value": "myPath",
|
||||||
"digest": null
|
"digest": null
|
||||||
}
|
}
|
||||||
@ -135,12 +135,12 @@ expression: actual
|
|||||||
{
|
{
|
||||||
"type": "CallExpression",
|
"type": "CallExpression",
|
||||||
"type": "CallExpression",
|
"type": "CallExpression",
|
||||||
"start": 88,
|
"start": 87,
|
||||||
"end": 105,
|
"end": 104,
|
||||||
"callee": {
|
"callee": {
|
||||||
"type": "Identifier",
|
"type": "Identifier",
|
||||||
"start": 88,
|
"start": 87,
|
||||||
"end": 94,
|
"end": 93,
|
||||||
"name": "lineTo",
|
"name": "lineTo",
|
||||||
"digest": null
|
"digest": null
|
||||||
},
|
},
|
||||||
@ -148,14 +148,14 @@ expression: actual
|
|||||||
{
|
{
|
||||||
"type": "ArrayExpression",
|
"type": "ArrayExpression",
|
||||||
"type": "ArrayExpression",
|
"type": "ArrayExpression",
|
||||||
"start": 95,
|
"start": 94,
|
||||||
"end": 101,
|
"end": 100,
|
||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"type": "Literal",
|
"type": "Literal",
|
||||||
"type": "Literal",
|
"type": "Literal",
|
||||||
"start": 96,
|
"start": 95,
|
||||||
"end": 97,
|
"end": 96,
|
||||||
"value": 1,
|
"value": 1,
|
||||||
"raw": "1",
|
"raw": "1",
|
||||||
"digest": null
|
"digest": null
|
||||||
@ -163,8 +163,8 @@ expression: actual
|
|||||||
{
|
{
|
||||||
"type": "Literal",
|
"type": "Literal",
|
||||||
"type": "Literal",
|
"type": "Literal",
|
||||||
"start": 99,
|
"start": 98,
|
||||||
"end": 100,
|
"end": 99,
|
||||||
"value": 1,
|
"value": 1,
|
||||||
"raw": "1",
|
"raw": "1",
|
||||||
"digest": null
|
"digest": null
|
||||||
@ -175,8 +175,8 @@ expression: actual
|
|||||||
{
|
{
|
||||||
"type": "PipeSubstitution",
|
"type": "PipeSubstitution",
|
||||||
"type": "PipeSubstitution",
|
"type": "PipeSubstitution",
|
||||||
"start": 103,
|
"start": 102,
|
||||||
"end": 104,
|
"end": 103,
|
||||||
"digest": null
|
"digest": null
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -186,12 +186,12 @@ expression: actual
|
|||||||
{
|
{
|
||||||
"type": "CallExpression",
|
"type": "CallExpression",
|
||||||
"type": "CallExpression",
|
"type": "CallExpression",
|
||||||
"start": 117,
|
"start": 116,
|
||||||
"end": 147,
|
"end": 145,
|
||||||
"callee": {
|
"callee": {
|
||||||
"type": "Identifier",
|
"type": "Identifier",
|
||||||
"start": 117,
|
"start": 116,
|
||||||
"end": 123,
|
"end": 122,
|
||||||
"name": "lineTo",
|
"name": "lineTo",
|
||||||
"digest": null
|
"digest": null
|
||||||
},
|
},
|
||||||
@ -199,14 +199,14 @@ expression: actual
|
|||||||
{
|
{
|
||||||
"type": "ArrayExpression",
|
"type": "ArrayExpression",
|
||||||
"type": "ArrayExpression",
|
"type": "ArrayExpression",
|
||||||
"start": 124,
|
"start": 123,
|
||||||
"end": 130,
|
"end": 129,
|
||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"type": "Literal",
|
"type": "Literal",
|
||||||
"type": "Literal",
|
"type": "Literal",
|
||||||
"start": 125,
|
"start": 124,
|
||||||
"end": 126,
|
"end": 125,
|
||||||
"value": 1,
|
"value": 1,
|
||||||
"raw": "1",
|
"raw": "1",
|
||||||
"digest": null
|
"digest": null
|
||||||
@ -214,8 +214,8 @@ expression: actual
|
|||||||
{
|
{
|
||||||
"type": "Literal",
|
"type": "Literal",
|
||||||
"type": "Literal",
|
"type": "Literal",
|
||||||
"start": 128,
|
"start": 127,
|
||||||
"end": 129,
|
"end": 128,
|
||||||
"value": 0,
|
"value": 0,
|
||||||
"raw": "0",
|
"raw": "0",
|
||||||
"digest": null
|
"digest": null
|
||||||
@ -226,15 +226,15 @@ expression: actual
|
|||||||
{
|
{
|
||||||
"type": "PipeSubstitution",
|
"type": "PipeSubstitution",
|
||||||
"type": "PipeSubstitution",
|
"type": "PipeSubstitution",
|
||||||
"start": 132,
|
"start": 131,
|
||||||
"end": 133,
|
"end": 132,
|
||||||
"digest": null
|
"digest": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TagDeclarator",
|
"type": "TagDeclarator",
|
||||||
"type": "TagDeclarator",
|
"type": "TagDeclarator",
|
||||||
"start": 135,
|
"start": 134,
|
||||||
"end": 146,
|
"end": 144,
|
||||||
"value": "rightPath",
|
"value": "rightPath",
|
||||||
"digest": null
|
"digest": null
|
||||||
}
|
}
|
||||||
@ -245,12 +245,12 @@ expression: actual
|
|||||||
{
|
{
|
||||||
"type": "CallExpression",
|
"type": "CallExpression",
|
||||||
"type": "CallExpression",
|
"type": "CallExpression",
|
||||||
"start": 159,
|
"start": 157,
|
||||||
"end": 167,
|
"end": 165,
|
||||||
"callee": {
|
"callee": {
|
||||||
"type": "Identifier",
|
"type": "Identifier",
|
||||||
"start": 159,
|
"start": 157,
|
||||||
"end": 164,
|
"end": 162,
|
||||||
"name": "close",
|
"name": "close",
|
||||||
"digest": null
|
"digest": null
|
||||||
},
|
},
|
||||||
@ -258,8 +258,8 @@ expression: actual
|
|||||||
{
|
{
|
||||||
"type": "PipeSubstitution",
|
"type": "PipeSubstitution",
|
||||||
"type": "PipeSubstitution",
|
"type": "PipeSubstitution",
|
||||||
"start": 165,
|
"start": 163,
|
||||||
"end": 166,
|
"end": 164,
|
||||||
"digest": null
|
"digest": null
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -389,7 +389,7 @@ where
|
|||||||
return Err(KclError::Semantic(KclErrorDetails {
|
return Err(KclError::Semantic(KclErrorDetails {
|
||||||
message: format!(
|
message: format!(
|
||||||
"Argument at index {i} was supposed to be type {} but wasn't",
|
"Argument at index {i} was supposed to be type {} but wasn't",
|
||||||
type_name::<T>()
|
type_name::<T>(),
|
||||||
),
|
),
|
||||||
source_ranges: vec![args.source_range],
|
source_ranges: vec![args.source_range],
|
||||||
}));
|
}));
|
||||||
|
@ -45,19 +45,19 @@ pub async fn chamfer(args: Args) -> Result<MemoryItem, KclError> {
|
|||||||
///
|
///
|
||||||
/// const mountingPlateSketch = startSketchOn("XY")
|
/// const mountingPlateSketch = startSketchOn("XY")
|
||||||
/// |> startProfileAt([-width/2, -length/2], %)
|
/// |> startProfileAt([-width/2, -length/2], %)
|
||||||
/// |> lineTo([width/2, -length/2], %, 'edge1')
|
/// |> lineTo([width/2, -length/2], %, $edge1)
|
||||||
/// |> lineTo([width/2, length/2], %, 'edge2')
|
/// |> lineTo([width/2, length/2], %, $edge2)
|
||||||
/// |> lineTo([-width/2, length/2], %, 'edge3')
|
/// |> lineTo([-width/2, length/2], %, $edge3)
|
||||||
/// |> close(%, 'edge4')
|
/// |> close(%, $edge4)
|
||||||
///
|
///
|
||||||
/// const mountingPlate = extrude(thickness, mountingPlateSketch)
|
/// const mountingPlate = extrude(thickness, mountingPlateSketch)
|
||||||
/// |> chamfer({
|
/// |> chamfer({
|
||||||
/// length: chamferLength,
|
/// length: chamferLength,
|
||||||
/// tags: [
|
/// tags: [
|
||||||
/// getNextAdjacentEdge('edge1', %),
|
/// getNextAdjacentEdge(edge1, %),
|
||||||
/// getNextAdjacentEdge('edge2', %),
|
/// getNextAdjacentEdge(edge2, %),
|
||||||
/// getNextAdjacentEdge('edge3', %),
|
/// getNextAdjacentEdge(edge3, %),
|
||||||
/// getNextAdjacentEdge('edge4', %)
|
/// getNextAdjacentEdge(edge4, %)
|
||||||
/// ],
|
/// ],
|
||||||
/// }, %)
|
/// }, %)
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -34,7 +34,7 @@ pub enum EdgeReference {
|
|||||||
/// A uuid of an edge.
|
/// A uuid of an edge.
|
||||||
Uuid(uuid::Uuid),
|
Uuid(uuid::Uuid),
|
||||||
/// A tag of an edge.
|
/// A tag of an edge.
|
||||||
Tag(#[serde(deserialize_with = "crate::std::string_or_struct::string_or_struct")] TagIdentifier),
|
Tag(TagIdentifier),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create fillets on tagged paths.
|
/// Create fillets on tagged paths.
|
||||||
@ -55,19 +55,19 @@ pub async fn fillet(args: Args) -> Result<MemoryItem, KclError> {
|
|||||||
///
|
///
|
||||||
/// const mountingPlateSketch = startSketchOn("XY")
|
/// const mountingPlateSketch = startSketchOn("XY")
|
||||||
/// |> startProfileAt([-width/2, -length/2], %)
|
/// |> startProfileAt([-width/2, -length/2], %)
|
||||||
/// |> lineTo([width/2, -length/2], %, 'edge1')
|
/// |> lineTo([width/2, -length/2], %, $edge1)
|
||||||
/// |> lineTo([width/2, length/2], %, 'edge2')
|
/// |> lineTo([width/2, length/2], %, $edge2)
|
||||||
/// |> lineTo([-width/2, length/2], %, 'edge3')
|
/// |> lineTo([-width/2, length/2], %, $edge3)
|
||||||
/// |> close(%, 'edge4')
|
/// |> close(%, $edge4)
|
||||||
///
|
///
|
||||||
/// const mountingPlate = extrude(thickness, mountingPlateSketch)
|
/// const mountingPlate = extrude(thickness, mountingPlateSketch)
|
||||||
/// |> fillet({
|
/// |> fillet({
|
||||||
/// radius: filletRadius,
|
/// radius: filletRadius,
|
||||||
/// tags: [
|
/// tags: [
|
||||||
/// getNextAdjacentEdge('edge1', %),
|
/// getNextAdjacentEdge(edge1, %),
|
||||||
/// getNextAdjacentEdge('edge2', %),
|
/// getNextAdjacentEdge(edge2, %),
|
||||||
/// getNextAdjacentEdge('edge3', %),
|
/// getNextAdjacentEdge(edge3, %),
|
||||||
/// getNextAdjacentEdge('edge4', %)
|
/// getNextAdjacentEdge(edge4, %)
|
||||||
/// ],
|
/// ],
|
||||||
/// }, %)
|
/// }, %)
|
||||||
/// ```
|
/// ```
|
||||||
@ -170,13 +170,13 @@ pub async fn get_opposite_edge(args: Args) -> Result<MemoryItem, KclError> {
|
|||||||
/// |> angledLine({
|
/// |> angledLine({
|
||||||
/// angle: 240,
|
/// angle: 240,
|
||||||
/// length: 10,
|
/// length: 10,
|
||||||
/// }, %, 'referenceEdge')
|
/// }, %, $referenceEdge)
|
||||||
/// |> close(%)
|
/// |> close(%)
|
||||||
///
|
///
|
||||||
/// const example = extrude(5, exampleSketch)
|
/// const example = extrude(5, exampleSketch)
|
||||||
/// |> fillet({
|
/// |> fillet({
|
||||||
/// radius: 3,
|
/// radius: 3,
|
||||||
/// tags: [getOppositeEdge("referenceEdge", %)],
|
/// tags: [getOppositeEdge(referenceEdge, %)],
|
||||||
/// }, %)
|
/// }, %)
|
||||||
/// ```
|
/// ```
|
||||||
#[stdlib {
|
#[stdlib {
|
||||||
@ -260,13 +260,13 @@ pub async fn get_next_adjacent_edge(args: Args) -> Result<MemoryItem, KclError>
|
|||||||
/// |> angledLine({
|
/// |> angledLine({
|
||||||
/// angle: 240,
|
/// angle: 240,
|
||||||
/// length: 10,
|
/// length: 10,
|
||||||
/// }, %, 'referenceEdge')
|
/// }, %, $referenceEdge)
|
||||||
/// |> close(%)
|
/// |> close(%)
|
||||||
///
|
///
|
||||||
/// const example = extrude(5, exampleSketch)
|
/// const example = extrude(5, exampleSketch)
|
||||||
/// |> fillet({
|
/// |> fillet({
|
||||||
/// radius: 3,
|
/// radius: 3,
|
||||||
/// tags: [getNextAdjacentEdge("referenceEdge", %)],
|
/// tags: [getNextAdjacentEdge(referenceEdge, %)],
|
||||||
/// }, %)
|
/// }, %)
|
||||||
/// ```
|
/// ```
|
||||||
#[stdlib {
|
#[stdlib {
|
||||||
@ -355,13 +355,13 @@ pub async fn get_previous_adjacent_edge(args: Args) -> Result<MemoryItem, KclErr
|
|||||||
/// |> angledLine({
|
/// |> angledLine({
|
||||||
/// angle: 240,
|
/// angle: 240,
|
||||||
/// length: 10,
|
/// length: 10,
|
||||||
/// }, %, 'referenceEdge')
|
/// }, %, $referenceEdge)
|
||||||
/// |> close(%)
|
/// |> close(%)
|
||||||
///
|
///
|
||||||
/// const example = extrude(5, exampleSketch)
|
/// const example = extrude(5, exampleSketch)
|
||||||
/// |> fillet({
|
/// |> fillet({
|
||||||
/// radius: 3,
|
/// radius: 3,
|
||||||
/// tags: [getPreviousAdjacentEdge("referenceEdge", %)],
|
/// tags: [getPreviousAdjacentEdge(referenceEdge, %)],
|
||||||
/// }, %)
|
/// }, %)
|
||||||
/// ```
|
/// ```
|
||||||
#[stdlib {
|
#[stdlib {
|
||||||
|
@ -16,7 +16,6 @@ pub mod segment;
|
|||||||
pub mod shapes;
|
pub mod shapes;
|
||||||
pub mod shell;
|
pub mod shell;
|
||||||
pub mod sketch;
|
pub mod sketch;
|
||||||
pub mod string_or_struct;
|
|
||||||
pub mod types;
|
pub mod types;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ pub async fn revolve(args: Args) -> Result<MemoryItem, KclError> {
|
|||||||
/// |> startProfileAt([0, 0], %)
|
/// |> startProfileAt([0, 0], %)
|
||||||
/// |> line([0, 20], %)
|
/// |> line([0, 20], %)
|
||||||
/// |> line([20, 0], %)
|
/// |> line([20, 0], %)
|
||||||
/// |> line([0, -20], %, 'revolveAxis')
|
/// |> line([0, -20], %, $revolveAxis)
|
||||||
/// |> close(%)
|
/// |> close(%)
|
||||||
/// |> extrude(20, %)
|
/// |> extrude(20, %)
|
||||||
///
|
///
|
||||||
@ -197,7 +197,7 @@ pub async fn revolve(args: Args) -> Result<MemoryItem, KclError> {
|
|||||||
/// |> circle([10,10], 4, %)
|
/// |> circle([10,10], 4, %)
|
||||||
/// |> revolve({
|
/// |> revolve({
|
||||||
/// angle: 90,
|
/// angle: 90,
|
||||||
/// axis: getOppositeEdge('revolveAxis', box)
|
/// axis: getOppositeEdge(revolveAxis, box)
|
||||||
/// }, %)
|
/// }, %)
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
@ -309,20 +309,20 @@ pub async fn get_edge(args: Args) -> Result<MemoryItem, KclError> {
|
|||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// const box = startSketchOn('XZ')
|
/// const box = startSketchOn('XZ')
|
||||||
/// |> startProfileAt([0, 0], %)
|
/// |> startProfileAt([0, 0], %)
|
||||||
/// |> line([0, 10], %, 'revolveAxis')
|
/// |> line([0, 10], %, $revolveAxis)
|
||||||
/// |> line([10, 0], %)
|
/// |> line([10, 0], %)
|
||||||
/// |> line([0, -10], %)
|
/// |> line([0, -10], %)
|
||||||
/// |> close(%)
|
/// |> close(%)
|
||||||
/// |> extrude(10, %)
|
/// |> extrude(10, %)
|
||||||
///
|
///
|
||||||
/// const revolution = startSketchOn(box, "revolveAxis")
|
/// const revolution = startSketchOn(box, revolveAxis)
|
||||||
/// |> startProfileAt([5, 10], %)
|
/// |> startProfileAt([5, 10], %)
|
||||||
/// |> line([0, 10], %)
|
/// |> line([0, 10], %)
|
||||||
/// |> line([2, 0], %)
|
/// |> line([2, 0], %)
|
||||||
/// |> line([0, -10], %)
|
/// |> line([0, -10], %)
|
||||||
/// |> close(%)
|
/// |> close(%)
|
||||||
/// |> revolve({
|
/// |> revolve({
|
||||||
/// axis: getEdge('revolveAxis', box),
|
/// axis: getEdge(revolveAxis, box),
|
||||||
/// angle: 90
|
/// angle: 90
|
||||||
/// }, %)
|
/// }, %)
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -23,9 +23,9 @@ pub async fn segment_end_x(args: Args) -> Result<MemoryItem, KclError> {
|
|||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// const exampleSketch = startSketchOn('XZ')
|
/// const exampleSketch = startSketchOn('XZ')
|
||||||
/// |> startProfileAt([0, 0], %)
|
/// |> startProfileAt([0, 0], %)
|
||||||
/// |> line([20, 0], %, "thing")
|
/// |> line([20, 0], %, $thing)
|
||||||
/// |> line([0, 5], %)
|
/// |> line([0, 5], %)
|
||||||
/// |> line([segEndX("thing", %), 0], %)
|
/// |> line([segEndX(thing, %), 0], %)
|
||||||
/// |> line([-20, 10], %)
|
/// |> line([-20, 10], %)
|
||||||
/// |> close(%)
|
/// |> close(%)
|
||||||
///
|
///
|
||||||
@ -66,9 +66,9 @@ pub async fn segment_end_y(args: Args) -> Result<MemoryItem, KclError> {
|
|||||||
/// const exampleSketch = startSketchOn('XZ')
|
/// const exampleSketch = startSketchOn('XZ')
|
||||||
/// |> startProfileAt([0, 0], %)
|
/// |> startProfileAt([0, 0], %)
|
||||||
/// |> line([20, 0], %)
|
/// |> line([20, 0], %)
|
||||||
/// |> line([0, 3], %, "thing")
|
/// |> line([0, 3], %, $thing)
|
||||||
/// |> line([-10, 0], %)
|
/// |> line([-10, 0], %)
|
||||||
/// |> line([0, segEndY("thing", %)], %)
|
/// |> line([0, segEndY(thing, %)], %)
|
||||||
/// |> line([-10, 0], %)
|
/// |> line([-10, 0], %)
|
||||||
/// |> close(%)
|
/// |> close(%)
|
||||||
///
|
///
|
||||||
@ -194,14 +194,14 @@ pub async fn segment_length(args: Args) -> Result<MemoryItem, KclError> {
|
|||||||
/// |> angledLine({
|
/// |> angledLine({
|
||||||
/// angle: 60,
|
/// angle: 60,
|
||||||
/// length: 10,
|
/// length: 10,
|
||||||
/// }, %, "thing")
|
/// }, %, $thing)
|
||||||
/// |> tangentialArc({
|
/// |> tangentialArc({
|
||||||
/// offset: -120,
|
/// offset: -120,
|
||||||
/// radius: 5,
|
/// radius: 5,
|
||||||
/// }, %)
|
/// }, %)
|
||||||
/// |> angledLine({
|
/// |> angledLine({
|
||||||
/// angle: -60,
|
/// angle: -60,
|
||||||
/// length: segLen("thing", %),
|
/// length: segLen(thing, %),
|
||||||
/// }, %)
|
/// }, %)
|
||||||
/// |> close(%)
|
/// |> close(%)
|
||||||
///
|
///
|
||||||
@ -245,11 +245,11 @@ pub async fn segment_angle(args: Args) -> Result<MemoryItem, KclError> {
|
|||||||
/// const exampleSketch = startSketchOn('XZ')
|
/// const exampleSketch = startSketchOn('XZ')
|
||||||
/// |> startProfileAt([0, 0], %)
|
/// |> startProfileAt([0, 0], %)
|
||||||
/// |> line([10, 0], %)
|
/// |> line([10, 0], %)
|
||||||
/// |> line([5, 10], %, 'seg01')
|
/// |> line([5, 10], %, $seg01)
|
||||||
/// |> line([-10, 0], %)
|
/// |> line([-10, 0], %)
|
||||||
/// |> angledLine([segAng('seg01', %), 10], %)
|
/// |> angledLine([segAng(seg01, %), 10], %)
|
||||||
/// |> line([-10, 0], %)
|
/// |> line([-10, 0], %)
|
||||||
/// |> angledLine([segAng('seg01', %), -15], %)
|
/// |> angledLine([segAng(seg01, %), -15], %)
|
||||||
/// |> close(%)
|
/// |> close(%)
|
||||||
///
|
///
|
||||||
/// const example = extrude(4, exampleSketch)
|
/// const example = extrude(4, exampleSketch)
|
||||||
@ -290,9 +290,9 @@ pub async fn angle_to_match_length_x(args: Args) -> Result<MemoryItem, KclError>
|
|||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// const sketch001 = startSketchOn('XZ')
|
/// const sketch001 = startSketchOn('XZ')
|
||||||
/// |> startProfileAt([0, 0], %)
|
/// |> startProfileAt([0, 0], %)
|
||||||
/// |> line([2, 5], %, 'seg01')
|
/// |> line([2, 5], %, $seg01)
|
||||||
/// |> angledLineToX([
|
/// |> angledLineToX([
|
||||||
/// -angleToMatchLengthX('seg01', 7, %),
|
/// -angleToMatchLengthX(seg01, 7, %),
|
||||||
/// 10
|
/// 10
|
||||||
/// ], %)
|
/// ], %)
|
||||||
/// |> close(%)
|
/// |> close(%)
|
||||||
@ -358,9 +358,9 @@ pub async fn angle_to_match_length_y(args: Args) -> Result<MemoryItem, KclError>
|
|||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// const sketch001 = startSketchOn('XZ')
|
/// const sketch001 = startSketchOn('XZ')
|
||||||
/// |> startProfileAt([0, 0], %)
|
/// |> startProfileAt([0, 0], %)
|
||||||
/// |> line([1, 2], %, 'seg01')
|
/// |> line([1, 2], %, $seg01)
|
||||||
/// |> angledLine({
|
/// |> angledLine({
|
||||||
/// angle: angleToMatchLengthY('seg01', 15, %),
|
/// angle: angleToMatchLengthY(seg01, 15, %),
|
||||||
/// length: 5,
|
/// length: 5,
|
||||||
/// }, %)
|
/// }, %)
|
||||||
/// |> yLineTo(0, %)
|
/// |> yLineTo(0, %)
|
||||||
|
@ -34,7 +34,7 @@ pub enum FaceTag {
|
|||||||
StartOrEnd(StartOrEnd),
|
StartOrEnd(StartOrEnd),
|
||||||
/// A tag for the face.
|
/// A tag for the face.
|
||||||
#[display("{0}")]
|
#[display("{0}")]
|
||||||
Tag(#[serde(deserialize_with = "crate::std::string_or_struct::string_or_struct")] TagIdentifier),
|
Tag(TagIdentifier),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FaceTag {
|
impl FaceTag {
|
||||||
@ -516,10 +516,10 @@ pub async fn angled_line_of_x_length(args: Args) -> Result<MemoryItem, KclError>
|
|||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// const sketch001 = startSketchOn('XZ')
|
/// const sketch001 = startSketchOn('XZ')
|
||||||
/// |> startProfileAt([0, 0], %)
|
/// |> startProfileAt([0, 0], %)
|
||||||
/// |> angledLineOfXLength({ angle: 45, length: 10 }, %, "edge1")
|
/// |> angledLineOfXLength({ angle: 45, length: 10 }, %, $edge1)
|
||||||
/// |> angledLineOfXLength({ angle: -15, length: 20 }, %, "edge2")
|
/// |> angledLineOfXLength({ angle: -15, length: 20 }, %, $edge2)
|
||||||
/// |> line([0, -5], %)
|
/// |> line([0, -5], %)
|
||||||
/// |> close(%, "edge3")
|
/// |> close(%, $edge3)
|
||||||
///
|
///
|
||||||
/// const extrusion = extrude(10, sketch001)
|
/// const extrusion = extrude(10, sketch001)
|
||||||
/// ```
|
/// ```
|
||||||
@ -691,7 +691,6 @@ pub struct AngledLineThatIntersectsData {
|
|||||||
/// The angle of the line.
|
/// The angle of the line.
|
||||||
pub angle: f64,
|
pub angle: f64,
|
||||||
/// The tag of the line to intersect with.
|
/// The tag of the line to intersect with.
|
||||||
#[serde(deserialize_with = "crate::std::string_or_struct::string_or_struct")]
|
|
||||||
pub intersect_tag: TagIdentifier,
|
pub intersect_tag: TagIdentifier,
|
||||||
/// The offset from the intersecting line.
|
/// The offset from the intersecting line.
|
||||||
pub offset: Option<f64>,
|
pub offset: Option<f64>,
|
||||||
@ -711,11 +710,11 @@ pub async fn angled_line_that_intersects(args: Args) -> Result<MemoryItem, KclEr
|
|||||||
/// const exampleSketch = startSketchOn('XZ')
|
/// const exampleSketch = startSketchOn('XZ')
|
||||||
/// |> startProfileAt([0, 0], %)
|
/// |> startProfileAt([0, 0], %)
|
||||||
/// |> lineTo([5, 10], %)
|
/// |> lineTo([5, 10], %)
|
||||||
/// |> lineTo([-10, 10], %, "lineToIntersect")
|
/// |> lineTo([-10, 10], %, $lineToIntersect)
|
||||||
/// |> lineTo([0, 20], %)
|
/// |> lineTo([0, 20], %)
|
||||||
/// |> angledLineThatIntersects({
|
/// |> angledLineThatIntersects({
|
||||||
/// angle: 80,
|
/// angle: 80,
|
||||||
/// intersectTag: 'lineToIntersect',
|
/// intersectTag: lineToIntersect,
|
||||||
/// offset: 10
|
/// offset: 10
|
||||||
/// }, %)
|
/// }, %)
|
||||||
/// |> close(%)
|
/// |> close(%)
|
||||||
@ -973,22 +972,22 @@ pub async fn start_sketch_on(args: Args) -> Result<MemoryItem, KclError> {
|
|||||||
/// const exampleSketch = startSketchOn("XY")
|
/// const exampleSketch = startSketchOn("XY")
|
||||||
/// |> startProfileAt([0, 0], %)
|
/// |> startProfileAt([0, 0], %)
|
||||||
/// |> line([10, 0], %)
|
/// |> line([10, 0], %)
|
||||||
/// |> line([0, 10], %, 'sketchingFace')
|
/// |> line([0, 10], %, $sketchingFace)
|
||||||
/// |> line([-10, 0], %)
|
/// |> line([-10, 0], %)
|
||||||
/// |> close(%)
|
/// |> close(%)
|
||||||
///
|
///
|
||||||
/// const example = extrude(10, exampleSketch)
|
/// const example = extrude(10, exampleSketch)
|
||||||
///
|
///
|
||||||
/// const exampleSketch002 = startSketchOn(example, 'sketchingFace')
|
/// const exampleSketch002 = startSketchOn(example, sketchingFace)
|
||||||
/// |> startProfileAt([1, 1], %)
|
/// |> startProfileAt([1, 1], %)
|
||||||
/// |> line([8, 0], %)
|
/// |> line([8, 0], %)
|
||||||
/// |> line([0, 8], %)
|
/// |> line([0, 8], %)
|
||||||
/// |> line([-8, 0], %)
|
/// |> line([-8, 0], %)
|
||||||
/// |> close(%, 'sketchingFace002')
|
/// |> close(%, $sketchingFace002)
|
||||||
///
|
///
|
||||||
/// const example002 = extrude(10, exampleSketch002)
|
/// const example002 = extrude(10, exampleSketch002)
|
||||||
///
|
///
|
||||||
/// const exampleSketch003 = startSketchOn(example002, 'sketchingFace002')
|
/// const exampleSketch003 = startSketchOn(example002, sketchingFace002)
|
||||||
/// |> startProfileAt([-8, 12], %)
|
/// |> startProfileAt([-8, 12], %)
|
||||||
/// |> line([0, 6], %)
|
/// |> line([0, 6], %)
|
||||||
/// |> line([6, 0], %)
|
/// |> line([6, 0], %)
|
||||||
@ -1301,8 +1300,8 @@ pub async fn profile_start(args: Args) -> Result<MemoryItem, KclError> {
|
|||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// const sketch001 = startSketchOn('XY')
|
/// const sketch001 = startSketchOn('XY')
|
||||||
/// |> startProfileAt([5, 2], %)
|
/// |> startProfileAt([5, 2], %)
|
||||||
/// |> angledLine({ angle: 120, length: 50 }, %, 'seg01')
|
/// |> angledLine({ angle: 120, length: 50 }, %, $seg01)
|
||||||
/// |> angledLine({ angle: segAng('seg01', %) + 120, length: 50 }, %)
|
/// |> angledLine({ angle: segAng(seg01, %) + 120, length: 50 }, %)
|
||||||
/// |> lineTo(profileStart(%), %)
|
/// |> lineTo(profileStart(%), %)
|
||||||
/// |> close(%)
|
/// |> close(%)
|
||||||
/// |> extrude(20, %)
|
/// |> extrude(20, %)
|
||||||
@ -1940,7 +1939,11 @@ mod tests {
|
|||||||
crate::std::sketch::FaceTag::StartOrEnd(crate::std::sketch::StartOrEnd::End)
|
crate::std::sketch::FaceTag::StartOrEnd(crate::std::sketch::StartOrEnd::End)
|
||||||
);
|
);
|
||||||
|
|
||||||
str_json = "\"thing\"".to_string();
|
str_json = serde_json::to_string(&TagIdentifier {
|
||||||
|
value: "thing".to_string(),
|
||||||
|
meta: Default::default(),
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
let data: crate::std::sketch::FaceTag = serde_json::from_str(&str_json).unwrap();
|
let data: crate::std::sketch::FaceTag = serde_json::from_str(&str_json).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
data,
|
data,
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
use std::{fmt, marker::PhantomData, str::FromStr};
|
|
||||||
|
|
||||||
use serde::{
|
|
||||||
de::{self, MapAccess, Visitor},
|
|
||||||
Deserialize, Deserializer,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::errors::KclError;
|
|
||||||
|
|
||||||
pub(crate) fn string_or_struct<'de, T, D>(deserializer: D) -> Result<T, D::Error>
|
|
||||||
where
|
|
||||||
T: Deserialize<'de> + FromStr<Err = KclError>,
|
|
||||||
D: Deserializer<'de>,
|
|
||||||
{
|
|
||||||
// This is a Visitor that forwards string types to T's `FromStr` impl and
|
|
||||||
// forwards map types to T's `Deserialize` impl. The `PhantomData` is to
|
|
||||||
// keep the compiler from complaining about T being an unused generic type
|
|
||||||
// parameter. We need T in order to know the Value type for the Visitor
|
|
||||||
// impl.
|
|
||||||
struct StringOrStruct<T>(PhantomData<fn() -> T>);
|
|
||||||
|
|
||||||
impl<'de, T> Visitor<'de> for StringOrStruct<T>
|
|
||||||
where
|
|
||||||
T: Deserialize<'de> + FromStr<Err = KclError>,
|
|
||||||
{
|
|
||||||
type Value = T;
|
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
formatter.write_str("string or map")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_str<E>(self, value: &str) -> Result<T, E>
|
|
||||||
where
|
|
||||||
E: de::Error,
|
|
||||||
{
|
|
||||||
Ok(FromStr::from_str(value).unwrap())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_map<M>(self, map: M) -> Result<T, M::Error>
|
|
||||||
where
|
|
||||||
M: MapAccess<'de>,
|
|
||||||
{
|
|
||||||
// `MapAccessDeserializer` is a wrapper that turns a `MapAccess`
|
|
||||||
// into a `Deserializer`, allowing it to be used as the input to T's
|
|
||||||
// `Deserialize` implementation. T then deserializes itself using
|
|
||||||
// the entries from the map visitor.
|
|
||||||
Deserialize::deserialize(de::value::MapAccessDeserializer::new(map))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
deserializer.deserialize_any(StringOrStruct(PhantomData))
|
|
||||||
}
|
|
@ -14,11 +14,11 @@ fn transform = (replicaId) => {
|
|||||||
// Each layer is just a pretty thin cylinder with a fillet.
|
// Each layer is just a pretty thin cylinder with a fillet.
|
||||||
fn layer = () => {
|
fn layer = () => {
|
||||||
return startSketchOn("XY") // or some other plane idk
|
return startSketchOn("XY") // or some other plane idk
|
||||||
|> circle([0, 0], 1, %, 'tag1')
|
|> circle([0, 0], 1, %, $tag1)
|
||||||
|> extrude(h, %)
|
|> extrude(h, %)
|
||||||
// |> fillet({
|
// |> fillet({
|
||||||
// radius: h / 2.01,
|
// radius: h / 2.01,
|
||||||
// tags: ["tag1", getOppositeEdge("tag1", %)]
|
// tags: ["tag1", getOppositeEdge(tag1, %)]
|
||||||
// }, %)
|
// }, %)
|
||||||
}
|
}
|
||||||
// The vase is 100 layers tall.
|
// The vase is 100 layers tall.
|
||||||
|
@ -218,19 +218,19 @@ const part002 = startSketchOn(part001, "END")
|
|||||||
async fn serial_test_fillet_duplicate_tags() {
|
async fn serial_test_fillet_duplicate_tags() {
|
||||||
let code = r#"const part001 = startSketchOn('XY')
|
let code = r#"const part001 = startSketchOn('XY')
|
||||||
|> startProfileAt([0,0], %)
|
|> startProfileAt([0,0], %)
|
||||||
|> line([0, 10], %, "thing")
|
|> line([0, 10], %, $thing)
|
||||||
|> line([10, 0], %)
|
|> line([10, 0], %)
|
||||||
|> line([0, -10], %, "thing2")
|
|> line([0, -10], %, $thing2)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(10, %)
|
|> extrude(10, %)
|
||||||
|> fillet({radius: 0.5, tags: ["thing", "thing"]}, %)
|
|> fillet({radius: 0.5, tags: [thing, thing]}, %)
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
let result = execute_and_snapshot(code, UnitLength::Mm).await;
|
let result = execute_and_snapshot(code, UnitLength::Mm).await;
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.err().unwrap().to_string(),
|
result.err().unwrap().to_string(),
|
||||||
r#"type: KclErrorDetails { source_ranges: [SourceRange([205, 255])], message: "Duplicate tags are not allowed." }"#,
|
r#"type: KclErrorDetails { source_ranges: [SourceRange([203, 249])], message: "Duplicate tags are not allowed." }"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,12 +238,12 @@ async fn serial_test_fillet_duplicate_tags() {
|
|||||||
async fn serial_test_basic_fillet_cube_start() {
|
async fn serial_test_basic_fillet_cube_start() {
|
||||||
let code = r#"const part001 = startSketchOn('XY')
|
let code = r#"const part001 = startSketchOn('XY')
|
||||||
|> startProfileAt([0,0], %)
|
|> startProfileAt([0,0], %)
|
||||||
|> line([0, 10], %, "thing")
|
|> line([0, 10], %, $thing)
|
||||||
|> line([10, 0], %)
|
|> line([10, 0], %)
|
||||||
|> line([0, -10], %, "thing2")
|
|> line([0, -10], %, $thing2)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(10, %)
|
|> extrude(10, %)
|
||||||
|> fillet({radius: 2, tags: ["thing", "thing2"]}, %)
|
|> fillet({radius: 2, tags: [thing, thing2]}, %)
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||||
@ -254,12 +254,12 @@ async fn serial_test_basic_fillet_cube_start() {
|
|||||||
async fn serial_test_basic_fillet_cube_end() {
|
async fn serial_test_basic_fillet_cube_end() {
|
||||||
let code = r#"const part001 = startSketchOn('XY')
|
let code = r#"const part001 = startSketchOn('XY')
|
||||||
|> startProfileAt([0,0], %)
|
|> startProfileAt([0,0], %)
|
||||||
|> line([0, 10], %, "thing")
|
|> line([0, 10], %, $thing)
|
||||||
|> line([10, 0], %)
|
|> line([10, 0], %)
|
||||||
|> line([0, -10], %, "thing2")
|
|> line([0, -10], %, $thing2)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(10, %)
|
|> extrude(10, %)
|
||||||
|> fillet({radius: 2, tags: ["thing", getOppositeEdge("thing", %)]}, %)
|
|> fillet({radius: 2, tags: [thing, getOppositeEdge(thing, %)]}, %)
|
||||||
|
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
@ -271,12 +271,12 @@ async fn serial_test_basic_fillet_cube_end() {
|
|||||||
async fn serial_test_basic_fillet_cube_close_opposite() {
|
async fn serial_test_basic_fillet_cube_close_opposite() {
|
||||||
let code = r#"const part001 = startSketchOn('XY')
|
let code = r#"const part001 = startSketchOn('XY')
|
||||||
|> startProfileAt([0,0], %)
|
|> startProfileAt([0,0], %)
|
||||||
|> line([0, 10], %, "thing")
|
|> line([0, 10], %, $thing)
|
||||||
|> line([10, 0], %)
|
|> line([10, 0], %)
|
||||||
|> line([0, -10], %, "thing2")
|
|> line([0, -10], %, $thing2)
|
||||||
|> close(%, "thing3")
|
|> close(%, $thing3)
|
||||||
|> extrude(10, %)
|
|> extrude(10, %)
|
||||||
|> fillet({radius: 2, tags: ["thing3", getOppositeEdge("thing3", %)]}, %)
|
|> fillet({radius: 2, tags: [thing3, getOppositeEdge(thing3, %)]}, %)
|
||||||
|
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
@ -292,12 +292,12 @@ async fn serial_test_basic_fillet_cube_close_opposite() {
|
|||||||
async fn serial_test_basic_fillet_cube_next_adjacent() {
|
async fn serial_test_basic_fillet_cube_next_adjacent() {
|
||||||
let code = r#"const part001 = startSketchOn('XY')
|
let code = r#"const part001 = startSketchOn('XY')
|
||||||
|> startProfileAt([0,0], %)
|
|> startProfileAt([0,0], %)
|
||||||
|> line([0, 10], %, "thing")
|
|> line([0, 10], %, $thing)
|
||||||
|> line([10, 0], %, "thing1")
|
|> line([10, 0], %, $thing1)
|
||||||
|> line([0, -10], %, "thing2")
|
|> line([0, -10], %, $thing2)
|
||||||
|> close(%, "thing3")
|
|> close(%, $thing3)
|
||||||
|> extrude(10, %)
|
|> extrude(10, %)
|
||||||
|> fillet({radius: 2, tags: [getNextAdjacentEdge("thing3", %)]}, %)
|
|> fillet({radius: 2, tags: [getNextAdjacentEdge(thing3, %)]}, %)
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||||
@ -312,12 +312,12 @@ async fn serial_test_basic_fillet_cube_next_adjacent() {
|
|||||||
async fn serial_test_basic_fillet_cube_previous_adjacent() {
|
async fn serial_test_basic_fillet_cube_previous_adjacent() {
|
||||||
let code = r#"const part001 = startSketchOn('XY')
|
let code = r#"const part001 = startSketchOn('XY')
|
||||||
|> startProfileAt([0,0], %)
|
|> startProfileAt([0,0], %)
|
||||||
|> line([0, 10], %, "thing")
|
|> line([0, 10], %, $thing)
|
||||||
|> line([10, 0], %, "thing1")
|
|> line([10, 0], %, $thing1)
|
||||||
|> line([0, -10], %, "thing2")
|
|> line([0, -10], %, $thing2)
|
||||||
|> close(%, "thing3")
|
|> close(%, $thing3)
|
||||||
|> extrude(10, %)
|
|> extrude(10, %)
|
||||||
|> fillet({radius: 2, tags: [getPreviousAdjacentEdge("thing3", %)]}, %)
|
|> fillet({radius: 2, tags: [getPreviousAdjacentEdge(thing3, %)]}, %)
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||||
@ -378,9 +378,9 @@ async fn serial_test_execute_with_angled_line() {
|
|||||||
let code = r#"const part001 = startSketchOn('XY')
|
let code = r#"const part001 = startSketchOn('XY')
|
||||||
|> startProfileAt([4.83, 12.56], %)
|
|> startProfileAt([4.83, 12.56], %)
|
||||||
|> line([15.1, 2.48], %)
|
|> line([15.1, 2.48], %)
|
||||||
|> line([3.15, -9.85], %, 'seg01')
|
|> line([3.15, -9.85], %, $seg01)
|
||||||
|> line([-15.17, -4.1], %)
|
|> line([-15.17, -4.1], %)
|
||||||
|> angledLine([segAng('seg01', %), 12.35], %)
|
|> angledLine([segAng(seg01, %), 12.35], %)
|
||||||
|> line([-13.02, 10.03], %)
|
|> line([-13.02, 10.03], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(4, %)
|
|> extrude(4, %)
|
||||||
@ -1228,7 +1228,7 @@ async fn serial_test_error_sketch_on_arc_face() {
|
|||||||
let code = r#"fn cube = (pos, scale) => {
|
let code = r#"fn cube = (pos, scale) => {
|
||||||
const sg = startSketchOn('XY')
|
const sg = startSketchOn('XY')
|
||||||
|> startProfileAt(pos, %)
|
|> startProfileAt(pos, %)
|
||||||
|> tangentialArc([0, scale], %, "here")
|
|> tangentialArc([0, scale], %, $here)
|
||||||
|> line([scale, 0], %)
|
|> line([scale, 0], %)
|
||||||
|> line([0, -scale], %)
|
|> line([0, -scale], %)
|
||||||
|
|
||||||
@ -1238,7 +1238,7 @@ const part001 = cube([0, 0], 20)
|
|||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(20, %)
|
|> extrude(20, %)
|
||||||
|
|
||||||
const part002 = startSketchOn(part001, "here")
|
const part002 = startSketchOn(part001, part001.sketchGroup.tags.here)
|
||||||
|> startProfileAt([0, 0], %)
|
|> startProfileAt([0, 0], %)
|
||||||
|> line([5, 0], %)
|
|> line([5, 0], %)
|
||||||
|> line([5, 5], %)
|
|> line([5, 5], %)
|
||||||
@ -1252,7 +1252,7 @@ const part002 = startSketchOn(part001, "here")
|
|||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.err().unwrap().to_string(),
|
result.err().unwrap().to_string(),
|
||||||
r#"type: KclErrorDetails { source_ranges: [SourceRange([281, 311])], message: "Tag `here` is a non-planar surface" }"#
|
r#"type: KclErrorDetails { source_ranges: [SourceRange([280, 333])], message: "Tag `here` is a non-planar surface" }"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1353,7 +1353,7 @@ const part001 = cube([0,0], 20)
|
|||||||
|> extrude(20, %)
|
|> extrude(20, %)
|
||||||
|
|
||||||
const part002 = startSketchOn(part001, "end")
|
const part002 = startSketchOn(part001, "end")
|
||||||
|> circle([0, 0], 5, %, "myCircle")
|
|> circle([0, 0], 5, %, $myCircle)
|
||||||
|> extrude(5, %)
|
|> extrude(5, %)
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
@ -1374,10 +1374,10 @@ async fn serial_test_stdlib_kcl_error_circle() {
|
|||||||
fn rectShape = (pos, w, l) => {
|
fn rectShape = (pos, w, l) => {
|
||||||
const rr = startSketchOn('XY')
|
const rr = startSketchOn('XY')
|
||||||
|> startProfileAt([pos[0] - (w / 2), pos[1] - (l / 2)], %)
|
|> startProfileAt([pos[0] - (w / 2), pos[1] - (l / 2)], %)
|
||||||
|> lineTo([pos[0] + w / 2, pos[1] - (l / 2)], %, "edge1")
|
|> lineTo([pos[0] + w / 2, pos[1] - (l / 2)], %, $edge1)
|
||||||
|> lineTo([pos[0] + w / 2, pos[1] + l / 2], %, "edge2")
|
|> lineTo([pos[0] + w / 2, pos[1] + l / 2], %, $edge2)
|
||||||
|> lineTo([pos[0] - (w / 2), pos[1] + l / 2], %, "edge3")
|
|> lineTo([pos[0] - (w / 2), pos[1] + l / 2], %, $edge3)
|
||||||
|> close(%, "edge4")
|
|> close(%, $edge4)
|
||||||
return rr
|
return rr
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1395,10 +1395,10 @@ const part = rectShape([0, 0], 20, 20)
|
|||||||
|> fillet({
|
|> fillet({
|
||||||
radius: 4,
|
radius: 4,
|
||||||
tags: [
|
tags: [
|
||||||
getNextAdjacentEdge("edge1", %),
|
getNextAdjacentEdge(edge1, %),
|
||||||
getNextAdjacentEdge("edge2", %),
|
getNextAdjacentEdge(edge2, %),
|
||||||
getNextAdjacentEdge("edge3", %),
|
getNextAdjacentEdge(edge3, %),
|
||||||
getNextAdjacentEdge("edge4", %)
|
getNextAdjacentEdge(edge4, %)
|
||||||
]
|
]
|
||||||
}, %)
|
}, %)
|
||||||
"#;
|
"#;
|
||||||
@ -1407,7 +1407,7 @@ const part = rectShape([0, 0], 20, 20)
|
|||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.err().unwrap().to_string(),
|
result.err().unwrap().to_string(),
|
||||||
r#"semantic: KclErrorDetails { source_ranges: [SourceRange([891, 940])], message: "Argument at index 0 was supposed to be type [f64; 2] but wasn't" }"#,
|
r#"semantic: KclErrorDetails { source_ranges: [SourceRange([887, 936])], message: "Argument at index 0 was supposed to be type [f64; 2] but wasn't" }"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1415,9 +1415,9 @@ const part = rectShape([0, 0], 20, 20)
|
|||||||
async fn serial_test_big_number_angle_to_match_length_x() {
|
async fn serial_test_big_number_angle_to_match_length_x() {
|
||||||
let code = r#"const part001 = startSketchOn('XY')
|
let code = r#"const part001 = startSketchOn('XY')
|
||||||
|> startProfileAt([0, 0], %)
|
|> startProfileAt([0, 0], %)
|
||||||
|> line([1, 3.82], %, 'seg01')
|
|> line([1, 3.82], %, $seg01)
|
||||||
|> angledLineToX([
|
|> angledLineToX([
|
||||||
-angleToMatchLengthX('seg01', 3, %),
|
-angleToMatchLengthX(seg01, 3, %),
|
||||||
3
|
3
|
||||||
], %)
|
], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
@ -1436,9 +1436,9 @@ async fn serial_test_big_number_angle_to_match_length_x() {
|
|||||||
async fn serial_test_big_number_angle_to_match_length_y() {
|
async fn serial_test_big_number_angle_to_match_length_y() {
|
||||||
let code = r#"const part001 = startSketchOn('XY')
|
let code = r#"const part001 = startSketchOn('XY')
|
||||||
|> startProfileAt([0, 0], %)
|
|> startProfileAt([0, 0], %)
|
||||||
|> line([1, 3.82], %, 'seg01')
|
|> line([1, 3.82], %, $seg01)
|
||||||
|> angledLineToX([
|
|> angledLineToX([
|
||||||
-angleToMatchLengthY('seg01', 3, %),
|
-angleToMatchLengthY(seg01, 3, %),
|
||||||
3
|
3
|
||||||
], %)
|
], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
@ -1617,7 +1617,7 @@ async fn serial_test_revolve_on_edge() {
|
|||||||
|> startProfileAt([0, 0], %)
|
|> startProfileAt([0, 0], %)
|
||||||
|> line([0, 10], %)
|
|> line([0, 10], %)
|
||||||
|> line([10, 0], %)
|
|> line([10, 0], %)
|
||||||
|> line([0, -10], %, 'revolveAxis')
|
|> line([0, -10], %, $revolveAxis)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(10, %)
|
|> extrude(10, %)
|
||||||
|
|
||||||
@ -1627,7 +1627,7 @@ const sketch001 = startSketchOn(box, "end")
|
|||||||
|> line([2, 0], %)
|
|> line([2, 0], %)
|
||||||
|> line([0, 10], %)
|
|> line([0, 10], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> revolve({ axis: getOppositeEdge('revolveAxis', box), angle: 90 }, %)
|
|> revolve({ axis: getOppositeEdge(revolveAxis, box), angle: 90 }, %)
|
||||||
|
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
@ -1641,17 +1641,17 @@ async fn serial_test_revolve_on_edge_get_edge() {
|
|||||||
|> startProfileAt([0, 0], %)
|
|> startProfileAt([0, 0], %)
|
||||||
|> line([0, 10], %)
|
|> line([0, 10], %)
|
||||||
|> line([10, 0], %)
|
|> line([10, 0], %)
|
||||||
|> line([0, -10], %, 'revolveAxis')
|
|> line([0, -10], %, $revolveAxis)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(10, %)
|
|> extrude(10, %)
|
||||||
|
|
||||||
const sketch001 = startSketchOn(box, "revolveAxis")
|
const sketch001 = startSketchOn(box, revolveAxis)
|
||||||
|> startProfileAt([5, 10], %)
|
|> startProfileAt([5, 10], %)
|
||||||
|> line([0, -10], %)
|
|> line([0, -10], %)
|
||||||
|> line([2, 0], %)
|
|> line([2, 0], %)
|
||||||
|> line([0, 10], %)
|
|> line([0, 10], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> revolve({ axis: getEdge('revolveAxis', box), angle: 90 }, %)
|
|> revolve({ axis: getEdge(revolveAxis, box), angle: 90 }, %)
|
||||||
|
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
@ -1660,7 +1660,7 @@ const sketch001 = startSketchOn(box, "revolveAxis")
|
|||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.err().unwrap().to_string(),
|
result.err().unwrap().to_string(),
|
||||||
r#"engine: KclErrorDetails { source_ranges: [SourceRange([349, 409])], message: "Modeling command failed: [ApiError { error_code: InternalEngine, message: \"Solid3D revolve failed: sketch profile must lie entirely on one side of the revolution axis\" }]" }"#
|
r#"engine: KclErrorDetails { source_ranges: [SourceRange([346, 404])], message: "Modeling command failed: [ApiError { error_code: InternalEngine, message: \"Solid3D revolve failed: sketch profile must lie entirely on one side of the revolution axis\" }]" }"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1670,7 +1670,7 @@ async fn serial_test_revolve_on_face_circle_edge() {
|
|||||||
|> startProfileAt([0, 0], %)
|
|> startProfileAt([0, 0], %)
|
||||||
|> line([0, 20], %)
|
|> line([0, 20], %)
|
||||||
|> line([20, 0], %)
|
|> line([20, 0], %)
|
||||||
|> line([0, -20], %, 'revolveAxis')
|
|> line([0, -20], %, $revolveAxis)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(20, %)
|
|> extrude(20, %)
|
||||||
|
|
||||||
@ -1678,7 +1678,7 @@ const sketch001 = startSketchOn(box, "END")
|
|||||||
|> circle([10,10], 4, %)
|
|> circle([10,10], 4, %)
|
||||||
|> revolve({
|
|> revolve({
|
||||||
angle: 90,
|
angle: 90,
|
||||||
axis: getOppositeEdge('revolveAxis', box)
|
axis: getOppositeEdge(revolveAxis, box)
|
||||||
}, %)
|
}, %)
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
@ -1695,7 +1695,7 @@ async fn serial_test_revolve_on_face_circle() {
|
|||||||
let code = r#"const box = startSketchOn('XY')
|
let code = r#"const box = startSketchOn('XY')
|
||||||
|> startProfileAt([0, 0], %)
|
|> startProfileAt([0, 0], %)
|
||||||
|> line([0, 20], %)
|
|> line([0, 20], %)
|
||||||
|> line([20, 0], %, 'revolveAxis')
|
|> line([20, 0], %, $revolveAxis)
|
||||||
|> line([0, -20], %)
|
|> line([0, -20], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(20, %)
|
|> extrude(20, %)
|
||||||
@ -1719,7 +1719,7 @@ async fn serial_test_revolve_on_face() {
|
|||||||
|> line([0, 10], %)
|
|> line([0, 10], %)
|
||||||
|> line([10, 0], %)
|
|> line([10, 0], %)
|
||||||
|> line([0, -10], %)
|
|> line([0, -10], %)
|
||||||
|> close(%, 'revolveAxis')
|
|> close(%, $revolveAxis)
|
||||||
|> extrude(10, %)
|
|> extrude(10, %)
|
||||||
|
|
||||||
const sketch001 = startSketchOn(box, "end")
|
const sketch001 = startSketchOn(box, "end")
|
||||||
@ -1913,20 +1913,20 @@ const filletR = 0.25
|
|||||||
// Sketch the bracket and extrude with fillets
|
// Sketch the bracket and extrude with fillets
|
||||||
const bracket = startSketchOn('XY')
|
const bracket = startSketchOn('XY')
|
||||||
|> startProfileAt([0, 0], %)
|
|> startProfileAt([0, 0], %)
|
||||||
|> line([0, wallMountL], %, 'outerEdge')
|
|> line([0, wallMountL], %, $outerEdge)
|
||||||
|> line([-shelfMountL, 0], %)
|
|> line([-shelfMountL, 0], %)
|
||||||
|> line([0, -thickness], %)
|
|> line([0, -thickness], %)
|
||||||
|> line([shelfMountL - thickness, 0], %, 'innerEdge')
|
|> line([shelfMountL - thickness, 0], %, $innerEdge)
|
||||||
|> line([0, -wallMountL + thickness], %)
|
|> line([0, -wallMountL + thickness], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(width, %)
|
|> extrude(width, %)
|
||||||
|> fillet({
|
|> fillet({
|
||||||
radius: filletR,
|
radius: filletR,
|
||||||
tags: [getNextAdjacentEdge('innerEdge', %)]
|
tags: [getNextAdjacentEdge(innerEdge, %)]
|
||||||
}, %)
|
}, %)
|
||||||
|> fillet({
|
|> fillet({
|
||||||
radius: filletR + thickness,
|
radius: filletR + thickness,
|
||||||
tags: [getNextAdjacentEdge('outerEdge', %)]
|
tags: [getNextAdjacentEdge(outerEdge, %)]
|
||||||
}, %)
|
}, %)
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
@ -1934,7 +1934,7 @@ const bracket = startSketchOn('XY')
|
|||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.err().unwrap().to_string(),
|
result.err().unwrap().to_string(),
|
||||||
r#"engine: KclErrorDetails { source_ranges: [SourceRange([1336, 1442])], message: "Modeling command failed: [ApiError { error_code: BadRequest, message: \"Fillet failed\" }]" }"#
|
r#"engine: KclErrorDetails { source_ranges: [SourceRange([1332, 1436])], message: "Modeling command failed: [ApiError { error_code: BadRequest, message: \"Fillet failed\" }]" }"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1958,7 +1958,7 @@ const secondSketch = startSketchOn(part001, '')
|
|||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.err().unwrap().to_string(),
|
result.err().unwrap().to_string(),
|
||||||
r#"type: KclErrorDetails { source_ranges: [SourceRange([272, 298])], message: "Expected a non-empty tag for the face" }"#
|
r#"semantic: KclErrorDetails { source_ranges: [SourceRange([272, 298])], message: "Argument at index 1 was supposed to be type kcl_lib::std::sketch::FaceTag but wasn't" }"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2137,27 +2137,27 @@ const filletR = 0.25
|
|||||||
// Sketch the bracket and extrude with fillets
|
// Sketch the bracket and extrude with fillets
|
||||||
const bracket = startSketchOn('XY')
|
const bracket = startSketchOn('XY')
|
||||||
|> startProfileAt([0, 0], %)
|
|> startProfileAt([0, 0], %)
|
||||||
|> line([0, wallMountL], %, 'outerEdge')
|
|> line([0, wallMountL], %, $outerEdge)
|
||||||
|> line([-shelfMountL, 0], %, 'seg01')
|
|> line([-shelfMountL, 0], %, $seg01)
|
||||||
|> line([0, -thickness], %)
|
|> line([0, -thickness], %)
|
||||||
|> line([shelfMountL - thickness, 0], %, 'innerEdge')
|
|> line([shelfMountL - thickness, 0], %, $innerEdge)
|
||||||
|> line([0, -wallMountL + thickness], %)
|
|> line([0, -wallMountL + thickness], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(width, %)
|
|> extrude(width, %)
|
||||||
|> fillet({
|
|> fillet({
|
||||||
radius: filletR,
|
radius: filletR,
|
||||||
tags: [
|
tags: [
|
||||||
getPreviousAdjacentEdge('innerEdge', %)
|
getPreviousAdjacentEdge(innerEdge, %)
|
||||||
]
|
]
|
||||||
}, %)
|
}, %)
|
||||||
|> fillet({
|
|> fillet({
|
||||||
radius: filletR + thickness,
|
radius: filletR + thickness,
|
||||||
tags: [
|
tags: [
|
||||||
getPreviousAdjacentEdge('outerEdge', %)
|
getPreviousAdjacentEdge(outerEdge, %)
|
||||||
]
|
]
|
||||||
}, %)
|
}, %)
|
||||||
|
|
||||||
const sketch001 = startSketchOn(bracket, 'seg01')
|
const sketch001 = startSketchOn(bracket, seg01)
|
||||||
|> startProfileAt([4.28, 3.83], %)
|
|> startProfileAt([4.28, 3.83], %)
|
||||||
|> line([2.17, -0.03], %)
|
|> line([2.17, -0.03], %)
|
||||||
|> line([-0.07, -1.8], %)
|
|> line([-0.07, -1.8], %)
|
||||||
@ -2235,27 +2235,27 @@ const holeDia = 0.5
|
|||||||
|
|
||||||
const sketch001 = startSketchOn("XZ")
|
const sketch001 = startSketchOn("XZ")
|
||||||
|> startProfileAt([-foot1Length, 0], %)
|
|> startProfileAt([-foot1Length, 0], %)
|
||||||
|> line([0, thickness], %, 'cornerFillet1')
|
|> line([0, thickness], %, $cornerFillet1)
|
||||||
|> line([foot1Length, 0], %)
|
|> line([foot1Length, 0], %)
|
||||||
|> line([0, height], %, 'fillet1')
|
|> line([0, height], %, $fillet1)
|
||||||
|> line([foot2Length, 0], %)
|
|> line([foot2Length, 0], %)
|
||||||
|> line([0, -thickness], %, 'cornerFillet2')
|
|> line([0, -thickness], %, $cornerFillet2)
|
||||||
|> line([-foot2Length+thickness, 0], %)
|
|> line([-foot2Length+thickness, 0], %)
|
||||||
|> line([0, -height], %, 'fillet2')
|
|> line([0, -height], %, $fillet2)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|
|
||||||
const baseExtrusion = extrude(width, sketch001)
|
const baseExtrusion = extrude(width, sketch001)
|
||||||
|> fillet({
|
|> fillet({
|
||||||
radius: cornerFilletRad,
|
radius: cornerFilletRad,
|
||||||
tags: ["cornerFillet1", "cornerFillet2", getOppositeEdge("cornerFillet1", %), getOppositeEdge("cornerFillet2", %)],
|
tags: [cornerFillet1, cornerFillet2, getOppositeEdge(cornerFillet1, %), getOppositeEdge(cornerFillet2, %)],
|
||||||
}, %)
|
}, %)
|
||||||
|> fillet({
|
|> fillet({
|
||||||
radius: filletRad,
|
radius: filletRad,
|
||||||
tags: [getPreviousAdjacentEdge("fillet1", %), getPreviousAdjacentEdge("fillet2", %)]
|
tags: [getPreviousAdjacentEdge(fillet1, %), getPreviousAdjacentEdge(fillet2, %)]
|
||||||
}, %)
|
}, %)
|
||||||
|> fillet({
|
|> fillet({
|
||||||
radius: filletRad + thickness,
|
radius: filletRad + thickness,
|
||||||
tags: [getNextAdjacentEdge("fillet1", %), getNextAdjacentEdge("fillet2", %)],
|
tags: [getNextAdjacentEdge(fillet1, %), getNextAdjacentEdge(fillet2, %)],
|
||||||
}, %)
|
}, %)
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
@ -2287,27 +2287,27 @@ const holeDia = 0.5
|
|||||||
|
|
||||||
const sketch001 = startSketchOn("XZ")
|
const sketch001 = startSketchOn("XZ")
|
||||||
|> startProfileAt([-foot1Length, 0], %)
|
|> startProfileAt([-foot1Length, 0], %)
|
||||||
|> line([0, thickness], %, 'cornerChamfer1')
|
|> line([0, thickness], %, $cornerChamfer1)
|
||||||
|> line([foot1Length, 0], %)
|
|> line([foot1Length, 0], %)
|
||||||
|> line([0, height], %, 'chamfer1')
|
|> line([0, height], %, $chamfer1)
|
||||||
|> line([foot2Length, 0], %)
|
|> line([foot2Length, 0], %)
|
||||||
|> line([0, -thickness], %, 'cornerChamfer2')
|
|> line([0, -thickness], %, $cornerChamfer2)
|
||||||
|> line([-foot2Length+thickness, 0], %)
|
|> line([-foot2Length+thickness, 0], %)
|
||||||
|> line([0, -height], %, 'chamfer2')
|
|> line([0, -height], %, $chamfer2)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|
|
||||||
const baseExtrusion = extrude(width, sketch001)
|
const baseExtrusion = extrude(width, sketch001)
|
||||||
|> chamfer({
|
|> chamfer({
|
||||||
length: cornerChamferRad,
|
length: cornerChamferRad,
|
||||||
tags: ["cornerChamfer1", "cornerChamfer2", getOppositeEdge("cornerChamfer1", %), getOppositeEdge("cornerChamfer2", %)],
|
tags: [cornerChamfer1, cornerChamfer2, getOppositeEdge(cornerChamfer1, %), getOppositeEdge(cornerChamfer2, %)],
|
||||||
}, %)
|
}, %)
|
||||||
|> chamfer({
|
|> chamfer({
|
||||||
length: chamferRad,
|
length: chamferRad,
|
||||||
tags: [getPreviousAdjacentEdge("chamfer1", %), getPreviousAdjacentEdge("chamfer2", %)]
|
tags: [getPreviousAdjacentEdge(chamfer1, %), getPreviousAdjacentEdge(chamfer2, %)]
|
||||||
}, %)
|
}, %)
|
||||||
|> chamfer({
|
|> chamfer({
|
||||||
length: chamferRad + thickness,
|
length: chamferRad + thickness,
|
||||||
tags: [getNextAdjacentEdge("chamfer1", %), getNextAdjacentEdge("chamfer2", %)],
|
tags: [getNextAdjacentEdge(chamfer1, %), getNextAdjacentEdge(chamfer2, %)],
|
||||||
}, %)
|
}, %)
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
@ -2323,14 +2323,14 @@ const baseExtrusion = extrude(width, sketch001)
|
|||||||
async fn serial_test_engine_error_source_range_on_last_command() {
|
async fn serial_test_engine_error_source_range_on_last_command() {
|
||||||
let code = r#"const sketch001 = startSketchOn('XZ')
|
let code = r#"const sketch001 = startSketchOn('XZ')
|
||||||
|> startProfileAt([61.74, 206.13], %)
|
|> startProfileAt([61.74, 206.13], %)
|
||||||
|> xLine(305.11, %, 'seg01')
|
|> xLine(305.11, %, $seg01)
|
||||||
|> yLine(-291.85, %)
|
|> yLine(-291.85, %)
|
||||||
|> xLine(-segLen('seg01', %), %)
|
|> xLine(-segLen(seg01, %), %)
|
||||||
|> lineTo([profileStartX(%), profileStartY(%)], %)
|
|> lineTo([profileStartX(%), profileStartY(%)], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(40.14, %)
|
|> extrude(40.14, %)
|
||||||
|> shell({
|
|> shell({
|
||||||
faces: ["seg01"],
|
faces: [seg01],
|
||||||
thickness: 3.14,
|
thickness: 3.14,
|
||||||
}, %)
|
}, %)
|
||||||
"#;
|
"#;
|
||||||
@ -2339,7 +2339,7 @@ async fn serial_test_engine_error_source_range_on_last_command() {
|
|||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.err().unwrap().to_string(),
|
result.err().unwrap().to_string(),
|
||||||
r#"engine: KclErrorDetails { source_ranges: [SourceRange([262, 320])], message: "Modeling command failed: [ApiError { error_code: InternalEngine, message: \"Invalid brep after shell operation\" }]" }"#
|
r#"engine: KclErrorDetails { source_ranges: [SourceRange([259, 315])], message: "Modeling command failed: [ApiError { error_code: InternalEngine, message: \"Invalid brep after shell operation\" }]" }"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2355,11 +2355,11 @@ async fn serial_test_linear_pattern3d_filleted_sketch() {
|
|||||||
return sg
|
return sg
|
||||||
}
|
}
|
||||||
const part001 = cube([0,0], 20)
|
const part001 = cube([0,0], 20)
|
||||||
|> close(%, 'line1')
|
|> close(%, $line1)
|
||||||
|> extrude(20, %)
|
|> extrude(20, %)
|
||||||
|> fillet({
|
|> fillet({
|
||||||
radius: 10,
|
radius: 10,
|
||||||
tags: [getOppositeEdge('line1',%)]
|
tags: [getOppositeEdge(line1,%)]
|
||||||
}, %)
|
}, %)
|
||||||
|
|
||||||
const pattn1 = patternLinear3d({
|
const pattn1 = patternLinear3d({
|
||||||
@ -2390,11 +2390,11 @@ async fn serial_test_circular_pattern3d_filleted_sketch() {
|
|||||||
return sg
|
return sg
|
||||||
}
|
}
|
||||||
const part001 = cube([0,0], 20)
|
const part001 = cube([0,0], 20)
|
||||||
|> close(%, 'line1')
|
|> close(%, $line1)
|
||||||
|> extrude(20, %)
|
|> extrude(20, %)
|
||||||
|> fillet({
|
|> fillet({
|
||||||
radius: 10,
|
radius: 10,
|
||||||
tags: [getOppositeEdge('line1',%)]
|
tags: [getOppositeEdge(line1,%)]
|
||||||
}, %)
|
}, %)
|
||||||
|
|
||||||
const pattn2 = patternCircular3d({axis: [0,0, 1], center: [-20, -20, -20], repetitions: 4, arcDegrees: 360, rotateDuplicates: false}, part001)
|
const pattn2 = patternCircular3d({axis: [0,0, 1], center: [-20, -20, -20], repetitions: 4, arcDegrees: 360, rotateDuplicates: false}, part001)
|
||||||
@ -2421,11 +2421,11 @@ async fn serial_test_circular_pattern3d_chamfered_sketch() {
|
|||||||
return sg
|
return sg
|
||||||
}
|
}
|
||||||
const part001 = cube([0,0], 20)
|
const part001 = cube([0,0], 20)
|
||||||
|> close(%, 'line1')
|
|> close(%, $line1)
|
||||||
|> extrude(20, %)
|
|> extrude(20, %)
|
||||||
|> chamfer({
|
|> chamfer({
|
||||||
length: 10,
|
length: 10,
|
||||||
tags: [getOppositeEdge('line1',%)]
|
tags: [getOppositeEdge(line1,%)]
|
||||||
}, %)
|
}, %)
|
||||||
|
|
||||||
const pattn2 = patternCircular3d({axis: [0,0, 1], center: [-20, -20, -20], repetitions: 4, arcDegrees: 360, rotateDuplicates: false}, part001)
|
const pattn2 = patternCircular3d({axis: [0,0, 1], center: [-20, -20, -20], repetitions: 4, arcDegrees: 360, rotateDuplicates: false}, part001)
|
||||||
@ -2452,12 +2452,12 @@ async fn serial_test_tag_chamfer_with_more_than_one_edge_should_fail() {
|
|||||||
return sg
|
return sg
|
||||||
}
|
}
|
||||||
const part001 = cube([0,0], 20)
|
const part001 = cube([0,0], 20)
|
||||||
|> close(%, 'line1')
|
|> close(%, $line1)
|
||||||
|> extrude(20, %)
|
|> extrude(20, %)
|
||||||
|> chamfer({
|
|> chamfer({
|
||||||
length: 10,
|
length: 10,
|
||||||
tags: ['line1', getOppositeEdge('line1',%)]
|
tags: [line1, getOppositeEdge(line1,%)]
|
||||||
}, %, 'chamfer1')
|
}, %, $chamfer1)
|
||||||
|
|
||||||
|
|
||||||
"#;
|
"#;
|
||||||
@ -2466,7 +2466,7 @@ const part001 = cube([0,0], 20)
|
|||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.err().unwrap().to_string(),
|
result.err().unwrap().to_string(),
|
||||||
r#"type: KclErrorDetails { source_ranges: [SourceRange([272, 365])], message: "You can only tag one edge at a time with a tagged chamfer. Either delete the tag for the chamfer fn if you don't need it OR separate into individual chamfer functions for each tag." }"#
|
r#"type: KclErrorDetails { source_ranges: [SourceRange([271, 359])], message: "You can only tag one edge at a time with a tagged chamfer. Either delete the tag for the chamfer fn if you don't need it OR separate into individual chamfer functions for each tag." }"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 198 KiB After Width: | Height: | Size: 197 KiB |
Reference in New Issue
Block a user