add hollow (#3642)

* add hollow

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* docs

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* docs

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2024-08-23 09:57:02 -07:00
committed by GitHub
parent e56c634b35
commit 4dfad19b7e
11 changed files with 6077 additions and 6 deletions

835
docs/kcl/hollow.md Normal file

File diff suppressed because one or more lines are too long

View File

@ -44,6 +44,7 @@ layout: manual
* [`getPreviousAdjacentEdge`](kcl/getPreviousAdjacentEdge)
* [`helix`](kcl/helix)
* [`hole`](kcl/hole)
* [`hollow`](kcl/hollow)
* [`import`](kcl/import)
* [`inch`](kcl/inch)
* [`int`](kcl/int)

File diff suppressed because it is too large Load Diff

View File

@ -724,7 +724,7 @@ dependencies = [
[[package]]
name = "derive-docs"
version = "0.1.24"
version = "0.1.25"
dependencies = [
"Inflector",
"anyhow",
@ -1397,7 +1397,7 @@ dependencies = [
[[package]]
name = "kcl-lib"
version = "0.2.7"
version = "0.2.8"
dependencies = [
"anyhow",
"approx",
@ -1469,7 +1469,7 @@ dependencies = [
[[package]]
name = "kcl-test-server"
version = "0.1.8"
version = "0.1.9"
dependencies = [
"anyhow",
"hyper",

View File

@ -1,7 +1,7 @@
[package]
name = "derive-docs"
description = "A tool for generating documentation from Rust derive macros"
version = "0.1.24"
version = "0.1.25"
edition = "2021"
license = "MIT"
repository = "https://github.com/KittyCAD/modeling-app"

View File

@ -1,7 +1,7 @@
[package]
name = "kcl-test-server"
description = "A test server for KCL"
version = "0.1.8"
version = "0.1.9"
edition = "2021"
license = "MIT"

View File

@ -1,7 +1,7 @@
[package]
name = "kcl-lib"
description = "KittyCAD Language implementation and tools"
version = "0.2.7"
version = "0.2.8"
edition = "2021"
license = "MIT"
repository = "https://github.com/KittyCAD/modeling-app"

View File

@ -95,6 +95,7 @@ lazy_static! {
Box::new(crate::std::fillet::GetPreviousAdjacentEdge),
Box::new(crate::std::helix::Helix),
Box::new(crate::std::shell::Shell),
Box::new(crate::std::shell::Hollow),
Box::new(crate::std::revolve::Revolve),
Box::new(crate::std::import::Import),
Box::new(crate::std::math::Cos),

View File

@ -129,3 +129,64 @@ async fn inner_shell(
Ok(extrude_group)
}
/// Make the inside of a 3D object hollow.
pub async fn hollow(args: Args) -> Result<KclValue, KclError> {
let (thickness, extrude_group): (f64, Box<ExtrudeGroup>) = args.get_data_and_extrude_group()?;
let extrude_group = inner_hollow(thickness, extrude_group, args).await?;
Ok(KclValue::ExtrudeGroup(extrude_group))
}
/// Make the inside of a 3D object hollow.
///
/// Remove volume from a 3-dimensional shape such that a wall of the
/// provided thickness remains around the exterior of the shape.
///
/// ```no_run
/// const firstSketch = startSketchOn('XY')
/// |> startProfileAt([-12, 12], %)
/// |> line([24, 0], %)
/// |> line([0, -24], %)
/// |> line([-24, 0], %)
/// |> close(%)
/// |> extrude(6, %)
/// |> hollow (0.25, %)
/// ```
///
/// ```no_run
/// const firstSketch = startSketchOn('-XZ')
/// |> startProfileAt([-12, 12], %)
/// |> line([24, 0], %)
/// |> line([0, -24], %)
/// |> line([-24, 0], %)
/// |> close(%)
/// |> extrude(6, %)
/// |> hollow (0.5, %)
/// ```
#[stdlib {
name = "hollow",
}]
async fn inner_hollow(
thickness: f64,
extrude_group: Box<ExtrudeGroup>,
args: Args,
) -> Result<Box<ExtrudeGroup>, KclError> {
// Flush the batch for our fillets/chamfers if there are any.
// If we do not do these for sketch on face, things will fail with face does not exist.
args.flush_batch_for_extrude_group_set(extrude_group.clone().into())
.await?;
args.batch_modeling_cmd(
uuid::Uuid::new_v4(),
ModelingCmd::Solid3DShellFace {
hollow: true,
face_ids: Vec::new(), // This is empty because we want to hollow the entire object.
object_id: extrude_group.id,
shell_thickness: thickness,
},
)
.await?;
Ok(extrude_group)
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB