able to go to and from app settings to executor settings for cli (#2236)

* settings from and into exefcutor settings

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* settings

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* ipdates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* ensure all have extrudes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2024-04-25 02:31:18 -07:00
committed by GitHub
parent c89780a489
commit b950cc0583
51 changed files with 150 additions and 144 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1068,7 +1068,7 @@
"unpublished": false, "unpublished": false,
"deprecated": false, "deprecated": false,
"examples": [ "examples": [
"const part001 = startSketchOn('XY')\n |> startProfileAt([0, 0], %)\n |> line([1, 3.82], %, 'seg01')\n |> angledLineToX([\n -angleToMatchLengthX('seg01', 10, %),\n 5\n ], %)\n |> close(%)" "const part001 = startSketchOn('XY')\n |> startProfileAt([0, 0], %)\n |> line([1, 3.82], %, 'seg01')\n |> angledLineToX([\n -angleToMatchLengthX('seg01', 10, %),\n 5\n ], %)\n |> close(%)\n |> extrude(5, %)"
] ]
}, },
{ {
@ -2074,7 +2074,7 @@
"unpublished": false, "unpublished": false,
"deprecated": false, "deprecated": false,
"examples": [ "examples": [
"const part001 = startSketchOn('XY')\n |> startProfileAt([0, 0], %)\n |> line([1, 3.82], %, 'seg01')\n |> angledLineToX([\n -angleToMatchLengthY('seg01', 10, %),\n 5\n ], %)\n |> close(%)" "const part001 = startSketchOn('XY')\n |> startProfileAt([0, 0], %)\n |> line([1, 3.82], %, 'seg01')\n |> angledLineToX([\n -angleToMatchLengthY('seg01', 10, %),\n 5\n ], %)\n |> close(%)\n |> extrude(5, %)"
] ]
}, },
{ {
@ -22380,8 +22380,8 @@
"unpublished": false, "unpublished": false,
"deprecated": false, "deprecated": false,
"examples": [ "examples": [
"startSketchOn('XZ')\n |> startProfileAt([0, 0], %)\n |> line([10, 10], %)\n |> line([10, 0], %)\n |> close(%)", "startSketchOn('XZ')\n |> startProfileAt([0, 0], %)\n |> line([10, 10], %)\n |> line([10, 0], %)\n |> close(%)\n |> extrude(10, %)",
"startSketchOn('YZ')\n |> startProfileAt([0, 0], %)\n |> line([10, 10], %)\n |> line([10, 0], %)\n |> close(%, \"edge1\")" "startSketchOn('YZ')\n |> startProfileAt([0, 0], %)\n |> line([10, 10], %)\n |> line([10, 0], %)\n |> close(%, \"edge1\")\n |> extrude(10, %)"
] ]
}, },
{ {
@ -43695,7 +43695,7 @@
"unpublished": false, "unpublished": false,
"deprecated": false, "deprecated": false,
"examples": [ "examples": [
"fn rectShape = (pos, w, l) => {\n const rr = startSketchOn('YZ')\n |> startProfileAt([pos[0] - (w / 2), pos[1] - (l / 2)], %)\n |> lineTo([pos[0] + w / 2, pos[1] - (l / 2)], %, \"edge1\")\n |> lineTo([pos[0] + w / 2, pos[1] + l / 2], %, \"edge2\")\n |> lineTo([pos[0] - (w / 2), pos[1] + l / 2], %, \"edge3\")\n |> close(%, \"edge4\")\n return rr\n}\n\n// Create the mounting plate extrusion, holes, and fillets\nconst part = rectShape([0, 0], 20, 20)" "fn rectShape = (pos, w, l) => {\n const rr = startSketchOn('YZ')\n |> startProfileAt([pos[0] - (w / 2), pos[1] - (l / 2)], %)\n |> lineTo([pos[0] + w / 2, pos[1] - (l / 2)], %, \"edge1\")\n |> lineTo([pos[0] + w / 2, pos[1] + l / 2], %, \"edge2\")\n |> lineTo([pos[0] - (w / 2), pos[1] + l / 2], %, \"edge3\")\n |> close(%, \"edge4\")\n return rr\n}\n\n// Create the mounting plate extrusion, holes, and fillets\nconst part = rectShape([0, 0], 20, 20)\n |> extrude(10, %)"
] ]
}, },
{ {
@ -45900,7 +45900,7 @@
"unpublished": false, "unpublished": false,
"deprecated": false, "deprecated": false,
"examples": [ "examples": [
"const part = startSketchOn('XY')\n |> circle([0, 0], 2, %)\n |> patternCircular2d({\n center: [20, 20],\n repetitions: 12,\n arcDegrees: 210,\n rotateDuplicates: true\n }, %)" "const part = startSketchOn('XY')\n |> circle([0, 0], 2, %)\n |> patternCircular2d({\n center: [20, 20],\n repetitions: 12,\n arcDegrees: 210,\n rotateDuplicates: true\n }, %)\n |> extrude(1, %)"
] ]
}, },
{ {
@ -50459,7 +50459,7 @@
"unpublished": false, "unpublished": false,
"deprecated": false, "deprecated": false,
"examples": [ "examples": [
"const part = startSketchOn('XY')\n |> circle([0, 0], 2, %)\n |> patternLinear2d({\n axis: [0, 1],\n repetitions: 12,\n distance: 2\n }, %)" "const part = startSketchOn('XY')\n |> circle([0, 0], 2, %)\n |> patternLinear2d({\n axis: [0, 1],\n repetitions: 12,\n distance: 2\n }, %)\n |> extrude(1, %)"
] ]
}, },
{ {
@ -59318,7 +59318,7 @@
"unpublished": false, "unpublished": false,
"deprecated": false, "deprecated": false,
"examples": [ "examples": [
"startSketchOn('XY')\n |> startProfileAt([0, 0], %)\n |> line([10, 10], %)" "startSketchOn('XY')\n |> startProfileAt([0, 0], %)\n |> line([10, 10], %)\n |> line([10, 0], %)\n |> close(%)\n |> extrude(10, %)"
] ]
}, },
{ {
@ -60312,7 +60312,7 @@
"unpublished": false, "unpublished": false,
"deprecated": false, "deprecated": false,
"examples": [ "examples": [
"startSketchAt([0, 0])\n |> line([10, 10], %)" "startSketchAt([0, 0])\n |> line([10, 10], %)\n |> line([20, 10], %, \"edge1\")\n |> close(%, \"edge2\")\n |> extrude(10, %)"
] ]
}, },
{ {
@ -61585,7 +61585,7 @@
"unpublished": false, "unpublished": false,
"deprecated": false, "deprecated": false,
"examples": [ "examples": [
"startSketchOn('XY')\n |> startProfileAt([0, 0], %)\n |> line([10, 10], %)\n |> line([20, 10], %, \"edge1\")\n |> close(%, \"edge2\")", "startSketchOn('XY')\n |> startProfileAt([0, 0], %)\n |> line([10, 10], %)\n |> line([20, 10], %, \"edge1\")\n |> close(%, \"edge2\")\n |> extrude(10, %)",
"fn cube = (pos, scale) => {\n const sg = startSketchOn('XY')\n |> startProfileAt(pos, %)\n |> line([0, scale], %)\n |> line([scale, 0], %)\n |> line([0, -scale], %)\n |> close(%)\n |> extrude(scale, %)\n\n return sg\n}\n\nconst box = cube([0, 0], 20)\n\nconst part001 = startSketchOn(box, \"start\")\n |> startProfileAt([0, 0], %)\n |> line([10, 10], %)\n |> line([20, 10], %, \"edge1\")\n |> close(%)\n |> extrude(20, %)" "fn cube = (pos, scale) => {\n const sg = startSketchOn('XY')\n |> startProfileAt(pos, %)\n |> line([0, scale], %)\n |> line([scale, 0], %)\n |> line([0, -scale], %)\n |> close(%)\n |> extrude(scale, %)\n\n return sg\n}\n\nconst box = cube([0, 0], 20)\n\nconst part001 = startSketchOn(box, \"start\")\n |> startProfileAt([0, 0], %)\n |> line([10, 10], %)\n |> line([20, 10], %, \"edge1\")\n |> close(%)\n |> extrude(20, %)"
] ]
}, },
@ -65584,7 +65584,7 @@
"unpublished": false, "unpublished": false,
"deprecated": false, "deprecated": false,
"examples": [ "examples": [
"startSketchOn('-YZ')\n |> startProfileAt([0, 0], %)\n |> line([10, 10], %, \"edge0\")\n |> tangentialArcTo([10, 0], %)\n |> close(%)" "startSketchOn('-YZ')\n |> startProfileAt([0, 0], %)\n |> line([10, 10], %, \"edge0\")\n |> tangentialArcTo([10, 0], %)\n |> close(%)\n |> extrude(10, %)"
] ]
}, },
{ {

File diff suppressed because one or more lines are too long

View File

@ -775,15 +775,11 @@ fn generate_code_block_test(
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") { if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
client.set_base_url(addr); client.set_base_url(addr);
} }
let ws = client
.modeling()
.commands_ws(None, None, None, None, None,None, Some(false))
.await.unwrap();
let tokens = crate::token::lexer(#code_block).unwrap(); let tokens = crate::token::lexer(#code_block).unwrap();
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let ctx = crate::executor::ExecutorContext::new(ws, Default::default()).await.unwrap(); let ctx = crate::executor::ExecutorContext::new(&client, Default::default()).await.unwrap();
ctx.run(program, None).await.unwrap(); ctx.run(program, None).await.unwrap();

View File

@ -20,15 +20,10 @@ mod test_examples_show {
client.set_base_url(addr); client.set_base_url(addr);
} }
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, None, Some(false))
.await
.unwrap();
let tokens = crate::token::lexer("This is another code block.\nyes sirrr.\nshow").unwrap(); let tokens = crate::token::lexer("This is another code block.\nyes sirrr.\nshow").unwrap();
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let ctx = crate::executor::ExecutorContext::new(ws, Default::default()) let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
.await .await
.unwrap(); .unwrap();
ctx.run(program, None).await.unwrap(); ctx.run(program, None).await.unwrap();
@ -96,15 +91,10 @@ mod test_examples_show {
client.set_base_url(addr); client.set_base_url(addr);
} }
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, None, Some(false))
.await
.unwrap();
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nshow").unwrap(); let tokens = crate::token::lexer("This is code.\nIt does other shit.\nshow").unwrap();
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let ctx = crate::executor::ExecutorContext::new(ws, Default::default()) let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
.await .await
.unwrap(); .unwrap();
ctx.run(program, None).await.unwrap(); ctx.run(program, None).await.unwrap();

View File

@ -20,15 +20,10 @@ mod test_examples_show {
client.set_base_url(addr); client.set_base_url(addr);
} }
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, None, Some(false))
.await
.unwrap();
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nshow").unwrap(); let tokens = crate::token::lexer("This is code.\nIt does other shit.\nshow").unwrap();
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let ctx = crate::executor::ExecutorContext::new(ws, Default::default()) let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
.await .await
.unwrap(); .unwrap();
ctx.run(program, None).await.unwrap(); ctx.run(program, None).await.unwrap();

View File

@ -20,16 +20,11 @@ mod test_examples_my_func {
client.set_base_url(addr); client.set_base_url(addr);
} }
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, None, Some(false))
.await
.unwrap();
let tokens = let tokens =
crate::token::lexer("This is another code block.\nyes sirrr.\nmyFunc").unwrap(); crate::token::lexer("This is another code block.\nyes sirrr.\nmyFunc").unwrap();
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let ctx = crate::executor::ExecutorContext::new(ws, Default::default()) let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
.await .await
.unwrap(); .unwrap();
ctx.run(program, None).await.unwrap(); ctx.run(program, None).await.unwrap();
@ -97,15 +92,10 @@ mod test_examples_my_func {
client.set_base_url(addr); client.set_base_url(addr);
} }
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, None, Some(false))
.await
.unwrap();
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nmyFunc").unwrap(); let tokens = crate::token::lexer("This is code.\nIt does other shit.\nmyFunc").unwrap();
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let ctx = crate::executor::ExecutorContext::new(ws, Default::default()) let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
.await .await
.unwrap(); .unwrap();
ctx.run(program, None).await.unwrap(); ctx.run(program, None).await.unwrap();

