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:
835
docs/kcl/hollow.md
Normal file
835
docs/kcl/hollow.md
Normal file
File diff suppressed because one or more lines are too long
@ -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)
|
||||
|
5173
docs/kcl/std.json
5173
docs/kcl/std.json
File diff suppressed because it is too large
Load Diff
6
src/wasm-lib/Cargo.lock
generated
6
src/wasm-lib/Cargo.lock
generated
@ -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",
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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),
|
||||
|
@ -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)
|
||||
}
|
||||
|
BIN
src/wasm-lib/kcl/tests/outputs/serial_test_example_hollow0.png
Normal file
BIN
src/wasm-lib/kcl/tests/outputs/serial_test_example_hollow0.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
BIN
src/wasm-lib/kcl/tests/outputs/serial_test_example_hollow1.png
Normal file
BIN
src/wasm-lib/kcl/tests/outputs/serial_test_example_hollow1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 96 KiB |
Reference in New Issue
Block a user