Update some circle function calls and twenty twenty stuff

This commit is contained in:
Kurt Hutten Irev-Dev
2024-09-09 20:28:24 +10:00
parent a1dd884013
commit e794c5b0e9
19 changed files with 57 additions and 57 deletions

View File

@ -937,6 +937,6 @@ mod tests {
fn get_autocomplete_snippet_circle() {
let circle_fn: Box<dyn StdLibFn> = Box::new(crate::std::shapes::Circle);
let snippet = circle_fn.to_autocomplete_snippet().unwrap();
assert_eq!(snippet, r#"circle([${0:3.14}, ${1:3.14}], ${2:3.14}, ${3:%})${}"#);
assert_eq!(snippet, r#"circle({ center: [${0:3.14}, ${1:3.14}], radius: ${2:3.14} }, ${3:%})${}"#);
}
}

View File

@ -2589,7 +2589,7 @@ fn transform = (replicaId) => {
fn layer = () => {
return startSketchOn("XY")
|> circle([0, 0], 1, %, $tag1)
|> circle({ center: [0, 0], radius: 1 }, %, $tag1)
|> extrude(10, %)
}
@ -2717,7 +2717,7 @@ fn transform = (replicaId) => {
fn layer = () => {
return startSketchOn("XY")
|> circle([0, 0], 1, %, $tag1)
|> circle({ center: [0, 0], radius: 1 }, %, $tag1)
|> extrude(10, %)
}

View File

@ -50,7 +50,7 @@ pub async fn int(args: Args) -> Result<KclValue, KclError> {
///
/// ```no_run
/// const sketch001 = startSketchOn('XZ')
/// |> circle([0, 0], 2, %)
/// |> circle({ center: [0, 0], radius: 2 }, %)
/// const extrude001 = extrude(5, sketch001)
///
/// const pattern01 = patternTransform(int(ceil(5 / 2)), (id) => {

View File

@ -42,7 +42,7 @@ pub async fn helix(args: Args) -> Result<KclValue, KclError> {
///
/// ```no_run
/// const part001 = startSketchOn('XY')
/// |> circle([5, 5], 10, %)
/// |> circle({ center: [5, 5], radius: 10 }, %)
/// |> extrude(10, %)
/// |> helix({
/// angleStart: 0,

View File

@ -91,10 +91,10 @@ pub async fn loft(args: Args) -> Result<KclValue, KclError> {
/// |> close(%)
///
/// const circleSketch0 = startSketchOn(offsetPlane('XY', 75))
/// |> circle([0, 100], 50, %)
/// |> circle({ center: [0, 100], radius: 50 }, %)
///
/// const circleSketch1 = startSketchOn(offsetPlane('XY', 150))
/// |> circle([0, 100], 20, %)
/// |> circle({ center: [0, 100], radius: 20 }, %)
///
/// loft([squareSketch, circleSketch0, circleSketch1])
/// ```
@ -110,10 +110,10 @@ pub async fn loft(args: Args) -> Result<KclValue, KclError> {
/// |> close(%)
///
/// const circleSketch0 = startSketchOn(offsetPlane('XY', 75))
/// |> circle([0, 100], 50, %)
/// |> circle({ center: [0, 100], radius: 50 }, %)
///
/// const circleSketch1 = startSketchOn(offsetPlane('XY', 150))
/// |> circle([0, 100], 20, %)
/// |> circle({ center: [0, 100], radius: 20 }, %)
///
/// loft([squareSketch, circleSketch0, circleSketch1], {
/// // This can be set to override the automatically determined

View File

@ -113,7 +113,7 @@ pub async fn pi(args: Args) -> Result<KclValue, KclError> {
/// const circumference = 70
///
/// const exampleSketch = startSketchOn("XZ")
/// |> circle([0, 0], circumference/ (2 * pi()), %)
/// |> circle({ center: [0, 0], radius: circumference/ (2 * pi()) }, %)
///
/// const example = extrude(5, exampleSketch)
/// ```

View File

@ -117,7 +117,7 @@ pub async fn pattern_transform(args: Args) -> Result<KclValue, KclError> {
/// // Each layer is just a pretty thin cylinder.
/// fn layer = () => {
/// return startSketchOn("XY") // or some other plane idk
/// |> circle([0, 0], 1, %, $tag1)
/// |> circle({ center: [0, 0], radius: 1 }, %, $tag1)
/// |> extrude(h, %)
/// }
/// // The vase is 100 layers tall.
@ -318,7 +318,7 @@ pub async fn pattern_linear_2d(args: Args) -> Result<KclValue, KclError> {
///
/// ```no_run
/// const exampleSketch = startSketchOn('XZ')
/// |> circle([0, 0], 1, %)
/// |> circle({ center: [0, 0], radius: 1 }, %)
/// |> patternLinear2d({
/// axis: [1, 0],
/// repetitions: 6,
@ -651,7 +651,7 @@ pub async fn pattern_circular_3d(args: Args) -> Result<KclValue, KclError> {
///
/// ```no_run
/// const exampleSketch = startSketchOn('XZ')
/// |> circle([0, 0], 1, %)
/// |> circle({ center: [0, 0], radius: 1 }, %)
///
/// const example = extrude(-5, exampleSketch)
/// |> patternCircular3d({

View File

@ -77,7 +77,7 @@ pub async fn offset_plane(args: Args) -> Result<KclValue, KclError> {
/// |> close(%)
///
/// const circleSketch = startSketchOn(offsetPlane('XY', 150))
/// |> circle([0, 100], 50, %)
/// |> circle({ center: [0, 100], radius: 50 }, %)
///
/// loft([squareSketch, circleSketch])
/// ```
@ -93,7 +93,7 @@ pub async fn offset_plane(args: Args) -> Result<KclValue, KclError> {
/// |> close(%)
///
/// const circleSketch = startSketchOn(offsetPlane('XZ', 150))
/// |> circle([0, 100], 50, %)
/// |> circle({ center: [0, 100], radius: 50 }, %)
///
/// loft([squareSketch, circleSketch])
/// ```
@ -109,7 +109,7 @@ pub async fn offset_plane(args: Args) -> Result<KclValue, KclError> {
/// |> close(%)
///
/// const circleSketch = startSketchOn(offsetPlane('YZ', 150))
/// |> circle([0, 100], 50, %)
/// |> circle({ center: [0, 100], radius: 50 }, %)
///
/// loft([squareSketch, circleSketch])
/// ```
@ -125,7 +125,7 @@ pub async fn offset_plane(args: Args) -> Result<KclValue, KclError> {
/// |> close(%)
///
/// const circleSketch = startSketchOn(offsetPlane('-XZ', -150))
/// |> circle([0, 100], 50, %)
/// |> circle({ center: [0, 100], radius: 50 }, %)
///
/// loft([squareSketch, circleSketch])
/// ```

View File

@ -133,7 +133,7 @@ pub async fn revolve(args: Args) -> Result<KclValue, KclError> {
/// ```no_run
/// // A donut shape.
/// const sketch001 = startSketchOn('XY')
/// |> circle([15, 0], 5, %)
/// |> circle({ center: [15, 0], radius: 5 }, %)
/// |> revolve({
/// angle: 360,
/// axis: 'y'
@ -185,7 +185,7 @@ pub async fn revolve(args: Args) -> Result<KclValue, KclError> {
/// |> extrude(20, %)
///
/// const sketch001 = startSketchOn(box, "END")
/// |> circle([10,10], 4, %)
/// |> circle({ center: [10,10], radius: 4 }, %)
/// |> revolve({
/// angle: -90,
/// axis: 'y'
@ -202,7 +202,7 @@ pub async fn revolve(args: Args) -> Result<KclValue, KclError> {
/// |> extrude(20, %)
///
/// const sketch001 = startSketchOn(box, "END")
/// |> circle([10,10], 4, %)
/// |> circle({ center: [10,10], radius: 4 }, %)
/// |> revolve({
/// angle: 90,
/// axis: getOppositeEdge(revolveAxis)
@ -219,7 +219,7 @@ pub async fn revolve(args: Args) -> Result<KclValue, KclError> {
/// |> extrude(20, %)
///
/// const sketch001 = startSketchOn(box, "END")
/// |> circle([10,10], 4, %)
/// |> circle({ center: [10,10], radius: 4 }, %)
/// |> revolve({
/// angle: 90,
/// axis: getOppositeEdge(revolveAxis),

View File

@ -48,7 +48,7 @@ pub async fn circle(args: Args) -> Result<KclValue, KclError> {
///
/// ```no_run
/// const exampleSketch = startSketchOn("-XZ")
/// |> circle([0, 0], 10, %)
/// |> circle({ center: [0, 0], radius: 10 }, %)
///
/// const example = extrude(5, exampleSketch)
/// ```
@ -60,7 +60,7 @@ pub async fn circle(args: Args) -> Result<KclValue, KclError> {
/// |> line([0, 30], %)
/// |> line([-30, 0], %)
/// |> close(%)
/// |> hole(circle([0, 15], 5, %), %)
/// |> hole(circle({ center: [0, 15], radius: 5 }, %), %)
///
/// const example = extrude(5, exampleSketch)
/// ```

View File

@ -2059,8 +2059,8 @@ pub async fn hole(args: Args) -> Result<KclValue, KclError> {
/// |> line([5, 0], %)
/// |> line([0, -5], %)
/// |> close(%)
/// |> hole(circle([1, 1], .25, %), %)
/// |> hole(circle([1, 4], .25, %), %)
/// |> hole(circle({ center: [1, 1], radius: .25 }, %), %)
/// |> hole(circle({ center: [1, 4], radius: .25 }, %), %)
///
/// const example = extrude(1, exampleSketch)
/// ```
@ -2077,7 +2077,7 @@ pub async fn hole(args: Args) -> Result<KclValue, KclError> {
/// }
///
/// const exampleSketch = startSketchOn('-XZ')
/// |> circle([0, 0], 3, %)
/// |> circle({ center: [0, 0], radius: 3 }, %)
/// |> hole(squareHoleSketch(), %)
/// const example = extrude(1, exampleSketch)
/// ```

View File

@ -1028,10 +1028,10 @@ const tabs_r = startSketchOn({
|> line([0, -10], %)
|> line([-10, -5], %)
|> close(%)
|> hole(circle([
|> hole(circle({ center: [
width / 2 + thk + hole_diam,
length / 2 - hole_diam
], hole_diam / 2, %), %)
], radius: hole_diam / 2 }, %), %)
|> extrude(-thk, %)
|> patternLinear3d({
axis: [0, -1, 0],
@ -1052,10 +1052,10 @@ const tabs_l = startSketchOn({
|> line([0, -10], %)
|> line([10, -5], %)
|> close(%)
|> hole(circle([
|> hole(circle({ center: [
-width / 2 - thk - hole_diam,
length / 2 - hole_diam
], hole_diam / 2, %), %)
], radius: hole_diam / 2 }, %), %)
|> extrude(-thk, %)
|> patternLinear3d({
axis: [0, -1, 0],
@ -1148,10 +1148,10 @@ const tabs_r = startSketchOn({
|> line([0, -10], %)
|> line([-10, -5], %)
|> close(%)
|> hole(circle([
|> hole(circle({ center: [
width / 2 + thk + hole_diam,
length / 2 - hole_diam
], hole_diam / 2, %), %)
], radius: hole_diam / 2 }, %), %)
|> extrude(-thk, %)
|> patternLinear3d({
axis: [0, -1, 0],
@ -1172,10 +1172,10 @@ const tabs_l = startSketchOn({
|> line([0, -10], %)
|> line([10, -5], %)
|> close(%)
|> hole(circle([
|> hole(circle({ center: [
-width / 2 - thk - hole_diam,
length / 2 - hole_diam
], hole_diam / 2, %), %)
], radius: hole_diam / 2 }, %), %)
|> extrude(-thk, %)
|> patternLinear3d({
axis: [0, -1, 0],

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 KiB

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 KiB

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 102 KiB

View File

@ -301,8 +301,8 @@ async fn kcl_test_holes() {
|> line([10, 0], %)
|> line([0, -10], %)
|> close(%)
|> hole(circle([2, 2], .5, %), %)
|> hole(circle([2, 8], .5, %), %)
|> hole(circle({ center: [2, 2], radius: .5 }, %), %)
|> hole(circle({ center: [2, 8], radius: .5 }, %), %)
|> extrude(2, %)
"#;
@ -354,10 +354,10 @@ const holeRadius = 1
const holeIndex = 6
const part = roundedRectangle([0, 0], 20, 20, 4)
|> hole(circle([-holeIndex, holeIndex], holeRadius, %), %)
|> hole(circle([holeIndex, holeIndex], holeRadius, %), %)
|> hole(circle([-holeIndex, -holeIndex], holeRadius, %), %)
|> hole(circle([holeIndex, -holeIndex], holeRadius, %), %)
|> hole(circle({ center: [-holeIndex, holeIndex], radius: holeRadius }, %), %)
|> hole(circle({ center: [holeIndex, holeIndex], radius: holeRadius }, %), %)
|> hole(circle({ center: [-holeIndex, -holeIndex], radius: holeRadius }, %), %)
|> hole(circle({ center: [holeIndex, -holeIndex], radius: holeRadius }, %), %)
|> extrude(2, %)
"#;
@ -367,7 +367,7 @@ const part = roundedRectangle([0, 0], 20, 20, 4)
#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_top_level_expression() {
let code = r#"startSketchOn('XY') |> circle([0,0], 22, %) |> extrude(14, %)"#;
let code = r#"startSketchOn('XY') |> circle({ center: [0,0], radius: 22 }, %) |> extrude(14, %)"#;
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
assert_out("top_level_expression", &result);
@ -378,7 +378,7 @@ async fn kcl_test_patterns_linear_basic_with_math() {
let code = r#"const num = 12
const distance = 5
const part = startSketchOn('XY')
|> circle([0,0], 2, %)
|> circle({ center: [0,0], radius: 2 }, %)
|> patternLinear2d({axis: [0,1], repetitions: num -1, distance: distance - 1}, %)
|> extrude(1, %)
"#;
@ -390,7 +390,7 @@ const part = startSketchOn('XY')
#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_patterns_linear_basic() {
let code = r#"const part = startSketchOn('XY')
|> circle([0,0], 2, %)
|> circle({ center: [0,0], radius: 2 }, %)
|> patternLinear2d({axis: [0,1], repetitions: 12, distance: 4}, %)
|> extrude(1, %)
"#;
@ -418,7 +418,7 @@ async fn kcl_test_patterns_linear_basic_3d() {
#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_patterns_linear_basic_negative_distance() {
let code = r#"const part = startSketchOn('XY')
|> circle([0,0], 2, %)
|> circle({ center: [0,0], radius: 2 }, %)
|> patternLinear2d({axis: [0,1], repetitions: 12, distance: -2}, %)
|> extrude(1, %)
"#;
@ -430,7 +430,7 @@ async fn kcl_test_patterns_linear_basic_negative_distance() {
#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_patterns_linear_basic_negative_axis() {
let code = r#"const part = startSketchOn('XY')
|> circle([0,0], 2, %)
|> circle({ center: [0,0], radius: 2 }, %)
|> patternLinear2d({axis: [0,-1], repetitions: 12, distance: 2}, %)
|> extrude(1, %)
"#;
@ -442,7 +442,7 @@ async fn kcl_test_patterns_linear_basic_negative_axis() {
#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_patterns_linear_basic_holes() {
let code = r#"const circles = startSketchOn('XY')
|> circle([5, 5], 1, %)
|> circle({ center: [5, 5], radius: 1 }, %)
|> patternLinear2d({axis: [1,1], repetitions: 12, distance: 3}, %)
const rectangle = startSketchOn('XY')
@ -463,7 +463,7 @@ const rectangle = startSketchOn('XY')
#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_patterns_circular_basic_2d() {
let code = r#"const part = startSketchOn('XY')
|> circle([0,0], 2, %)
|> circle({ center: [0,0], radius: 2 }, %)
|> patternCircular2d({center: [20, 20], repetitions: 12, arcDegrees: 210, rotateDuplicates: true}, %)
|> extrude(1, %)
"#;
@ -787,8 +787,8 @@ async fn kcl_test_stdlib_kcl_error_right_code_path() {
|> line([10, 0], %)
|> line([0, -10], %)
|> close(%)
|> hole(circle([2, 2], .5), %)
|> hole(circle([2, 8], .5, %), %)
|> hole(circle({ center: [2, 2], radius: .5 }), %)
|> hole(circle({ center: [2, 8], radius: .5 }, %), %)
|> extrude(2, %)
"#;
@ -816,7 +816,7 @@ const part001 = cube([0,0], 20)
|> extrude(20, %)
const part002 = startSketchOn(part001, "end")
|> circle([0, 0], 5, %)
|> circle({ center: [0, 0], radius: 5 }, %)
|> extrude(5, %)
"#;
@ -1085,7 +1085,7 @@ async fn kcl_test_revolve_on_face_circle_edge() {
|> extrude(20, %)
const sketch001 = startSketchOn(box, "END")
|> circle([10,10], 4, %)
|> circle({ center: [10,10], radius: 4 }, %)
|> revolve({
angle: 90,
axis: getOppositeEdge(revolveAxis)
@ -1107,7 +1107,7 @@ async fn kcl_test_revolve_on_face_circle() {
|> extrude(20, %)
const sketch001 = startSketchOn(box, "END")
|> circle([10,10], 4, %)
|> circle({ center: [10,10], radius: 4 }, %)
|> revolve({
angle: -90,
axis: 'y'
@ -1147,7 +1147,7 @@ const sketch001 = startSketchOn(box, "end")
#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_basic_revolve_circle() {
let code = r#"const sketch001 = startSketchOn('XY')
|> circle([15, 0], 5, %)
|> circle({ center: [15, 0], radius: 5 }, %)
|> revolve({
angle: 360,
axis: 'y'
@ -1271,10 +1271,10 @@ async fn kcl_test_member_expression_in_params() {
z_axis: { x: 0, y: 1, z: 0 }
}
})
|> circle([0, 0], capDia / 2, %)
|> circle({ center: [0, 0], radius: capDia / 2 }, %)
|> extrude(capHeadLength, %)
const screw = startSketchOn(screwHead, "start")
|> circle([0, 0], dia / 2, %)
|> circle({ center: [0, 0], radius: dia / 2 }, %)
|> extrude(length, %)
return screw
}
@ -1343,7 +1343,7 @@ async fn kcl_test_error_empty_start_sketch_on_string() {
|> extrude(100, %)
const secondSketch = startSketchOn(part001, '')
|> circle([-20, 50], 40, %)
|> circle({ center: [-20, 50], radius: 40 }, %)
|> extrude(20, %)
"#;
@ -1373,7 +1373,7 @@ fn squareHole = (l, w) => {
}
const extrusion = startSketchOn('XY')
|> circle([0, 0], dia/2, %)
|> circle({ center: [0, 0], radius: dia/2 }, %)
|> hole(squareHole(length, width, height), %)
|> extrude(height, %)
"#;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 0 B