View File

@ -21,16 +21,11 @@ mod test_examples_import {
client.set_base_url(addr); client.set_base_url(addr);
} }
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, None, Some(false))
.await
.unwrap();
let tokens = let tokens =
crate::token::lexer("This is another code block.\nyes sirrr.\nimport").unwrap(); crate::token::lexer("This is another code block.\nyes sirrr.\nimport").unwrap();
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let ctx = crate::executor::ExecutorContext::new(ws, Default::default()) let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
.await .await
.unwrap(); .unwrap();
ctx.run(program, None).await.unwrap(); ctx.run(program, None).await.unwrap();
@ -99,15 +94,10 @@ mod test_examples_import {
client.set_base_url(addr); client.set_base_url(addr);
} }
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, None, Some(false))
.await
.unwrap();
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nimport").unwrap(); let tokens = crate::token::lexer("This is code.\nIt does other shit.\nimport").unwrap();
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let ctx = crate::executor::ExecutorContext::new(ws, Default::default()) let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
.await .await
.unwrap(); .unwrap();
ctx.run(program, None).await.unwrap(); ctx.run(program, None).await.unwrap();

View File

@ -20,16 +20,11 @@ mod test_examples_line_to {
client.set_base_url(addr); client.set_base_url(addr);
} }
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, None, Some(false))
.await
.unwrap();
let tokens = let tokens =
crate::token::lexer("This is another code block.\nyes sirrr.\nlineTo").unwrap(); crate::token::lexer("This is another code block.\nyes sirrr.\nlineTo").unwrap();
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let ctx = crate::executor::ExecutorContext::new(ws, Default::default()) let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
.await .await
.unwrap(); .unwrap();
ctx.run(program, None).await.unwrap(); ctx.run(program, None).await.unwrap();
@ -97,15 +92,10 @@ mod test_examples_line_to {
client.set_base_url(addr); client.set_base_url(addr);
} }
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, None, Some(false))
.await
.unwrap();
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nlineTo").unwrap(); let tokens = crate::token::lexer("This is code.\nIt does other shit.\nlineTo").unwrap();
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let ctx = crate::executor::ExecutorContext::new(ws, Default::default()) let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
.await .await
.unwrap(); .unwrap();
ctx.run(program, None).await.unwrap(); ctx.run(program, None).await.unwrap();

