Fix some uses of close and lineTo

Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
Nick Cameron
2025-01-22 11:48:27 +13:00
parent 8bac097743
commit 38e59df85c
10 changed files with 78 additions and 521 deletions

View File

@ -199,7 +199,7 @@ test.describe('Testing segment overlays', () => {
}) })
} }
test.setTimeout(120000) test.setTimeout(120000)
test('for segments [line, angledLine, lineTo, xLineTo]', async ({ test('for segments [line, angledLine, xLineTo]', async ({
page, page,
editor, editor,
homePage, homePage,
@ -1111,7 +1111,7 @@ test.describe('Testing segment overlays', () => {
) )
await page.mouse.move(hoverPos.x, hoverPos.y) await page.mouse.move(hoverPos.x, hoverPos.y)
const codeToBeDeleted = 'lineTo(endAbsolute = [33, 11.5 + 0])' const codeToBeDeleted = 'line(endAbsolute = [33, 11.5 + 0])'
await editor.expectEditor.toContain(codeToBeDeleted, { await editor.expectEditor.toContain(codeToBeDeleted, {
shouldNormalise: true, shouldNormalise: true,
}) })

View File

@ -815,7 +815,7 @@ test.describe('Testing selections', () => {
await checkCodeAtHoverPosition( await checkCodeAtHoverPosition(
'adjacentChamfer1', 'adjacentChamfer1',
adjacentChamfer1, adjacentChamfer1,
`lineTo([profileStartX(%),profileStartY(%)],%,$seg02)chamfer({length=30,tags=[seg01,getNextAdjacentEdge(yo),getNextAdjacentEdge(seg02),getOppositeEdge(seg01)]},%)`, `line(endAbsolute=[profileStartX(%),profileStartY(%)],tag=$seg02)chamfer({length=30,tags=[seg01,getNextAdjacentEdge(yo),getNextAdjacentEdge(seg02),getOppositeEdge(seg01)]},%)`,
'}, %)' '}, %)'
) )

View File

@ -119,7 +119,7 @@ const Part001 = startSketchOn('XY')
|> angledLineToX({ angle: 120, to: pipeSmallDia }, %) |> angledLineToX({ angle: 120, to: pipeSmallDia }, %)
|> line([0, pipeLength], %) |> line([0, pipeLength], %)
|> angledLineToX({ angle: 60, to: pipeLargeDia }, %) |> angledLineToX({ angle: 60, to: pipeLargeDia }, %)
|> close(%) |> close()
|> revolve({ axis: 'y' }, %) |> revolve({ axis: 'y' }, %)
" "
); );
@ -155,7 +155,7 @@ const part001 = startSketchOn('XY')
|> angledLineToX({ angle: 120, to: pipeSmallDia }, %) |> angledLineToX({ angle: 120, to: pipeSmallDia }, %)
|> line([0, pipeLength], %) |> line([0, pipeLength], %)
|> angledLineToX({ angle: 60, to: pipeLargeDia }, %) |> angledLineToX({ angle: 60, to: pipeLargeDia }, %)
|> close(%) |> close()
|> revolve({ axis: 'y' }, %) |> revolve({ axis: 'y' }, %)
" "
); );

View File

@ -107,7 +107,7 @@ const bracket = startSketchOn('XY')
|> 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,
@ -154,7 +154,7 @@ const bracket = startSketchOn('XY')
|> 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,

View File

@ -3385,7 +3385,7 @@ mySk1 = startSketchAt([0, 0])"#;
#[test] #[test]
fn pipes_on_pipes_minimal() { fn pipes_on_pipes_minimal() {
let test_program = r#"startSketchAt([0, 0]) let test_program = r#"startSketchAt([0, 0])
|> lineTo([0, -0], %) // MoveRelative |> line(endAbsolute = [0, -0]) // MoveRelative
"#; "#;
let tokens = crate::parsing::token::lex(test_program, ModuleId::default()).unwrap(); let tokens = crate::parsing::token::lex(test_program, ModuleId::default()).unwrap();
@ -3730,7 +3730,7 @@ firstExtrude = startSketchOn('XY')
|> line([0, 8], %) |> line([0, 8], %)
|> line([20, 0], %) |> line([20, 0], %)
|> line([0, -8], %) |> line([0, -8], %)
|> close(%) |> close()
|> extrude(length=2) |> extrude(length=2)
secondExtrude = startSketchOn('XY') secondExtrude = startSketchOn('XY')
@ -4207,7 +4207,7 @@ let other_thing = 2 * cos(3)"#;
|> line([0, l], %) |> line([0, l], %)
|> line([w, 0], %) |> line([w, 0], %)
|> line([0, -l], %) |> line([0, -l], %)
|> close(%) |> close()
|> extrude(length=h) |> extrude(length=h)
return myBox return myBox
@ -4574,7 +4574,7 @@ mod snapshot_tests {
snapshot_test!(y, "sg = startSketchAt(pos)"); snapshot_test!(y, "sg = startSketchAt(pos)");
snapshot_test!(z, "sg = startSketchAt(pos) |> line([0, -scale], %)"); snapshot_test!(z, "sg = startSketchAt(pos) |> line([0, -scale], %)");
snapshot_test!(aa, r#"sg = -scale"#); snapshot_test!(aa, r#"sg = -scale"#);
snapshot_test!(ab, "lineTo({ to: [0, -1] })"); snapshot_test!(ab, "line(endAbsolute = [0, -1])");
snapshot_test!(ac, "myArray = [0..10]"); snapshot_test!(ac, "myArray = [0..10]");
snapshot_test!( snapshot_test!(
ad, ad,
@ -4594,20 +4594,16 @@ mod snapshot_tests {
snapshot_test!( snapshot_test!(
af, af,
r#"mySketch = startSketchAt([0,0]) r#"mySketch = startSketchAt([0,0])
|> lineTo([0, 1], %, $myPath) |> line(endAbsolute = [0, 1], tag = $myPath)
|> lineTo([1, 1], %) |> line(endAbsolute = [1, 1])
|> lineTo([1, 0], %, $rightPath) |> line(endAbsolute = [1, 0], tag = $rightPath)
|> close(%)"# |> close()"#
); );
snapshot_test!(ag, "mySketch = startSketchAt([0,0]) |> lineTo([1, 1], %) |> close(%)"); snapshot_test!(ag, "mySketch = startSketchAt([0,0]) |> line(endAbsolute = [1, 1]) |> close()");
snapshot_test!(ah, "myBox = startSketchAt(p)"); snapshot_test!(ah, "myBox = startSketchAt(p)");
snapshot_test!(ai, r#"myBox = f(1) |> g(2, %)"#); snapshot_test!(ai, r#"myBox = f(1) |> g(2, %)"#);
snapshot_test!(aj, r#"myBox = startSketchAt(p) |> line([0, l], %)"#); snapshot_test!(aj, r#"myBox = startSketchAt(p) |> line(end = [0, l])"#);
snapshot_test!(ak, "lineTo({ to: [0, 1] })"); snapshot_test!(ak, "line(endAbsolute = [0, 1])");
snapshot_test!(al, "lineTo({ to: [0, 1], from: [3, 3] })");
snapshot_test!(am, "lineTo({to:[0, 1]})");
snapshot_test!(an, "lineTo({ to: [0, 1], from: [3, 3]})");
snapshot_test!(ao, "lineTo({ to: [0, 1],from: [3, 3] })");
snapshot_test!(ap, "mySketch = startSketchAt([0,0])"); snapshot_test!(ap, "mySketch = startSketchAt([0,0])");
snapshot_test!(aq, "log(5, \"hello\", aIdentifier)"); snapshot_test!(aq, "log(5, \"hello\", aIdentifier)");
snapshot_test!(ar, r#"5 + "a""#); snapshot_test!(ar, r#"5 + "a""#);

View File

@ -1,120 +0,0 @@
---
source: kcl/src/parsing/parser.rs
expression: actual
---
{
"body": [
{
"end": 36,
"expression": {
"arguments": [
{
"end": 35,
"properties": [
{
"end": 19,
"key": {
"end": 11,
"name": "to",
"start": 9,
"type": "Identifier"
},
"start": 9,
"type": "ObjectProperty",
"value": {
"elements": [
{
"end": 15,
"raw": "0",
"start": 14,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"end": 18,
"raw": "1",
"start": 17,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
}
],
"end": 19,
"start": 13,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"end": 33,
"key": {
"end": 25,
"name": "from",
"start": 21,
"type": "Identifier"
},
"start": 21,
"type": "ObjectProperty",
"value": {
"elements": [
{
"end": 29,
"raw": "3",
"start": 28,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.0,
"suffix": "None"
}
},
{
"end": 32,
"raw": "3",
"start": 31,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.0,
"suffix": "None"
}
}
],
"end": 33,
"start": 27,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
}
],
"start": 7,
"type": "ObjectExpression",
"type": "ObjectExpression"
}
],
"callee": {
"end": 6,
"name": "lineTo",
"start": 0,
"type": "Identifier"
},
"end": 36,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"end": 36,
"start": 0
}

View File

@ -1,79 +0,0 @@
---
source: kcl/src/parsing/parser.rs
expression: actual
---
{
"body": [
{
"end": 19,
"expression": {
"arguments": [
{
"end": 18,
"properties": [
{
"end": 17,
"key": {
"end": 10,
"name": "to",
"start": 8,
"type": "Identifier"
},
"start": 8,
"type": "ObjectProperty",
"value": {
"elements": [
{
"end": 13,
"raw": "0",
"start": 12,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"end": 16,
"raw": "1",
"start": 15,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
}
],
"end": 17,
"start": 11,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
}
],
"start": 7,
"type": "ObjectExpression",
"type": "ObjectExpression"
}
],
"callee": {
"end": 6,
"name": "lineTo",
"start": 0,
"type": "Identifier"
},
"end": 19,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"end": 19,
"start": 0
}

View File

@ -1,120 +0,0 @@
---
source: kcl/src/parsing/parser.rs
expression: actual
---
{
"body": [
{
"end": 35,
"expression": {
"arguments": [
{
"end": 34,
"properties": [
{
"end": 19,
"key": {
"end": 11,
"name": "to",
"start": 9,
"type": "Identifier"
},
"start": 9,
"type": "ObjectProperty",
"value": {
"elements": [
{
"end": 15,
"raw": "0",
"start": 14,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"end": 18,
"raw": "1",
"start": 17,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
}
],
"end": 19,
"start": 13,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"end": 33,
"key": {
"end": 25,
"name": "from",
"start": 21,
"type": "Identifier"
},
"start": 21,
"type": "ObjectProperty",
"value": {
"elements": [
{
"end": 29,
"raw": "3",
"start": 28,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.0,
"suffix": "None"
}
},
{
"end": 32,
"raw": "3",
"start": 31,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.0,
"suffix": "None"
}
}
],
"end": 33,
"start": 27,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
}
],
"start": 7,
"type": "ObjectExpression",
"type": "ObjectExpression"
}
],
"callee": {
"end": 6,
"name": "lineTo",
"start": 0,
"type": "Identifier"
},
"end": 35,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"end": 35,
"start": 0
}

View File

@ -1,120 +0,0 @@
---
source: kcl/src/parsing/parser.rs
expression: actual
---
{
"body": [
{
"end": 35,
"expression": {
"arguments": [
{
"end": 34,
"properties": [
{
"end": 19,
"key": {
"end": 11,
"name": "to",
"start": 9,
"type": "Identifier"
},
"start": 9,
"type": "ObjectProperty",
"value": {
"elements": [
{
"end": 15,
"raw": "0",
"start": 14,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"end": 18,
"raw": "1",
"start": 17,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
}
],
"end": 19,
"start": 13,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"end": 32,
"key": {
"end": 24,
"name": "from",
"start": 20,
"type": "Identifier"
},
"start": 20,
"type": "ObjectProperty",
"value": {
"elements": [
{
"end": 28,
"raw": "3",
"start": 27,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.0,
"suffix": "None"
}
},
{
"end": 31,
"raw": "3",
"start": 30,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.0,
"suffix": "None"
}
}
],
"end": 32,
"start": 26,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
}
],
"start": 7,
"type": "ObjectExpression",
"type": "ObjectExpression"
}
],
"callee": {
"end": 6,
"name": "lineTo",
"start": 0,
"type": "Identifier"
},
"end": 35,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"end": 35,
"start": 0
}

View File

@ -876,17 +876,17 @@ fn rect(x, y, w, h) {
|> xLine(w, %) |> xLine(w, %)
|> yLine(h, %) |> yLine(h, %)
|> xLine(-w, %) |> xLine(-w, %)
|> close(%) |> close()
|> extrude(d, %) |> extrude(d, %)
} }
fn quad(x1, y1, x2, y2, x3, y3, x4, y4) { fn quad(x1, y1, x2, y2, x3, y3, x4, y4) {
startSketchOn('XY') startSketchOn('XY')
|> startProfileAt([x1, y1], %) |> startProfileAt([x1, y1], %)
|> lineTo([x2, y2], %) |> line(endAbsolute = [x2, y2])
|> lineTo([x3, y3], %) |> line(endAbsolute = [x3, y3])
|> lineTo([x4, y4], %) |> line(endAbsolute = [x4, y4])
|> close(%) |> close()
|> extrude(d, %) |> extrude(d, %)
} }
@ -950,7 +950,7 @@ fn o(c_x, c_y) {
angle_start = 225 - a, angle_start = 225 - a,
angle_end = 45 + a angle_end = 45 + a
}, %) }, %)
|> close(%) |> close()
|> extrude(d, %) |> extrude(d, %)
startSketchOn('XY') startSketchOn('XY')
@ -966,7 +966,7 @@ fn o(c_x, c_y) {
angle_start = 45 - a, angle_start = 45 - a,
angle_end = 225 + a - 360 angle_end = 225 + a - 360
}, %) }, %)
|> close(%) |> close()
|> extrude(d, %) |> extrude(d, %)
} }
@ -1006,7 +1006,7 @@ insideRevolve = startSketchOn('XZ')
|> line([overHangLength - thickness, 0], %) |> line([overHangLength - thickness, 0], %)
|> line([0, -thickness], %) |> line([0, -thickness], %)
|> line([-overHangLength, 0], %) |> line([-overHangLength, 0], %)
|> close(%) |> close()
|> revolve({ axis: 'y' }, %) |> revolve({ axis: 'y' }, %)
// Sketch and revolve one of the balls and duplicate it using a circular pattern. (This is currently a workaround, we have a bug with rotating on a sketch that touches the rotation axis) // Sketch and revolve one of the balls and duplicate it using a circular pattern. (This is currently a workaround, we have a bug with rotating on a sketch that touches the rotation axis)
@ -1021,7 +1021,7 @@ sphere = startSketchOn('XZ')
angle_end = -180, angle_end = -180,
radius = sphereDia / 2 - 0.05 radius = sphereDia / 2 - 0.05
}, %) }, %)
|> close(%) |> close()
|> revolve({ axis: 'x' }, %) |> revolve({ axis: 'x' }, %)
|> patternCircular3d({ |> patternCircular3d({
axis = [0, 0, 1], axis = [0, 0, 1],
@ -1045,7 +1045,7 @@ outsideRevolve = startSketchOn('XZ')
|> line([-overHangLength, 0], %) |> line([-overHangLength, 0], %)
|> line([0, thickness], %) |> line([0, thickness], %)
|> line([overHangLength - thickness, 0], %) |> line([overHangLength - thickness, 0], %)
|> close(%) |> close()
|> revolve({ axis: 'y' }, %)"#; |> revolve({ axis: 'y' }, %)"#;
let program = crate::parsing::top_level_parse(some_program_string).unwrap(); let program = crate::parsing::top_level_parse(some_program_string).unwrap();
@ -1073,7 +1073,7 @@ insideRevolve = startSketchOn('XZ')
|> line([overHangLength - thickness, 0], %) |> line([overHangLength - thickness, 0], %)
|> line([0, -thickness], %) |> line([0, -thickness], %)
|> line([-overHangLength, 0], %) |> line([-overHangLength, 0], %)
|> close(%) |> close()
|> revolve({ axis = 'y' }, %) |> revolve({ axis = 'y' }, %)
// Sketch and revolve one of the balls and duplicate it using a circular pattern. (This is currently a workaround, we have a bug with rotating on a sketch that touches the rotation axis) // Sketch and revolve one of the balls and duplicate it using a circular pattern. (This is currently a workaround, we have a bug with rotating on a sketch that touches the rotation axis)
@ -1088,7 +1088,7 @@ sphere = startSketchOn('XZ')
angle_end = -180, angle_end = -180,
radius = sphereDia / 2 - 0.05 radius = sphereDia / 2 - 0.05
}, %) }, %)
|> close(%) |> close()
|> revolve({ axis = 'x' }, %) |> revolve({ axis = 'x' }, %)
|> patternCircular3d({ |> patternCircular3d({
axis = [0, 0, 1], axis = [0, 0, 1],
@ -1112,7 +1112,7 @@ outsideRevolve = startSketchOn('XZ')
|> line([-overHangLength, 0], %) |> line([-overHangLength, 0], %)
|> line([0, thickness], %) |> line([0, thickness], %)
|> line([overHangLength - thickness, 0], %) |> line([overHangLength - thickness, 0], %)
|> close(%) |> close()
|> revolve({ axis = 'y' }, %) |> revolve({ axis = 'y' }, %)
"# "#
); );
@ -1239,7 +1239,7 @@ part001 = startSketchOn('XY')
|> line([20, 0], %) |> line([20, 0], %)
|> line([0, 20], %) |> line([0, 20], %)
|> line([-20, 0], %) |> line([-20, 0], %)
|> close(%) |> close()
"#; "#;
let program = crate::parsing::top_level_parse(some_program_string).unwrap(); let program = crate::parsing::top_level_parse(some_program_string).unwrap();
@ -1254,7 +1254,7 @@ part001 = startSketchOn('XY')
|> line([20, 0], %) |> line([20, 0], %)
|> line([0, 20], %) |> line([0, 20], %)
|> line([-20, 0], %) |> line([-20, 0], %)
|> close(%) |> close()
"# "#
); );
} }
@ -1270,7 +1270,7 @@ part001 = startSketchOn('XY')
|> line([20, 0], %) |> line([20, 0], %)
|> line([0, 20], %) |> line([0, 20], %)
|> line([-20, 0], %) |> line([-20, 0], %)
|> close(%) |> close()
"#; "#;
let program = crate::parsing::top_level_parse(some_program_string).unwrap(); let program = crate::parsing::top_level_parse(some_program_string).unwrap();
@ -1285,7 +1285,7 @@ part001 = startSketchOn('XY')
|> line([20, 0], %) |> line([20, 0], %)
|> line([0, 20], %) |> line([0, 20], %)
|> line([-20, 0], %) |> line([-20, 0], %)
|> close(%) |> close()
"# "#
); );
} }
@ -1300,7 +1300,7 @@ part001 = startSketchOn('XY')
|> line([20, 0], %) |> line([20, 0], %)
|> line([0, 20], %) |> line([0, 20], %)
|> line([-20, 0], %) |> line([-20, 0], %)
|> close(%) |> close()
"#; "#;
let program = crate::parsing::top_level_parse(some_program_string).unwrap(); let program = crate::parsing::top_level_parse(some_program_string).unwrap();
@ -1316,7 +1316,7 @@ part001 = startSketchOn('XY')
|> line([20, 0], %) |> line([20, 0], %)
|> line([0, 20], %) |> line([0, 20], %)
|> line([-20, 0], %) |> line([-20, 0], %)
|> close(%) |> close()
"# "#
); );
} }
@ -1335,10 +1335,10 @@ hole_diam = 5
fn rectShape = (pos, w, l) => { fn rectShape = (pos, w, l) => {
rr = startSketchOn('xy') 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) |> line(endAbsolute = [pos[0] + w / 2, pos[1] - (l / 2)], tag = $edge1)
|> lineTo([pos[0] + w / 2, pos[1] + l / 2], %, $edge2) |> line(endAbsolute = [pos[0] + w / 2, pos[1] + l / 2], tag = $edge2)
|> lineTo([pos[0] - (w / 2), pos[1] + l / 2], %, $edge3) |> line(endAbsolute = [pos[0] - (w / 2), pos[1] + l / 2], tag = $edge3)
|> close(%, $edge4) |> close($edge4)
return rr return rr
} }
// build the body of the focusrite scarlett solo gen 4 // build the body of the focusrite scarlett solo gen 4
@ -1365,14 +1365,14 @@ fn bracketSketch = (w, d, t) => {
} }
}) })
|> startProfileAt([-w / 2 - t, d + t], %) |> startProfileAt([-w / 2 - t, d + t], %)
|> lineTo([-w / 2 - t, -t], %, $edge1) |> line(endAbsolute = [-w / 2 - t, -t], tag = $edge1)
|> lineTo([w / 2 + t, -t], %, $edge2) |> line(endAbsolute = [w / 2 + t, -t], tag = $edge2)
|> lineTo([w / 2 + t, d + t], %, $edge3) |> line(endAbsolute = [w / 2 + t, d + t], tag = $edge3)
|> lineTo([w / 2, d + t], %, $edge4) |> line(endAbsolute = [w / 2, d + t], tag = $edge4)
|> lineTo([w / 2, 0], %, $edge5) |> line(endAbsolute = [w / 2, 0], tag = $edge5)
|> lineTo([-w / 2, 0], %, $edge6) |> line(endAbsolute = [-w / 2, 0], tag = $edge6)
|> lineTo([-w / 2, d + t], %, $edge7) |> line(endAbsolute = [-w / 2, d + t], tag = $edge7)
|> close(%, $edge8) |> close($edge8)
return s return s
} }
// build the body of the bracket // build the body of the bracket
@ -1400,7 +1400,7 @@ tabs_r = startSketchOn({
|> line([10, -5], %) |> line([10, -5], %)
|> line([0, -10], %) |> line([0, -10], %)
|> line([-10, -5], %) |> line([-10, -5], %)
|> close(%) |> close()
|> hole(circle({ |> hole(circle({
center = [ center = [
width / 2 + thk + hole_diam, width / 2 + thk + hole_diam,
@ -1427,7 +1427,7 @@ tabs_l = startSketchOn({
|> line([-10, -5], %) |> line([-10, -5], %)
|> line([0, -10], %) |> line([0, -10], %)
|> line([10, -5], %) |> line([10, -5], %)
|> close(%) |> close()
|> hole(circle({ |> hole(circle({
center = [ center = [
-width / 2 - thk - hole_diam, -width / 2 - thk - hole_diam,
@ -1460,10 +1460,10 @@ hole_diam = 5
fn rectShape(pos, w, l) { fn rectShape(pos, w, l) {
rr = startSketchOn('xy') 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) |> line(endAbsolute = [pos[0] + w / 2, pos[1] - (l / 2)], tag = $edge1)
|> lineTo([pos[0] + w / 2, pos[1] + l / 2], %, $edge2) |> line(endAbsolute = [pos[0] + w / 2, pos[1] + l / 2], tag = $edge2)
|> lineTo([pos[0] - (w / 2), pos[1] + l / 2], %, $edge3) |> line(endAbsolute = [pos[0] - (w / 2), pos[1] + l / 2], tag = $edge3)
|> close(%, $edge4) |> close($edge4)
return rr return rr
} }
// build the body of the focusrite scarlett solo gen 4 // build the body of the focusrite scarlett solo gen 4
@ -1490,14 +1490,14 @@ fn bracketSketch(w, d, t) {
} }
}) })
|> startProfileAt([-w / 2 - t, d + t], %) |> startProfileAt([-w / 2 - t, d + t], %)
|> lineTo([-w / 2 - t, -t], %, $edge1) |> line(endAbsolute = [-w / 2 - t, -t], tag = $edge1)
|> lineTo([w / 2 + t, -t], %, $edge2) |> line(endAbsolute = [w / 2 + t, -t], tag = $edge2)
|> lineTo([w / 2 + t, d + t], %, $edge3) |> line(endAbsolute = [w / 2 + t, d + t], tag = $edge3)
|> lineTo([w / 2, d + t], %, $edge4) |> line(endAbsolute = [w / 2, d + t], tag = $edge4)
|> lineTo([w / 2, 0], %, $edge5) |> line(endAbsolute = [w / 2, 0], tag = $edge5)
|> lineTo([-w / 2, 0], %, $edge6) |> line(endAbsolute = [-w / 2, 0], tag = $edge6)
|> lineTo([-w / 2, d + t], %, $edge7) |> line(endAbsolute = [-w / 2, d + t], tag = $edge7)
|> close(%, $edge8) |> close($edge8)
return s return s
} }
// build the body of the bracket // build the body of the bracket
@ -1525,7 +1525,7 @@ tabs_r = startSketchOn({
|> line([10, -5], %) |> line([10, -5], %)
|> line([0, -10], %) |> line([0, -10], %)
|> line([-10, -5], %) |> line([-10, -5], %)
|> close(%) |> close()
|> hole(circle({ |> hole(circle({
center = [ center = [
width / 2 + thk + hole_diam, width / 2 + thk + hole_diam,
@ -1552,7 +1552,7 @@ tabs_l = startSketchOn({
|> line([-10, -5], %) |> line([-10, -5], %)
|> line([0, -10], %) |> line([0, -10], %)
|> line([10, -5], %) |> line([10, -5], %)
|> close(%) |> close()
|> hole(circle({ |> hole(circle({
center = [ center = [
-width / 2 - thk - hole_diam, -width / 2 - thk - hole_diam,
@ -1578,7 +1578,7 @@ tabs_l = startSketchOn({
|> line([0, scale], %) |> line([0, scale], %)
|> line([scale, 0], %) |> line([scale, 0], %)
|> line([0, -scale], %) |> line([0, -scale], %)
|> close(%) |> close()
|> extrude(scale, %) |> extrude(scale, %)
}"#; }"#;
let program = crate::parsing::top_level_parse(some_program_string).unwrap(); let program = crate::parsing::top_level_parse(some_program_string).unwrap();
@ -1592,7 +1592,7 @@ tabs_l = startSketchOn({
|> line([0, scale], %) |> line([0, scale], %)
|> line([scale, 0], %) |> line([scale, 0], %)
|> line([0, -scale], %) |> line([0, -scale], %)
|> close(%) |> close()
|> extrude(scale, %) |> extrude(scale, %)
} }
"# "#
@ -1609,7 +1609,7 @@ tabs_l = startSketchOn({
|> line([0, scale], %) |> line([0, scale], %)
|> line([scale, 0], %) as bar |> line([scale, 0], %) as bar
|> line([0 as baz, -scale] as qux, %) |> line([0 as baz, -scale] as qux, %)
|> close(%) |> close()
|> extrude(scale, %) |> extrude(scale, %)
} }
@ -1825,10 +1825,10 @@ mySk1 = startSketchAt([0, 0])
let some_program_string = r#"// comment at start let some_program_string = r#"// comment at start
mySk1 = startSketchOn('XY') mySk1 = startSketchOn('XY')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> lineTo([1, 1], %) |> line(endAbsolute = [1, 1])
// comment here // comment here
|> lineTo([0, 1], %, $myTag) |> line(endAbsolute = [0, 1], tag = $myTag)
|> lineTo([1, 1], %) |> line(endAbsolute = [1, 1])
/* and /* and
here here
*/ */
@ -1846,10 +1846,10 @@ mySk1 = startSketchOn('XY')
r#"// comment at start r#"// comment at start
mySk1 = startSketchOn('XY') mySk1 = startSketchOn('XY')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> lineTo([1, 1], %) |> line(endAbsolute = [1, 1])
// comment here // comment here
|> lineTo([0, 1], %, $myTag) |> line(endAbsolute = [0, 1], tag = $myTag)
|> lineTo([1, 1], %) |> line(endAbsolute = [1, 1])
/* and /* and
here */ here */
// a comment between pipe expression statements // a comment between pipe expression statements
@ -2088,7 +2088,7 @@ firstExtrude = startSketchOn('XY')
|> line([0, l], %) |> line([0, l], %)
|> line([w, 0], %) |> line([w, 0], %)
|> line([0, -l], %) |> line([0, -l], %)
|> close(%) |> close()
|> extrude(h, %) |> extrude(h, %)
"#; "#;
let program = crate::parsing::top_level_parse(some_program_string).unwrap(); let program = crate::parsing::top_level_parse(some_program_string).unwrap();
@ -2105,7 +2105,7 @@ firstExtrude = startSketchOn('XY')
|> line([0, l], %) |> line([0, l], %)
|> line([w, 0], %) |> line([w, 0], %)
|> line([0, -l], %) |> line([0, -l], %)
|> close(%) |> close()
|> extrude(h, %) |> extrude(h, %)
"# "#
); );
@ -2125,7 +2125,7 @@ firstExtrude = startSketchOn('XY')
|> line([0, l], %) |> line([0, l], %)
|> line([w, 0], %) |> line([w, 0], %)
|> line([0, -l], %) |> line([0, -l], %)
|> close(%) |> close()
|> extrude(h, %) |> extrude(h, %)
"#; "#;
let program = crate::parsing::top_level_parse(some_program_string).unwrap(); let program = crate::parsing::top_level_parse(some_program_string).unwrap();
@ -2145,7 +2145,7 @@ firstExtrude = startSketchOn('XY')
|> line([0, l], %) |> line([0, l], %)
|> line([w, 0], %) |> line([w, 0], %)
|> line([0, -l], %) |> line([0, -l], %)
|> close(%) |> close()
|> extrude(h, %) |> extrude(h, %)
"# "#
); );