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:
@ -22,5 +22,3 @@ once fixed in engine will just start working here with no language changes.
|
||||
|
||||
- **Chamfers**: Chamfers cannot intersect, you will get an error. Only simple
|
||||
chamfer cases work currently.
|
||||
|
||||
Sketching on the chamfered face does not currently work.
|
||||
|
File diff suppressed because one or more lines are too long
@ -68039,7 +68039,8 @@
|
||||
"unpublished": false,
|
||||
"deprecated": false,
|
||||
"examples": [
|
||||
"const width = 20\nconst length = 10\nconst thickness = 1\nconst chamferLength = 2\n\nconst mountingPlateSketch = startSketchOn(\"XY\")\n |> startProfileAt([-width / 2, -length / 2], %)\n |> lineTo([width / 2, -length / 2], %, $edge1)\n |> lineTo([width / 2, length / 2], %, $edge2)\n |> lineTo([-width / 2, length / 2], %, $edge3)\n |> close(%, $edge4)\n\nconst mountingPlate = extrude(thickness, mountingPlateSketch)\n |> chamfer({\n length: chamferLength,\n tags: [\n getNextAdjacentEdge(edge1),\n getNextAdjacentEdge(edge2),\n getNextAdjacentEdge(edge3),\n getNextAdjacentEdge(edge4)\n ]\n }, %)"
|
||||
"// Chamfer a mounting plate.\nconst width = 20\nconst length = 10\nconst thickness = 1\nconst chamferLength = 2\n\nconst mountingPlateSketch = startSketchOn(\"XY\")\n |> startProfileAt([-width / 2, -length / 2], %)\n |> lineTo([width / 2, -length / 2], %, $edge1)\n |> lineTo([width / 2, length / 2], %, $edge2)\n |> lineTo([-width / 2, length / 2], %, $edge3)\n |> close(%, $edge4)\n\nconst mountingPlate = extrude(thickness, mountingPlateSketch)\n |> chamfer({\n length: chamferLength,\n tags: [\n getNextAdjacentEdge(edge1),\n getNextAdjacentEdge(edge2),\n getNextAdjacentEdge(edge3),\n getNextAdjacentEdge(edge4)\n ]\n }, %)",
|
||||
"// Sketch on the face of a chamfer.\nfn cube = (pos, scale) => {\n const sg = startSketchOn('XY')\n |> startProfileAt(pos, %)\n |> line([0, scale], %)\n |> line([scale, 0], %)\n |> line([0, -scale], %)\n\n return sg\n}\n\nconst part001 = cube([0, 0], 20)\n |> close(%, $line1)\n |> extrude(20, %)\n |> chamfer({\n length: 10,\n tags: [getOppositeEdge(line1)]\n }, %, $chamfer1) // We tag the chamfer to reference it later.\n\nconst sketch001 = startSketchOn(part001, chamfer1)\n |> startProfileAt([10, 10], %)\n |> line([2, 0], %)\n |> line([0, 2], %)\n |> line([-2, 0], %)\n |> lineTo([profileStartX(%), profileStartY(%)], %)\n |> close(%)\n |> extrude(10, %)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -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,
|
||||
|
BIN
src/wasm-lib/kcl/tests/outputs/serial_test_example_chamfer1.png
Normal file
BIN
src/wasm-lib/kcl/tests/outputs/serial_test_example_chamfer1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 116 KiB |
@ -1823,40 +1823,6 @@ const part001 = cube([0,0], 20)
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
#[ignore] // Will return an error until this is fixed in the engine: https://github.com/KittyCAD/engine/issues/2260
|
||||
async fn kcl_test_sketch_on_face_of_chamfer() {
|
||||
let code = r#"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)
|
||||
|
||||
const sketch001 = startSketchOn(part001, chamfer1)
|
||||
|> startProfileAt([4.28, 3.83], %)
|
||||
|> line([2.17, -0.03], %)
|
||||
|> line([-0.07, -1.8], %)
|
||||
|> line([-2.07, 0.05], %)
|
||||
|> lineTo([profileStartX(%), profileStartY(%)], %)
|
||||
|> close(%)
|
||||
|> extrude(10, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
assert_out("sketch_on_face_of_chamfer", &result);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_duplicate_tags_should_error() {
|
||||
let code = r#"fn triangle = (len) => {
|
||||
|
Reference in New Issue
Block a user