Skip to content

Commit 51280f4

Browse files
docs: Add sketch-on-face docs page (#7924)
* docs: Add sketch-on-face docs page --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 4ead559 commit 51280f4

File tree

5 files changed

+103
-0
lines changed

5 files changed

+103
-0
lines changed

docs/kcl-lang/sketch-on-face.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
title: "Sketch on Face"
3+
excerpt: "Sketching on the face of a solid using the KCL language for the Zoo Design Studio."
4+
layout: manual
5+
---
6+
7+
When you sketch on a plane and extrude, a new solid is created.
8+
9+
```kcl
10+
cube = startSketchOn(XY)
11+
|> startProfile(at = [0, 0])
12+
|> line(end = [1, 0])
13+
|> line(end = [0, 1])
14+
|> line(end = [-1, 0])
15+
|> line(end = [0, -1])
16+
|> close()
17+
|> extrude(length = 1)
18+
```
19+
20+
However, when you sketch on the face of an existing solid, extruding extends the
21+
existing solid.
22+
23+
```kcl
24+
cube = startSketchOn(XY)
25+
|> startProfile(at = [0, 0])
26+
|> line(end = [1, 0])
27+
|> line(end = [0, 1])
28+
|> line(end = [-1, 0])
29+
|> line(end = [0, -1])
30+
|> close()
31+
|> extrude(length = 1)
32+
33+
tower = startSketchOn(cube, face = END)
34+
|> circle(center = [0.5, 0.5], diameter = 0.2)
35+
|> extrude(length = 0.8)
36+
```
37+
38+
The result is that there's only one solid. You can think about this as being
39+
equivalent to making a new, separate solid and unioning the two in a single
40+
operation.
41+
42+
On the other hand, if you don't want to change the initial solid and create a
43+
new solid instead, there are a couple ways to do this.
44+
45+
The first way is instead of starting the sketch on the face of the solid, start
46+
the sketch on the same plane. Since it's not directly on the first solid's face,
47+
extrusions do not modify the solid. They create new solids instead.
48+
49+
```kcl
50+
cube = startSketchOn(XY)
51+
|> startProfile(at = [0, 0])
52+
|> line(end = [1, 0])
53+
|> line(end = [0, 1])
54+
|> line(end = [-1, 0])
55+
|> line(end = [0, -1])
56+
|> close()
57+
|> extrude(length = 1)
58+
59+
// This tower is a separate solid from the cube.
60+
tower = startSketchOn(planeOf(cube, face = END))
61+
|> circle(center = [0.5, 0.5], diameter = 0.2)
62+
|> extrude(length = 0.8)
63+
```
64+
65+
The second way to create a separate solid is by using the `method` parameter of
66+
`extrude()`. You can start the sketch on the face, but when extruding, specify
67+
that the method should create a new solid using `method = NEW`.
68+
69+
```kcl
70+
cube = startSketchOn(XY)
71+
|> startProfile(at = [0, 0])
72+
|> line(end = [1, 0])
73+
|> line(end = [0, 1])
74+
|> line(end = [-1, 0])
75+
|> line(end = [0, -1])
76+
|> close()
77+
|> extrude(length = 1)
78+
79+
// This tower is a separate solid from the cube.
80+
tower = startSketchOn(cube, face = END)
81+
|> circle(center = [0.5, 0.5], diameter = 0.2)
82+
|> extrude(method = NEW, length = 0.8)
83+
```
84+
85+
Once you have a separate solid, you can translate or rotate it separately or use
86+
boolean operations like union, subtract, and intersect.
87+
88+
If you intend to create a single solid, you should prefer to sketch-on-face
89+
since it's more succinct, efficient, and robust. But sometimes you need the
90+
flexibility of creating a separate solid.

docs/kcl-std/functions/std-sketch-extrude.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ extrude(
2525
You can provide more than one sketch to extrude, and they will all be
2626
extruded in the same direction.
2727

28+
When you sketch on a face of a solid, extruding extends or cuts into the
29+
existing solid, meaning you don't need to union or subtract the volumes. You
30+
can change this behavior by using the `method` parameter. See
31+
[sketch on face](/docs/kcl-lang/sketch-on-face) for more details.
32+
2833
### Arguments
2934

3035
| Name | Type | Description | Required |

docs/kcl-std/functions/std-sketch-startSketchOn.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ The point is if you want to export the result of a sketch on a face, you
3434
only need to export the final Solid that was created from the sketch on the
3535
face, since it will include all the parent faces and Solids.
3636

37+
See [sketch on face](/docs/kcl-lang/sketch-on-face) for more details.
38+
3739
### Arguments
3840

3941
| Name | Type | Description | Required |
189 Bytes
Loading

rust/kcl-lib/std/sketch.kcl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
/// only need to export the final Solid that was created from the sketch on the
2727
/// face, since it will include all the parent faces and Solids.
2828
///
29+
/// See [sketch on face](/docs/kcl-lang/sketch-on-face) for more details.
2930
///
3031
/// ```kcl
3132
/// exampleSketch = startSketchOn(XY)
@@ -376,6 +377,11 @@ export fn ellipse(
376377
/// You can provide more than one sketch to extrude, and they will all be
377378
/// extruded in the same direction.
378379
///
380+
/// When you sketch on a face of a solid, extruding extends or cuts into the
381+
/// existing solid, meaning you don't need to union or subtract the volumes. You
382+
/// can change this behavior by using the `method` parameter. See
383+
/// [sketch on face](/docs/kcl-lang/sketch-on-face) for more details.
384+
///
379385
/// ```kcl
380386
/// example = startSketchOn(XZ)
381387
/// |> startProfile(at = [0, 0])

0 commit comments

Comments
 (0)