Sketch on face of chamfer now works, added an example (#3876)

* sketch on face of chamfer example

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

* sketch on face of chamfer example

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

* make pretty

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-09-12 16:13:11 -07:00
committed by GitHub
parent 957a9ca4fe
commit 772034af68
6 changed files with 68 additions and 39 deletions

View File

@ -42,6 +42,7 @@ pub async fn chamfer(args: Args) -> Result<KclValue, KclError> {
/// a sharp, straight transitional edge.
///
/// ```no_run
/// // Chamfer a mounting plate.
/// const width = 20
/// const length = 10
/// const thickness = 1
@ -65,6 +66,36 @@ pub async fn chamfer(args: Args) -> Result<KclValue, KclError> {
/// ],
/// }, %)
/// ```
///
/// ```no_run
/// // Sketch on the face of a chamfer.
/// fn cube = (pos, scale) => {
/// const sg = startSketchOn('XY')
/// |> startProfileAt(pos, %)
/// |> line([0, scale], %)
/// |> line([scale, 0], %)
/// |> line([0, -scale], %)
///
/// return sg
/// }
///
/// const part001 = cube([0,0], 20)
/// |> close(%, $line1)
/// |> extrude(20, %)
/// |> chamfer({
/// length: 10,
/// tags: [getOppositeEdge(line1)]
/// }, %, $chamfer1) // We tag the chamfer to reference it later.
///
/// const sketch001 = startSketchOn(part001, chamfer1)
/// |> startProfileAt([10, 10], %)
/// |> line([2, 0], %)
/// |> line([0, 2], %)
/// |> line([-2, 0], %)
/// |> lineTo([profileStartX(%), profileStartY(%)], %)
/// |> close(%)
/// |> extrude(10, %)
/// ```
#[stdlib {
name = "chamfer",
}]
@ -111,7 +142,7 @@ async fn inner_chamfer(
radius: data.length,
tolerance: DEFAULT_TOLERANCE, // We can let the user set this in the future.
cut_type: Some(kittycad::types::CutType::Chamfer),
face_id: None,
face_id: Some(id),
},
)
.await?;
@ -125,7 +156,7 @@ async fn inner_chamfer(
if let Some(ref tag) = tag {
extrude_group.value.push(ExtrudeSurface::Chamfer(ChamferSurface {
face_id: edge_id,
face_id: id,
tag: Some(tag.clone()),
geo_meta: GeoMeta {
id,