View File

@ -20,15 +20,10 @@ mod test_examples_min {
client.set_base_url(addr); client.set_base_url(addr);
} }
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, None, Some(false))
.await
.unwrap();
let tokens = crate::token::lexer("This is another code block.\nyes sirrr.\nmin").unwrap(); let tokens = crate::token::lexer("This is another code block.\nyes sirrr.\nmin").unwrap();
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let ctx = crate::executor::ExecutorContext::new(ws, Default::default()) let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
.await .await
.unwrap(); .unwrap();
ctx.run(program, None).await.unwrap(); ctx.run(program, None).await.unwrap();
@ -96,15 +91,10 @@ mod test_examples_min {
client.set_base_url(addr); client.set_base_url(addr);
} }
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, None, Some(false))
.await
.unwrap();
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nmin").unwrap(); let tokens = crate::token::lexer("This is code.\nIt does other shit.\nmin").unwrap();
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let ctx = crate::executor::ExecutorContext::new(ws, Default::default()) let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
.await .await
.unwrap(); .unwrap();
ctx.run(program, None).await.unwrap(); ctx.run(program, None).await.unwrap();

View File

@ -20,15 +20,10 @@ mod test_examples_show {
client.set_base_url(addr); client.set_base_url(addr);
} }
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, None, Some(false))
.await
.unwrap();
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nshow").unwrap(); let tokens = crate::token::lexer("This is code.\nIt does other shit.\nshow").unwrap();
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let ctx = crate::executor::ExecutorContext::new(ws, Default::default()) let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
.await .await
.unwrap(); .unwrap();
ctx.run(program, None).await.unwrap(); ctx.run(program, None).await.unwrap();

View File

@ -20,15 +20,10 @@ mod test_examples_import {
client.set_base_url(addr); client.set_base_url(addr);
} }
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, None, Some(false))
.await
.unwrap();
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nimport").unwrap(); let tokens = crate::token::lexer("This is code.\nIt does other shit.\nimport").unwrap();
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let ctx = crate::executor::ExecutorContext::new(ws, Default::default()) let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
.await .await
.unwrap(); .unwrap();
ctx.run(program, None).await.unwrap(); ctx.run(program, None).await.unwrap();

View File

