fix variable in pipe start (#1932)
Signed-off-by: Jess Frazelle <github@jessfraz.com>
@ -51189,6 +51189,7 @@
|
||||
"deprecated": false,
|
||||
"examples": [
|
||||
"const part001 = 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 |> revolve({ axis: 'y' }, %) // default angle is 360",
|
||||
"// A donut shape.\nconst sketch001 = startSketchOn('XY')\n |> circle([15, 0], 5, %)\n |> revolve({ angle: 360, axis: 'y' }, %)",
|
||||
"const part001 = 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 |> revolve({ axis: 'y', angle: 180 }, %)",
|
||||
"const box = startSketchOn('XY')\n |> startProfileAt([0, 0], %)\n |> line([0, 20], %)\n |> line([20, 0], %)\n |> line([0, -20], %)\n |> close(%)\n |> extrude(20, %)\n\nconst sketch001 = startSketchOn(box, \"END\")\n |> circle([10, 10], 4, %)\n |> revolve({ angle: -90, axis: 'y' }, %)",
|
||||
"const box = startSketchOn('XY')\n |> startProfileAt([0, 0], %)\n |> line([0, 20], %)\n |> line([20, 0], %)\n |> line([0, -20], %, 'revolveAxis')\n |> close(%)\n |> extrude(20, %)\n\nconst sketch001 = startSketchOn(box, \"END\")\n |> circle([10, 10], 4, %)\n |> revolve({\n angle: 90,\n axis: getOppositeEdge('revolveAxis', box)\n }, %)"
|
||||
|
@ -2743,6 +2743,12 @@ async fn execute_pipe_body(
|
||||
pipe_info.body = body.to_vec();
|
||||
call_expression.execute(memory, pipe_info, ctx).await
|
||||
}
|
||||
Value::Identifier(identifier) => {
|
||||
let result = memory.get(&identifier.name, identifier.into())?;
|
||||
pipe_info.previous_results.push(result.clone());
|
||||
pipe_info.index += 1;
|
||||
execute_pipe_body(memory, body, pipe_info, source_range, ctx).await
|
||||
}
|
||||
_ => {
|
||||
// Return an error this should not happen.
|
||||
Err(KclError::Semantic(KclErrorDetails {
|
||||
|
@ -123,6 +123,16 @@ pub async fn revolve(args: Args) -> Result<MemoryItem, KclError> {
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
/// // A donut shape.
|
||||
/// const sketch001 = startSketchOn('XY')
|
||||
/// |> circle([15, 0], 5, %)
|
||||
/// |> revolve({
|
||||
/// angle: 360,
|
||||
/// axis: 'y'
|
||||
/// }, %)
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
/// const part001 = startSketchOn('XY')
|
||||
/// |> startProfileAt([4, 12], %)
|
||||
/// |> line([2, 0], %)
|
||||
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 149 KiB |
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 106 KiB |
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 119 KiB |
BIN
src/wasm-lib/kcl/tests/outputs/serial_test_example_revolve4.png
Normal file
After Width: | Height: | Size: 117 KiB |
51
src/wasm-lib/tests/executor/inputs/i_shape.kcl
Normal file
@ -0,0 +1,51 @@
|
||||
let d_wrist_circumference = [22.8, 10.7, 16.4, 18.5]
|
||||
let width = d_wrist_circumference[0] + d_wrist_circumference[1] + d_wrist_circumference[2] + d_wrist_circumference[3]
|
||||
let length = 120.0
|
||||
let hand_thickness = 24.0
|
||||
let corner_radius = 5.0
|
||||
|
||||
// At first I thought this was going to be symmetric,
|
||||
// but I measured intentionally to not be symmetric,
|
||||
// because your wrist isn't a perfect cylindrical surface
|
||||
let brace_base = startSketchAt([corner_radius, 0])
|
||||
|> line([width - corner_radius, 0.0], %)
|
||||
|> tangentialArc([corner_radius, corner_radius], %)
|
||||
|> yLine(25.0 - corner_radius, %)
|
||||
|> tangentialArc([-corner_radius, corner_radius], %)
|
||||
|> xLine(-(d_wrist_circumference[0] - (corner_radius * 2)), %)
|
||||
|> tangentialArc([-corner_radius, corner_radius], %)
|
||||
|> yLine(length - 25.0 - 23.0 - (corner_radius * 2), %)
|
||||
|> tangentialArc([corner_radius, corner_radius], %)
|
||||
|> xLine(15.0 - (corner_radius * 2), %)
|
||||
|> tangentialArc([corner_radius, corner_radius], %)
|
||||
|> yLine(23.0 - corner_radius, %)
|
||||
|> tangentialArc([-corner_radius, corner_radius], %)
|
||||
|> xLine(-(hand_thickness + 15.0 + 15.0 - (corner_radius * 2)), %)
|
||||
|> tangentialArc([-corner_radius, -corner_radius], %)
|
||||
|> yLine(-(23.0 - corner_radius), %)
|
||||
|> tangentialArc([corner_radius, -corner_radius], %)
|
||||
|> xLine(15.0 - (corner_radius * 2), %)
|
||||
|> tangentialArc([corner_radius, -corner_radius], %)
|
||||
|> yLine(-(length - 25.0 - 23.0 - (corner_radius * 2)), %)
|
||||
|> tangentialArc([-corner_radius, -corner_radius], %)
|
||||
|> xLine(-(d_wrist_circumference[1] + d_wrist_circumference[2] + d_wrist_circumference[3] - hand_thickness - corner_radius), %)
|
||||
|> tangentialArc([-corner_radius, -corner_radius], %)
|
||||
|> yLine(-(25.0 - corner_radius), %)
|
||||
|> tangentialArc([corner_radius, -corner_radius], %)
|
||||
|> close(%)
|
||||
|
||||
let inner = startSketchAt([0, 0])
|
||||
|> xLine(1.0, %)
|
||||
|> tangentialArc([corner_radius, corner_radius], %)
|
||||
|> yLine(25.0 - (corner_radius * 2), %)
|
||||
|> tangentialArc([-corner_radius, corner_radius], %)
|
||||
|> xLine(-1.0, %)
|
||||
|> tangentialArc([-corner_radius, -corner_radius], %)
|
||||
|> yLine(-(25.0 - (corner_radius * 2)), %)
|
||||
|> tangentialArc([corner_radius, -corner_radius], %)
|
||||
|> close(%)
|
||||
|
||||
let final = brace_base
|
||||
|> hole(inner, %)
|
||||
|> extrude(3.0, %)
|
||||
|
@ -481,6 +481,17 @@ async fn serial_test_execute_engine_error_return() {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_execute_i_shape() {
|
||||
// This is some code from lee that starts a pipe expression with a variable.
|
||||
let code = include_str!("inputs/i_shape.kcl");
|
||||
|
||||
let result = execute_and_snapshot(code, kittycad::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/i_shape.png", &result, 0.999);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
#[ignore] // ignore until more stack fixes
|
||||
async fn serial_test_execute_pipes_on_pipes() {
|
||||
|
BIN
src/wasm-lib/tests/executor/outputs/i_shape.png
Normal file
After Width: | Height: | Size: 125 KiB |