make pipe have a hole (#4766)

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2024-12-11 17:07:14 -08:00
committed by GitHub
parent f38c6b90b7
commit c668d40efc
9 changed files with 47 additions and 28 deletions

File diff suppressed because one or more lines are too long

View File

@ -34804,7 +34804,7 @@
"// Setting the appearance of a 3D pattern can be done _before_ or _after_ the pattern.\n// This example shows _before_ the pattern.\nexampleSketch = startSketchOn('XZ')\n |> startProfileAt([0, 0], %)\n |> line([0, 2], %)\n |> line([3, 1], %)\n |> line([0, -4], %)\n |> close(%)\n\nexample = extrude(1, exampleSketch)\n |> appearance({\n color = '#ff0000',\n metalness = 90,\n roughness = 90\n }, %)\n |> patternLinear3d({\n axis = [1, 0, 1],\n instances = 7,\n distance = 6\n }, %)", "// Setting the appearance of a 3D pattern can be done _before_ or _after_ the pattern.\n// This example shows _before_ the pattern.\nexampleSketch = startSketchOn('XZ')\n |> startProfileAt([0, 0], %)\n |> line([0, 2], %)\n |> line([3, 1], %)\n |> line([0, -4], %)\n |> close(%)\n\nexample = extrude(1, exampleSketch)\n |> appearance({\n color = '#ff0000',\n metalness = 90,\n roughness = 90\n }, %)\n |> patternLinear3d({\n axis = [1, 0, 1],\n instances = 7,\n distance = 6\n }, %)",
"// Setting the appearance of a 3D pattern can be done _before_ or _after_ the pattern.\n// This example shows _after_ the pattern.\nexampleSketch = startSketchOn('XZ')\n |> startProfileAt([0, 0], %)\n |> line([0, 2], %)\n |> line([3, 1], %)\n |> line([0, -4], %)\n |> close(%)\n\nexample = extrude(1, exampleSketch)\n |> patternLinear3d({\n axis = [1, 0, 1],\n instances = 7,\n distance = 6\n }, %)\n |> appearance({\n color = '#ff0000',\n metalness = 90,\n roughness = 90\n }, %)", "// Setting the appearance of a 3D pattern can be done _before_ or _after_ the pattern.\n// This example shows _after_ the pattern.\nexampleSketch = startSketchOn('XZ')\n |> startProfileAt([0, 0], %)\n |> line([0, 2], %)\n |> line([3, 1], %)\n |> line([0, -4], %)\n |> close(%)\n\nexample = extrude(1, exampleSketch)\n |> patternLinear3d({\n axis = [1, 0, 1],\n instances = 7,\n distance = 6\n }, %)\n |> appearance({\n color = '#ff0000',\n metalness = 90,\n roughness = 90\n }, %)",
"// Color the result of a 2D pattern that was extruded.\nexampleSketch = startSketchOn('XZ')\n |> startProfileAt([.5, 25], %)\n |> line([0, 5], %)\n |> line([-1, 0], %)\n |> line([0, -5], %)\n |> close(%)\n |> patternCircular2d({\n center = [0, 0],\n instances = 13,\n arcDegrees = 360,\n rotateDuplicates = true\n }, %)\n\nexample = extrude(1, exampleSketch)\n |> appearance({\n color = '#ff0000',\n metalness = 90,\n roughness = 90\n }, %)", "// Color the result of a 2D pattern that was extruded.\nexampleSketch = startSketchOn('XZ')\n |> startProfileAt([.5, 25], %)\n |> line([0, 5], %)\n |> line([-1, 0], %)\n |> line([0, -5], %)\n |> close(%)\n |> patternCircular2d({\n center = [0, 0],\n instances = 13,\n arcDegrees = 360,\n rotateDuplicates = true\n }, %)\n\nexample = extrude(1, exampleSketch)\n |> appearance({\n color = '#ff0000',\n metalness = 90,\n roughness = 90\n }, %)",
"// Color the result of a sweep.\n\n\n// Create a path for the sweep.\nsweepPath = startSketchOn('XZ')\n |> startProfileAt([0.05, 0.05], %)\n |> line([0, 7], %)\n |> tangentialArc({ offset = 90, radius = 5 }, %)\n |> line([-3, 0], %)\n |> tangentialArc({ offset = -90, radius = 5 }, %)\n |> line([0, 7], %)\n\nsweepSketch = startSketchOn('XY')\n |> startProfileAt([2, 0], %)\n |> arc({\n angleEnd = 360,\n angleStart = 0,\n radius = 2\n }, %)\n |> sweep({ path = sweepPath }, %)\n |> appearance({\n color = \"#ff0000\",\n metalness = 50,\n roughness = 50\n }, %)" "// Color the result of a sweep.\n\n\n// Create a path for the sweep.\nsweepPath = startSketchOn('XZ')\n |> startProfileAt([0.05, 0.05], %)\n |> line([0, 7], %)\n |> tangentialArc({ offset = 90, radius = 5 }, %)\n |> line([-3, 0], %)\n |> tangentialArc({ offset = -90, radius = 5 }, %)\n |> line([0, 7], %)\n\npipeHole = startSketchOn('XY')\n |> circle({ center = [0, 0], radius = 1.5 }, %)\n\nsweepSketch = startSketchOn('XY')\n |> circle({ center = [0, 0], radius = 2 }, %)\n |> hole(pipeHole, %)\n |> sweep({ path = sweepPath }, %)\n |> appearance({\n color = \"#ff0000\",\n metalness = 50,\n roughness = 50\n }, %)"
] ]
}, },
{ {
@ -178348,7 +178348,7 @@
"unpublished": false, "unpublished": false,
"deprecated": false, "deprecated": false,
"examples": [ "examples": [
"// Create a pipe using a sweep.\n\n\n// Create a path for the sweep.\nsweepPath = startSketchOn('XZ')\n |> startProfileAt([0.05, 0.05], %)\n |> line([0, 7], %)\n |> tangentialArc({ offset = 90, radius = 5 }, %)\n |> line([-3, 0], %)\n |> tangentialArc({ offset = -90, radius = 5 }, %)\n |> line([0, 7], %)\n\nsweepSketch = startSketchOn('XY')\n |> startProfileAt([2, 0], %)\n |> arc({\n angleEnd = 360,\n angleStart = 0,\n radius = 2\n }, %)\n |> sweep({ path = sweepPath }, %)" "// Create a pipe using a sweep.\n\n\n// Create a path for the sweep.\nsweepPath = startSketchOn('XZ')\n |> startProfileAt([0.05, 0.05], %)\n |> line([0, 7], %)\n |> tangentialArc({ offset = 90, radius = 5 }, %)\n |> line([-3, 0], %)\n |> tangentialArc({ offset = -90, radius = 5 }, %)\n |> line([0, 7], %)\n\n// Create a hole for the pipe.\npipeHole = startSketchOn('XY')\n |> circle({ center = [0, 0], radius = 1.5 }, %)\n\nsweepSketch = startSketchOn('XY')\n |> circle({ center = [0, 0], radius = 2 }, %)\n |> hole(pipeHole, %)\n |> sweep({ path = sweepPath }, %)"
] ]
}, },
{ {

File diff suppressed because one or more lines are too long

View File

@ -236,6 +236,8 @@ pub trait StdLibFn: std::fmt::Debug + Send + Sync {
fn to_autocomplete_snippet(&self) -> Result<String> { fn to_autocomplete_snippet(&self) -> Result<String> {
if self.name() == "loft" { if self.name() == "loft" {
return Ok("loft([${0:sketch000}, ${1:sketch001}])${}".to_string()); return Ok("loft([${0:sketch000}, ${1:sketch001}])${}".to_string());
} else if self.name() == "hole" {
return Ok("hole(${0:holeSketch}, ${1:%})${}".to_string());
} }
let mut args = Vec::new(); let mut args = Vec::new();
let mut index = 0; let mut index = 0;
@ -1001,6 +1003,13 @@ mod tests {
); );
} }
#[test]
fn get_autocomplete_snippet_hole() {
let hole_fn: Box<dyn StdLibFn> = Box::new(crate::std::sketch::Hole);
let snippet = hole_fn.to_autocomplete_snippet().unwrap();
assert_eq!(snippet, r#"hole(${0:holeSketch}, ${1:%})${}"#);
}
// We want to test the snippets we compile at lsp start. // We want to test the snippets we compile at lsp start.
#[test] #[test]
fn get_all_stdlib_autocomplete_snippets() { fn get_all_stdlib_autocomplete_snippets() {

View File

@ -240,13 +240,18 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result<KclVa
/// }, %) /// }, %)
/// |> line([0, 7], %) /// |> line([0, 7], %)
/// ///
/// sweepSketch = startSketchOn('XY') /// pipeHole = startSketchOn('XY')
/// |> startProfileAt([2, 0], %) /// |> circle({
/// |> arc({ /// center = [0, 0],
/// angleEnd: 360, /// radius = 1.5,
/// angleStart: 0,
/// radius: 2
/// }, %) /// }, %)
///
/// sweepSketch = startSketchOn('XY')
/// |> circle({
/// center = [0, 0],
/// radius = 2,
/// }, %)
/// |> hole(pipeHole, %)
/// |> sweep({ /// |> sweep({
/// path: sweepPath, /// path: sweepPath,
/// }, %) /// }, %)

View File

@ -60,13 +60,19 @@ pub async fn sweep(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
/// }, %) /// }, %)
/// |> line([0, 7], %) /// |> line([0, 7], %)
/// ///
/// sweepSketch = startSketchOn('XY') /// // Create a hole for the pipe.
/// |> startProfileAt([2, 0], %) /// pipeHole = startSketchOn('XY')
/// |> arc({ /// |> circle({
/// angleEnd: 360, /// center = [0, 0],
/// angleStart: 0, /// radius = 1.5,
/// radius: 2
/// }, %) /// }, %)
///
/// sweepSketch = startSketchOn('XY')
/// |> circle({
/// center = [0, 0],
/// radius = 2,
/// }, %)
/// |> hole(pipeHole, %)
/// |> sweep({ /// |> sweep({
/// path: sweepPath, /// path: sweepPath,
/// }, %) /// }, %)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 35 KiB