@ -20,15 +20,10 @@ mod test_examples_import {
client.set_base_url(addr); client.set_base_url(addr);
} }
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, None, Some(false))
.await
.unwrap();
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nimport").unwrap(); let tokens = crate::token::lexer("This is code.\nIt does other shit.\nimport").unwrap();
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let ctx = crate::executor::ExecutorContext::new(ws, Default::default()) let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
.await .await
.unwrap(); .unwrap();
ctx.run(program, None).await.unwrap(); ctx.run(program, None).await.unwrap();

View File

@ -20,15 +20,10 @@ mod test_examples_import {
client.set_base_url(addr); client.set_base_url(addr);
} }
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, None, Some(false))
.await
.unwrap();
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nimport").unwrap(); let tokens = crate::token::lexer("This is code.\nIt does other shit.\nimport").unwrap();
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let ctx = crate::executor::ExecutorContext::new(ws, Default::default()) let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
.await .await
.unwrap(); .unwrap();
ctx.run(program, None).await.unwrap(); ctx.run(program, None).await.unwrap();

View File

@ -20,15 +20,10 @@ mod test_examples_show {
client.set_base_url(addr); client.set_base_url(addr);
} }
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, None, Some(false))
.await
.unwrap();
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nshow").unwrap(); let tokens = crate::token::lexer("This is code.\nIt does other shit.\nshow").unwrap();
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let ctx = crate::executor::ExecutorContext::new(ws, Default::default()) let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
.await .await
.unwrap(); .unwrap();
ctx.run(program, None).await.unwrap(); ctx.run(program, None).await.unwrap();

View File

