Skip to content

Commit 238c9f2

Browse files
authored
Change to accept uppercase strings for extrude method (#7874)
* Change to accept uppercase strings for extrude method * Add example test that uses method NEW * Update docs
1 parent d3303e3 commit 238c9f2

File tree

5 files changed

+49
-3
lines changed

5 files changed

+49
-3
lines changed

docs/kcl-std/functions/std-sketch-extrude.md

Lines changed: 24 additions & 0 deletions
Large diffs are not rendered by default.

rust/kcl-derive-docs/src/example_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ pub const TEST_NAMES: &[&str] = &[
128128
"std-sketch-extrude-2",
129129
"std-sketch-extrude-3",
130130
"std-sketch-extrude-4",
131+
"std-sketch-extrude-5",
131132
"std-sketch-polygon-0",
132133
"std-sketch-polygon-1",
133134
"std-sketch-sweep-0",

rust/kcl-lib/src/std/extrude.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ async fn inner_extrude(
8484
let tolerance = LengthUnit(tolerance.as_ref().map(|t| t.to_mm()).unwrap_or(DEFAULT_TOLERANCE_MM));
8585

8686
let extrude_method = match method.as_deref() {
87-
Some("new") => ExtrudeMethod::New,
88-
Some("merge") => ExtrudeMethod::Merge,
87+
Some("new" | "NEW") => ExtrudeMethod::New,
88+
Some("merge" | "MERGE") => ExtrudeMethod::Merge,
8989
None => ExtrudeMethod::default(),
9090
Some(other) => {
9191
return Err(KclError::new_semantic(KclErrorDetails::new(
92-
format!("Unknown merge method {other}, try using MERGE or NEW"),
92+
format!("Unknown merge method {other}, try using `MERGE` or `NEW`"),
9393
vec![args.source_range],
9494
)));
9595
}

rust/kcl-lib/std/sketch.kcl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,27 @@ export fn ellipse(
443443
/// |> polygon(radius = 10, numSides = 3, center = [0, 0])
444444
/// |> extrude(length = 10, twistAngle = 120deg)
445445
/// ```
446+
///
447+
/// ```kcl
448+
/// sketch001 = startSketchOn(XY)
449+
/// profile001 = startProfile(sketch001, at = [0, 0])
450+
/// |> yLine(length = 1)
451+
/// |> xLine(length = 1)
452+
/// |> yLine(length = -1)
453+
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
454+
/// |> close()
455+
/// cube = extrude(profile001, length = 1)
456+
///
457+
/// sketch002 = startSketchOn(cube, face = END)
458+
/// profile002 = circle(sketch002, center = [0.38, 0.64], radius = 0.13)
459+
/// // When sketching on a face, we can make a new solid instead of merging with
460+
/// // it by using the method parameter.
461+
/// cylinder = extrude(profile002, length = 2, method = NEW)
462+
///
463+
/// // The cylinder is a separate solid that can be translated separately from
464+
/// // the cube.
465+
/// translate(cylinder, x = 1)
466+
/// ```
446467
@(impl = std_rust)
447468
export fn extrude(
448469
/// Which sketch or sketches should be extruded.
48.7 KB
Loading

0 commit comments

Comments
 (0)