|
| 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. |
0 commit comments