@ -1013,6 +1013,8 @@ pub struct ExecutorSettings {
pub units: crate::settings::types::UnitLength, pub units: crate::settings::types::UnitLength,
/// Highlight edges of 3D objects? /// Highlight edges of 3D objects?
pub highlight_edges: bool, pub highlight_edges: bool,
/// Whether or not Screen Space Ambient Occlusion (SSAO) is enabled.
pub enable_ssao: bool,
} }
impl Default for ExecutorSettings { impl Default for ExecutorSettings {
@ -1020,6 +1022,37 @@ impl Default for ExecutorSettings {
Self { Self {
units: Default::default(), units: Default::default(),
highlight_edges: true, highlight_edges: true,
enable_ssao: false,
}
}
}
impl From<crate::settings::types::Configuration> for ExecutorSettings {
fn from(config: crate::settings::types::Configuration) -> Self {
Self {
units: config.settings.modeling.base_unit,
highlight_edges: config.settings.modeling.highlight_edges.into(),
enable_ssao: config.settings.modeling.enable_ssao.into(),
}
}
}
impl From<crate::settings::types::project::ProjectConfiguration> for ExecutorSettings {
fn from(config: crate::settings::types::project::ProjectConfiguration) -> Self {
Self {
units: config.settings.modeling.base_unit,
highlight_edges: config.settings.modeling.highlight_edges.into(),
enable_ssao: config.settings.modeling.enable_ssao.into(),
}
}
}
impl From<crate::settings::types::ModelingSettings> for ExecutorSettings {
fn from(modeling: crate::settings::types::ModelingSettings) -> Self {
Self {
units: modeling.base_unit,
highlight_edges: modeling.highlight_edges.into(),
enable_ssao: modeling.enable_ssao.into(),
} }
} }
} }
@ -1027,9 +1060,40 @@ impl Default for ExecutorSettings {
impl ExecutorContext { impl ExecutorContext {
/// Create a new default executor context. /// Create a new default executor context.
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
pub async fn new(ws: reqwest::Upgraded, settings: ExecutorSettings) -> Result<Self> { pub async fn new(client: &kittycad::Client, settings: ExecutorSettings) -> Result<Self> {
let ws = client
.modeling()
.commands_ws(
None,
None,
if settings.enable_ssao {
Some(kittycad::types::PostEffectType::Ssao)
} else {
None
},
None,
None,
None,
Some(false),
)
.await?;
let engine: Arc<Box<dyn EngineManager>> =
Arc::new(Box::new(crate::engine::conn::EngineConnection::new(ws).await?));
// Set the edge visibility.
engine
.send_modeling_cmd(
uuid::Uuid::new_v4(),
SourceRange::default(),
kittycad::types::ModelingCmd::EdgeLinesVisible {
hidden: !settings.highlight_edges,
},
)
.await?;
Ok(Self { Ok(Self {
engine: Arc::new(Box::new(crate::engine::conn::EngineConnection::new(ws).await?)), engine,
fs: Arc::new(FileManager::new()), fs: Arc::new(FileManager::new()),
stdlib: Arc::new(StdLib::new()), stdlib: Arc::new(StdLib::new()),
settings, settings,

View File

@ -49,11 +49,7 @@ async fn kcl_lsp_server(execute: bool) -> Result<crate::lsp::kcl::Backend> {
let zoo_client = new_zoo_client(); let zoo_client = new_zoo_client();
let executor_ctx = if execute { let executor_ctx = if execute {
let ws = zoo_client Some(crate::executor::ExecutorContext::new(&zoo_client, Default::default()).await?)
.modeling()
.commands_ws(None, None, None, None, None, None, Some(false))
.await?;
Some(crate::executor::ExecutorContext::new(ws, Default::default()).await?)
} else { } else {
None None
}; };

View File

@ -93,6 +93,7 @@ pub async fn pattern_linear_2d(args: Args) -> Result<MemoryItem, KclError> {
/// const part = startSketchOn('XY') /// const part = startSketchOn('XY')
/// |> circle([0,0], 2, %) /// |> circle([0,0], 2, %)
/// |> patternLinear2d({axis: [0,1], repetitions: 12, distance: 2}, %) /// |> patternLinear2d({axis: [0,1], repetitions: 12, distance: 2}, %)
/// |> extrude(1, %)
/// ``` /// ```
#[stdlib { #[stdlib {
name = "patternLinear2d", name = "patternLinear2d",
@ -341,6 +342,7 @@ pub async fn pattern_circular_2d(args: Args) -> Result<MemoryItem, KclError> {
/// const part = startSketchOn('XY') /// const part = startSketchOn('XY')
/// |> circle([0,0], 2, %) /// |> circle([0,0], 2, %)
/// |> patternCircular2d({center: [20, 20], repetitions: 12, arcDegrees: 210, rotateDuplicates: true}, %) /// |> patternCircular2d({center: [20, 20], repetitions: 12, arcDegrees: 210, rotateDuplicates: true}, %)
/// |> extrude(1, %)
/// ``` /// ```
#[stdlib { #[stdlib {
name = "patternCircular2d", name = "patternCircular2d",

View File

@ -260,6 +260,7 @@ pub async fn angle_to_match_length_x(args: Args) -> Result<MemoryItem, KclError>
/// 5 /// 5
/// ], %) /// ], %)
/// |> close(%) /// |> close(%)
/// |> extrude(5, %)
/// ``` /// ```
#[stdlib { #[stdlib {
name = "angleToMatchLengthX", name = "angleToMatchLengthX",
@ -326,6 +327,7 @@ pub async fn angle_to_match_length_y(args: Args) -> Result<MemoryItem, KclError>
/// 5 /// 5
/// ], %) /// ], %)
/// |> close(%) /// |> close(%)
/// |> extrude(5, %)
/// ``` /// ```
#[stdlib { #[stdlib {
name = "angleToMatchLengthY", name = "angleToMatchLengthY",

View File

@ -47,6 +47,7 @@ pub async fn line_to(args: Args) -> Result<MemoryItem, KclError> {
/// ///
/// // Create the mounting plate extrusion, holes, and fillets /// // Create the mounting plate extrusion, holes, and fillets
/// const part = rectShape([0, 0], 20, 20) /// const part = rectShape([0, 0], 20, 20)
/// |> extrude(10, %)
/// ``` /// ```
#[stdlib { #[stdlib {
name = "lineTo", name = "lineTo",
@ -662,6 +663,9 @@ pub async fn start_sketch_at(args: Args) -> Result<MemoryItem, KclError> {
/// ```no_run /// ```no_run
/// startSketchAt([0, 0]) /// startSketchAt([0, 0])
/// |> line([10, 10], %) /// |> line([10, 10], %)
/// |> line([20, 10], %, "edge1")
/// |> close(%, "edge2")
/// |> extrude(10, %)
/// ``` /// ```
#[stdlib { #[stdlib {
name = "startSketchAt", name = "startSketchAt",
@ -814,6 +818,7 @@ pub async fn start_sketch_on(args: Args) -> Result<MemoryItem, KclError> {
/// |> line([10, 10], %) /// |> line([10, 10], %)
/// |> line([20, 10], %, "edge1") /// |> line([20, 10], %, "edge1")
/// |> close(%, "edge2") /// |> close(%, "edge2")
/// |> extrude(10, %)
/// ``` /// ```
/// ///
/// ```no_run /// ```no_run
@ -1027,6 +1032,9 @@ pub async fn start_profile_at(args: Args) -> Result<MemoryItem, KclError> {
/// startSketchOn('XY') /// startSketchOn('XY')
/// |> startProfileAt([0, 0], %) /// |> startProfileAt([0, 0], %)
/// |> line([10, 10], %) /// |> line([10, 10], %)
/// |> line([10, 0], %)
/// |> close(%)
/// |> extrude(10, %)
/// ``` /// ```
#[stdlib { #[stdlib {
name = "startProfileAt", name = "startProfileAt",
@ -1097,6 +1105,7 @@ pub async fn close(args: Args) -> Result<MemoryItem, KclError> {
/// |> line([10, 10], %) /// |> line([10, 10], %)
/// |> line([10, 0], %) /// |> line([10, 0], %)
/// |> close(%) /// |> close(%)
/// |> extrude(10, %)
/// ``` /// ```
/// ///
/// ```no_run /// ```no_run
@ -1105,6 +1114,7 @@ pub async fn close(args: Args) -> Result<MemoryItem, KclError> {
/// |> line([10, 10], %) /// |> line([10, 10], %)
/// |> line([10, 0], %) /// |> line([10, 0], %)
/// |> close(%, "edge1") /// |> close(%, "edge1")
/// |> extrude(10, %)
/// ``` /// ```
#[stdlib { #[stdlib {
name = "close", name = "close",
@ -1411,6 +1421,7 @@ pub async fn tangential_arc_to(args: Args) -> Result<MemoryItem, KclError> {
/// |> line([10, 10], %, "edge0") /// |> line([10, 10], %, "edge0")
/// |> tangentialArcTo([10, 0], %) /// |> tangentialArcTo([10, 0], %)
/// |> close(%) /// |> close(%)
/// |> extrude(10, %)
/// ``` /// ```
#[stdlib { #[stdlib {
name = "tangentialArcTo", name = "tangentialArcTo",

View File

@ -1483,7 +1483,7 @@ const things = "things"
fn test_kitt() { fn test_kitt() {
let program = include_str!("../../../tests/executor/inputs/kittycad_svg.kcl"); let program = include_str!("../../../tests/executor/inputs/kittycad_svg.kcl");
let actual = lexer(program).unwrap(); let actual = lexer(program).unwrap();
assert_eq!(actual.len(), 5093); assert_eq!(actual.len(), 5103);
} }
#[test] #[test]
fn test_pipes_on_pipes() { fn test_pipes_on_pipes() {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 155 KiB

View File

@ -308,3 +308,4 @@ const svg = startSketchOn('XY')
|> lineTo([13.44, -13.44], %) // VerticalLineHorizonal |> lineTo([13.44, -13.44], %) // VerticalLineHorizonal
|> lineTo([14.28, -13.44], %) // HorizontalLineRelative |> lineTo([14.28, -13.44], %) // HorizontalLineRelative
|> close(%) |> close(%)
|> extrude(1, %)

View File

@ -28,11 +28,6 @@ async fn execute_and_snapshot(code: &str, units: kcl_lib::settings::types::UnitL
client.set_base_url(addr); client.set_base_url(addr);
} }
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, None, Some(false))
.await?;
// Create a temporary file to write the output to. // Create a temporary file to write the output to.
let output_file = std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4())); let output_file = std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
@ -40,10 +35,11 @@ async fn execute_and_snapshot(code: &str, units: kcl_lib::settings::types::UnitL
let parser = kcl_lib::parser::Parser::new(tokens); let parser = kcl_lib::parser::Parser::new(tokens);
let program = parser.ast()?; let program = parser.ast()?;
let ctx = kcl_lib::executor::ExecutorContext::new( let ctx = kcl_lib::executor::ExecutorContext::new(
ws, &client,
ExecutorSettings { ExecutorSettings {
units, units,
..Default::default() highlight_edges: true,
enable_ssao: false,
}, },
) )
.await?; .await?;
@ -578,12 +574,14 @@ async fn serial_test_member_expression_sketch_group() {
|> line([0, scale], %) |> line([0, scale], %)
|> line([scale, 0], %) |> line([scale, 0], %)
|> line([0, -scale], %) |> line([0, -scale], %)
|> close(%)
return sg return sg
} }
const b1 = cube([0,0], 10) const b1 = cube([0,0], 10)
const b2 = cube([3,3], 4) const b2 = cube([3,3], 4)
|> extrude(10, %)
const pt1 = b1.value[0] const pt1 = b1.value[0]
const pt2 = b2.value[0] const pt2 = b2.value[0]
@ -667,6 +665,7 @@ async fn serial_test_dimensions_match() {
|> line([0, 20], %) |> line([0, 20], %)
|> line([-20, 0], %) |> line([-20, 0], %)
|> close(%) |> close(%)
|> extrude(10, %)
"#; "#;
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm) let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
@ -887,6 +886,7 @@ async fn optional_params() {
|> startProfileAt(pos, %) |> startProfileAt(pos, %)
|> arc({angle_end: 360, angle_start: 0, radius: radius}, %) |> arc({angle_end: 360, angle_start: 0, radius: radius}, %)
|> close(%) |> close(%)
|> extrude(2, %)
return sg return sg
} }
@ -1004,6 +1004,7 @@ async fn serial_test_patterns_linear_basic_negative_distance() {
let code = r#"const part = startSketchOn('XY') let code = r#"const part = startSketchOn('XY')
|> circle([0,0], 2, %) |> circle([0,0], 2, %)
|> patternLinear2d({axis: [0,1], repetitions: 12, distance: -2}, %) |> patternLinear2d({axis: [0,1], repetitions: 12, distance: -2}, %)
|> extrude(1, %)
"#; "#;
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm) let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
@ -1021,6 +1022,7 @@ async fn serial_test_patterns_linear_basic_negative_axis() {
let code = r#"const part = startSketchOn('XY') let code = r#"const part = startSketchOn('XY')
|> circle([0,0], 2, %) |> circle([0,0], 2, %)
|> patternLinear2d({axis: [0,-1], repetitions: 12, distance: 2}, %) |> patternLinear2d({axis: [0,-1], repetitions: 12, distance: 2}, %)
|> extrude(1, %)
"#; "#;
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm) let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
@ -1046,6 +1048,7 @@ const rectangle = startSketchOn('XY')
|> line([0, -50], %) |> line([0, -50], %)
|> close(%) |> close(%)
|> hole(circles, %) |> hole(circles, %)
|> extrude(10, %)
"#; "#;
@ -1060,6 +1063,7 @@ async fn serial_test_patterns_circular_basic_2d() {
let code = r#"const part = startSketchOn('XY') let code = r#"const part = startSketchOn('XY')
|> circle([0,0], 2, %) |> circle([0,0], 2, %)
|> patternCircular2d({center: [20, 20], repetitions: 12, arcDegrees: 210, rotateDuplicates: true}, %) |> patternCircular2d({center: [20, 20], repetitions: 12, arcDegrees: 210, rotateDuplicates: true}, %)
|> extrude(1, %)
"#; "#;
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm) let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 128 KiB

View File

@ -31,15 +31,10 @@ async fn setup(code: &str, name: &str) -> Result<(ExecutorContext, Program, uuid
client.set_base_url(addr); client.set_base_url(addr);
} }
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, None, Some(false))
.await?;
let tokens = kcl_lib::token::lexer(code)?; let tokens = kcl_lib::token::lexer(code)?;
let parser = kcl_lib::parser::Parser::new(tokens); let parser = kcl_lib::parser::Parser::new(tokens);
let program = parser.ast()?; let program = parser.ast()?;
let ctx = kcl_lib::executor::ExecutorContext::new(ws, Default::default()).await?; let ctx = kcl_lib::executor::ExecutorContext::new(&client, Default::default()).await?;
let memory = ctx.run(program.clone(), None).await?; let memory = ctx.run(program.clone(), None).await?;
// We need to get the sketch ID. // We need to get the sketch ID.