Skip to content

Commit

Permalink
add more shell samples (#3861)
Browse files Browse the repository at this point in the history
* add more shell sampels

Signed-off-by: Jess Frazelle <[email protected]>

* docs

Signed-off-by: Jess Frazelle <[email protected]>

---------

Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Sep 11, 2024
1 parent 78ceba6 commit a00800b
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 3 deletions.
72 changes: 72 additions & 0 deletions docs/kcl/shell.md

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions docs/kcl/std.json
Original file line number Diff line number Diff line change
Expand Up @@ -207809,9 +207809,12 @@
"unpublished": false,
"deprecated": false,
"examples": [
"const firstSketch = startSketchOn('XY')\n |> startProfileAt([-12, 12], %)\n |> line([24, 0], %)\n |> line([0, -24], %)\n |> line([-24, 0], %)\n |> close(%)\n |> extrude(6, %)\n\n// Remove the end face for the extrusion.\nshell({ faces: ['end'], thickness: 0.25 }, firstSketch)",
"const firstSketch = startSketchOn('-XZ')\n |> startProfileAt([-12, 12], %)\n |> line([24, 0], %)\n |> line([0, -24], %)\n |> line([-24, 0], %)\n |> close(%)\n |> extrude(6, %)\n\n// Remove the start face for the extrusion.\nshell({ faces: ['start'], thickness: 0.25 }, firstSketch)",
"const firstSketch = startSketchOn('XY')\n |> startProfileAt([-12, 12], %)\n |> line([24, 0], %)\n |> line([0, -24], %)\n |> line([-24, 0], %, $myTag)\n |> close(%)\n |> extrude(6, %)\n\n// Remove a tagged face for the extrusion.\nshell({ faces: [myTag], thickness: 0.25 }, firstSketch)"
"// Remove the end face for the extrusion.\nconst firstSketch = startSketchOn('XY')\n |> startProfileAt([-12, 12], %)\n |> line([24, 0], %)\n |> line([0, -24], %)\n |> line([-24, 0], %)\n |> close(%)\n |> extrude(6, %)\n\n// Remove the end face for the extrusion.\nshell({ faces: ['end'], thickness: 0.25 }, firstSketch)",
"// Remove the start face for the extrusion.\nconst firstSketch = startSketchOn('-XZ')\n |> startProfileAt([-12, 12], %)\n |> line([24, 0], %)\n |> line([0, -24], %)\n |> line([-24, 0], %)\n |> close(%)\n |> extrude(6, %)\n\n// Remove the start face for the extrusion.\nshell({ faces: ['start'], thickness: 0.25 }, firstSketch)",
"// Remove a tagged face and the end face for the extrusion.\nconst firstSketch = startSketchOn('XY')\n |> startProfileAt([-12, 12], %)\n |> line([24, 0], %)\n |> line([0, -24], %)\n |> line([-24, 0], %, $myTag)\n |> close(%)\n |> extrude(6, %)\n\n// Remove a tagged face for the extrusion.\nshell({ faces: [myTag], thickness: 0.25 }, firstSketch)",
"// Remove multiple faces at once.\nconst firstSketch = startSketchOn('XY')\n |> startProfileAt([-12, 12], %)\n |> line([24, 0], %)\n |> line([0, -24], %)\n |> line([-24, 0], %, $myTag)\n |> close(%)\n |> extrude(6, %)\n\n// Remove a tagged face and the end face for the extrusion.\nshell({\n faces: [myTag, 'end'],\n thickness: 0.25\n}, firstSketch)",
"// Shell a sketch on face.\nlet size = 100\nconst case = startSketchOn('-XZ')\n |> startProfileAt([-size, -size], %)\n |> line([2 * size, 0], %)\n |> line([0, 2 * size], %)\n |> tangentialArcTo([-size, size], %)\n |> close(%)\n |> extrude(65, %)\n\nconst thing1 = startSketchOn(case, 'end')\n |> circle([-size / 2, -size / 2], 25, %)\n |> extrude(50, %)\n\nconst thing2 = startSketchOn(case, 'end')\n |> circle([size / 2, -size / 2], 25, %)\n |> extrude(50, %)\n\n// We put \"case\" in the shell function to shell the entire object.\nshell({ faces: ['start'], thickness: 5 }, case)",
"// Shell a sketch on face object on the end face.\nlet size = 100\nconst case = startSketchOn('XY')\n |> startProfileAt([-size, -size], %)\n |> line([2 * size, 0], %)\n |> line([0, 2 * size], %)\n |> tangentialArcTo([-size, size], %)\n |> close(%)\n |> extrude(65, %)\n\nconst thing1 = startSketchOn(case, 'end')\n |> circle([-size / 2, -size / 2], 25, %)\n |> extrude(50, %)\n\nconst thing2 = startSketchOn(case, 'end')\n |> circle([size / 2, -size / 2], 25, %)\n |> extrude(50, %)\n\n// We put \"thing1\" in the shell function to shell the end face of the object.\nshell({ faces: ['end'], thickness: 5 }, thing1)"
]
},
{
Expand Down
66 changes: 66 additions & 0 deletions src/wasm-lib/kcl/src/std/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub async fn shell(args: Args) -> Result<KclValue, KclError> {
/// face, leaving it open in that direction.
///
/// ```no_run
/// // Remove the end face for the extrusion.
/// const firstSketch = startSketchOn('XY')
/// |> startProfileAt([-12, 12], %)
/// |> line([24, 0], %)
Expand All @@ -52,6 +53,7 @@ pub async fn shell(args: Args) -> Result<KclValue, KclError> {
/// ```
///
/// ```no_run
/// // Remove the start face for the extrusion.
/// const firstSketch = startSketchOn('-XZ')
/// |> startProfileAt([-12, 12], %)
/// |> line([24, 0], %)
Expand All @@ -68,6 +70,7 @@ pub async fn shell(args: Args) -> Result<KclValue, KclError> {
/// ```
///
/// ```no_run
/// // Remove a tagged face and the end face for the extrusion.
/// const firstSketch = startSketchOn('XY')
/// |> startProfileAt([-12, 12], %)
/// |> line([24, 0], %)
Expand All @@ -82,6 +85,69 @@ pub async fn shell(args: Args) -> Result<KclValue, KclError> {
/// thickness: 0.25,
/// }, firstSketch)
/// ```
///
/// ```no_run
/// // Remove multiple faces at once.
/// const firstSketch = startSketchOn('XY')
/// |> startProfileAt([-12, 12], %)
/// |> line([24, 0], %)
/// |> line([0, -24], %)
/// |> line([-24, 0], %, $myTag)
/// |> close(%)
/// |> extrude(6, %)
///
/// // Remove a tagged face and the end face for the extrusion.
/// shell({
/// faces: [myTag, 'end'],
/// thickness: 0.25,
/// }, firstSketch)
/// ```
///
/// ```no_run
/// // Shell a sketch on face.
/// let size = 100
/// const case = startSketchOn('-XZ')
/// |> startProfileAt([-size, -size], %)
/// |> line([2 * size, 0], %)
/// |> line([0, 2 * size], %)
/// |> tangentialArcTo([-size, size], %)
/// |> close(%)
/// |> extrude(65, %)
///
/// const thing1 = startSketchOn(case, 'end')
/// |> circle([-size / 2, -size / 2], 25, %)
/// |> extrude(50, %)
///
/// const thing2 = startSketchOn(case, 'end')
/// |> circle([size / 2, -size / 2], 25, %)
/// |> extrude(50, %)
///
/// // We put "case" in the shell function to shell the entire object.
/// shell({ faces: ['start'], thickness: 5 }, case)
/// ```
///
/// ```no_run
/// // Shell a sketch on face object on the end face.
/// let size = 100
/// const case = startSketchOn('XY')
/// |> startProfileAt([-size, -size], %)
/// |> line([2 * size, 0], %)
/// |> line([0, 2 * size], %)
/// |> tangentialArcTo([-size, size], %)
/// |> close(%)
/// |> extrude(65, %)
///
/// const thing1 = startSketchOn(case, 'end')
/// |> circle([-size / 2, -size / 2], 25, %)
/// |> extrude(50, %)
///
/// const thing2 = startSketchOn(case, 'end')
/// |> circle([size / 2, -size / 2], 25, %)
/// |> extrude(50, %)
///
/// // We put "thing1" in the shell function to shell the end face of the object.
/// shell({ faces: ['end'], thickness: 5 }, thing1)
/// ```
#[stdlib {
name = "shell",
}]
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a00800b

Please sign in to comment.