diff --git a/docs/kcl/std.json b/docs/kcl/std.json index 84ae5f226..47324ce82 100644 --- a/docs/kcl/std.json +++ b/docs/kcl/std.json @@ -211871,16 +211871,6 @@ "format": "double" } } - }, - { - "description": "A point where the arc should end. Must lie in the same plane as the current path pen position. Must not be colinear with current path pen position.", - "type": "array", - "items": { - "type": "number", - "format": "double" - }, - "maxItems": 2, - "minItems": 2 } ] }, @@ -218589,6 +218579,14 @@ }, "required": true }, + { + "name": "relative", + "type": "bool", + "schema": { + "type": "boolean" + }, + "required": true + }, { "name": "sketch_group", "type": "SketchGroup", diff --git a/docs/kcl/tangentialArc.md b/docs/kcl/tangentialArc.md index 20769d09d..baab5bc59 100644 --- a/docs/kcl/tangentialArc.md +++ b/docs/kcl/tangentialArc.md @@ -37,8 +37,7 @@ const example = extrude(10, exampleSketch) offset: number, // Radius of the arc. Not to be confused with Raiders of the Lost Ark. radius: number, -} | -[number, number] +} ``` * `sketch_group`: `SketchGroup` - A sketch group is a collection of paths. (REQUIRED) ```js diff --git a/docs/kcl/tangentialArcTo.md b/docs/kcl/tangentialArcTo.md index 8ad844e01..754edea78 100644 --- a/docs/kcl/tangentialArcTo.md +++ b/docs/kcl/tangentialArcTo.md @@ -9,7 +9,7 @@ Starting at the current sketch's origin, draw a curved line segment along some part of an imaginary circle until it reaches the desired (x, y) coordinates. ```js -tangentialArcTo(to: [number], sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup +tangentialArcTo(to: [number], relative: bool, sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup ``` ### Examples @@ -30,6 +30,7 @@ const example = extrude(10, exampleSketch) ### Arguments * `to`: `[number]` (REQUIRED) +* `relative`: `bool` (REQUIRED) * `sketch_group`: `SketchGroup` - A sketch group is a collection of paths. (REQUIRED) ```js { diff --git a/src/wasm-lib/kcl/src/std/args.rs b/src/wasm-lib/kcl/src/std/args.rs index 1d428b35e..de8389c1a 100644 --- a/src/wasm-lib/kcl/src/std/args.rs +++ b/src/wasm-lib/kcl/src/std/args.rs @@ -5,7 +5,7 @@ use serde::de::DeserializeOwned; use super::{shapes::SketchSurfaceOrGroup, sketch::FaceTag, FnAsArg}; use crate::{ - ast::types::{parse_json_number_as_f64, TagDeclarator}, + ast::types::{parse_json_number_as_f64, KclNone, TagDeclarator}, errors::{KclError, KclErrorDetails}, executor::{ DynamicState, ExecutorContext, ExtrudeGroup, ExtrudeGroupSet, ExtrudeSurface, MemoryItem, Metadata, @@ -479,11 +479,15 @@ where { fn from_args(args: &'a Args, i: usize) -> Result { let Some(arg) = args.args.get(i) else { return Ok(None) }; + if let Some(_kcl_none) = KclNone::from_mem_item(arg) { + return Ok(None); + } let Some(val) = T::from_mem_item(arg) else { return Err(KclError::Semantic(KclErrorDetails { message: format!( - "Argument at index {i} was supposed to be type {} but wasn't", - type_name::() + "Argument at index {i} was supposed to be type {} but wasn't, it was {:?}", + type_name::(), + arg, ), source_ranges: vec![args.source_range], })); @@ -615,6 +619,7 @@ impl_from_arg_via_json!(u32); impl_from_arg_via_json!(u64); impl_from_arg_via_json!(f64); impl_from_arg_via_json!(bool); +impl_from_arg_via_json!(KclNone); impl_from_arg_for_array!(2); impl_from_arg_for_array!(3); diff --git a/src/wasm-lib/kcl/src/std/sketch.rs b/src/wasm-lib/kcl/src/std/sketch.rs index c65d59dd2..99388b622 100644 --- a/src/wasm-lib/kcl/src/std/sketch.rs +++ b/src/wasm-lib/kcl/src/std/sketch.rs @@ -1787,7 +1787,7 @@ pub async fn tangential_arc_to(args: Args) -> Result { /// angle: 60, /// length: 10, /// }, %) -/// |> tangentialArcTo([15, 15], %) +/// |> tangentialArcTo([15, 15], false, %) /// |> line([10, -15], %) /// |> close(%) /// diff --git a/src/wasm-lib/tests/executor/inputs/i_shape.kcl b/src/wasm-lib/tests/executor/inputs/i_shape.kcl index e35de7f12..d603d07bf 100644 --- a/src/wasm-lib/tests/executor/inputs/i_shape.kcl +++ b/src/wasm-lib/tests/executor/inputs/i_shape.kcl @@ -9,40 +9,40 @@ let corner_radius = 5.0 // 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], %) + |> tangentialArcTo([corner_radius, corner_radius], true, %) |> yLine(25.0 - corner_radius, %) - |> tangentialArc([-corner_radius, corner_radius], %) + |> tangentialArcTo([-corner_radius, corner_radius], true, %) |> xLine(-(d_wrist_circumference[0] - (corner_radius * 2)), %) - |> tangentialArc([-corner_radius, corner_radius], %) + |> tangentialArcTo([-corner_radius, corner_radius], true, %) |> yLine(length - 25.0 - 23.0 - (corner_radius * 2), %) - |> tangentialArc([corner_radius, corner_radius], %) + |> tangentialArcTo([corner_radius, corner_radius], true, %) |> xLine(15.0 - (corner_radius * 2), %) - |> tangentialArc([corner_radius, corner_radius], %) + |> tangentialArcTo([corner_radius, corner_radius], true, %) |> yLine(23.0 - corner_radius, %) - |> tangentialArc([-corner_radius, corner_radius], %) + |> tangentialArcTo([-corner_radius, corner_radius], true, %) |> xLine(-(hand_thickness + 15.0 + 15.0 - (corner_radius * 2)), %) - |> tangentialArc([-corner_radius, -corner_radius], %) + |> tangentialArcTo([-corner_radius, -corner_radius], true, %) |> yLine(-(23.0 - corner_radius), %) - |> tangentialArc([corner_radius, -corner_radius], %) + |> tangentialArcTo([corner_radius, -corner_radius], true, %) |> xLine(15.0 - (corner_radius * 2), %) - |> tangentialArc([corner_radius, -corner_radius], %) + |> tangentialArcTo([corner_radius, -corner_radius], true, %) |> yLine(-(length - 25.0 - 23.0 - (corner_radius * 2)), %) - |> tangentialArc([-corner_radius, -corner_radius], %) + |> tangentialArcTo([-corner_radius, -corner_radius], true, %) |> xLine(-(d_wrist_circumference[1] + d_wrist_circumference[2] + d_wrist_circumference[3] - hand_thickness - corner_radius), %) - |> tangentialArc([-corner_radius, -corner_radius], %) + |> tangentialArcTo([-corner_radius, -corner_radius], true, %) |> yLine(-(25.0 - corner_radius), %) - |> tangentialArc([corner_radius, -corner_radius], %) + |> tangentialArcTo([corner_radius, -corner_radius], true, %) |> close(%) let inner = startSketchAt([0, 0]) |> xLine(1.0, %) - |> tangentialArc([corner_radius, corner_radius], %) + |> tangentialArcTo([corner_radius, corner_radius], true, %) |> yLine(25.0 - (corner_radius * 2), %) - |> tangentialArc([-corner_radius, corner_radius], %) + |> tangentialArcTo([-corner_radius, corner_radius], true, %) |> xLine(-1.0, %) - |> tangentialArc([-corner_radius, -corner_radius], %) + |> tangentialArcTo([-corner_radius, -corner_radius], true, %) |> yLine(-(25.0 - (corner_radius * 2)), %) - |> tangentialArc([corner_radius, -corner_radius], %) + |> tangentialArcTo([corner_radius, -corner_radius], true, %) |> close(%) let final = brace_base diff --git a/src/wasm-lib/tests/executor/main.rs b/src/wasm-lib/tests/executor/main.rs index 173a1fc0c..75c8865f3 100644 --- a/src/wasm-lib/tests/executor/main.rs +++ b/src/wasm-lib/tests/executor/main.rs @@ -317,7 +317,7 @@ async fn kcl_test_basic_tangential_arc() { async fn kcl_test_basic_tangential_arc_with_point() { let code = r#"const boxSketch = startSketchAt([0, 0]) |> line([0, 10], %) - |> tangentialArc([-5, 5], %) + |> tangentialArcTo([-5, 5], true, %) |> line([5, -15], %) |> extrude(10, %) "#; @@ -330,7 +330,7 @@ async fn kcl_test_basic_tangential_arc_with_point() { async fn kcl_test_basic_tangential_arc_to() { let code = r#"const boxSketch = startSketchAt([0, 0]) |> line([0, 10], %) - |> tangentialArcTo([-5, 15], %) + |> tangentialArcTo([-5, 15], false, %) |> line([5, -15], %) |> extrude(10, %) "#; @@ -463,7 +463,7 @@ const thing = other_circle([2, 2], 20) #[tokio::test(flavor = "multi_thread")] async fn kcl_test_rounded_with_holes() { let code = r#"fn tarc = (to, sketchGroup, tag?) => { - return tangentialArcTo(to, sketchGroup, tag) + return tangentialArcTo(to, false, sketchGroup, tag) } fn roundedRectangle = (pos, w, l, cornerRadius) => { @@ -1530,7 +1530,7 @@ async fn kcl_test_error_empty_start_sketch_on_string() { |> line([190.03, -118.13], %) |> line([-33.38, -202.86], %) |> line([-315.86, -64.2], %) - |> tangentialArcTo([-147.66, 121.34], %) + |> tangentialArcTo([-147.66, 121.34], false, %) |> close(%) |> extrude(100, %) diff --git a/src/wasm-lib/tests/executor/outputs/rounded_with_holes.png b/src/wasm-lib/tests/executor/outputs/rounded_with_holes.png index 851aa68ff..644272519 100644 Binary files a/src/wasm-lib/tests/executor/outputs/rounded_with_holes.png and b/src/wasm-lib/tests/executor/outputs/rounded_with_holes.png differ