@franknoirot @jtran and I decided that the `extrudeTwist()` function (which I added in https://github.com/KittyCAD/modeling-app/pull/7480) would be better as an optional case of the normal `extrude` function. Doing it this way means less work for the frontend team.
125 lines
453 KiB
Markdown
125 lines
453 KiB
Markdown
---
|
|
title: "extrude"
|
|
subtitle: "Function in std::sketch"
|
|
excerpt: "Extend a 2-dimensional sketch through a third dimension in order to create new 3-dimensional volume, or if extruded into an existing volume, cut into an existing solid."
|
|
layout: manual
|
|
---
|
|
|
|
Extend a 2-dimensional sketch through a third dimension in order to create new 3-dimensional volume, or if extruded into an existing volume, cut into an existing solid.
|
|
|
|
```kcl
|
|
extrude(
|
|
@sketches: [Sketch; 1+],
|
|
length: number(Length),
|
|
symmetric?: bool,
|
|
bidirectionalLength?: number(Length),
|
|
tagStart?: TagDecl,
|
|
tagEnd?: TagDecl,
|
|
twistAngle?: number(Angle),
|
|
twistAngleStep?: number(Angle),
|
|
twistCenter?: Point2d,
|
|
): [Solid; 1+]
|
|
```
|
|
|
|
You can provide more than one sketch to extrude, and they will all be
|
|
extruded in the same direction.
|
|
|
|
### Arguments
|
|
|
|
| Name | Type | Description | Required |
|
|
|----------|------|-------------|----------|
|
|
| `sketches` | [`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch) | Which sketch or sketches should be extruded. | Yes |
|
|
| `length` | [`number(Length)`](/docs/kcl-std/types/std-types-number) | How far to extrude the given sketches. | Yes |
|
|
| `symmetric` | [`bool`](/docs/kcl-std/types/std-types-bool) | If true, the extrusion will happen symmetrically around the sketch. Otherwise, the extrusion will happen on only one side of the sketch. | No |
|
|
| `bidirectionalLength` | [`number(Length)`](/docs/kcl-std/types/std-types-number) | If specified, will also extrude in the opposite direction to 'distance' to the specified distance. If 'symmetric' is true, this value is ignored. | No |
|
|
| `tagStart` | [`TagDecl`](/docs/kcl-std/types/std-types-TagDecl) | A named tag for the face at the start of the extrusion, i.e. the original sketch. | No |
|
|
| `tagEnd` | [`TagDecl`](/docs/kcl-std/types/std-types-TagDecl) | A named tag for the face at the end of the extrusion, i.e. the new face created by extruding the original sketch. | No |
|
|
| `twistAngle` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | If given, the sketch will be twisted around this angle while being extruded. | No |
|
|
| `twistAngleStep` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | The size of each intermediate angle as the sketch twists around. Must be between 4 and 90 degrees. Only used if `twistAngle` is given, defaults to 15 degrees. | No |
|
|
| `twistCenter` | [`Point2d`](/docs/kcl-std/types/std-types-Point2d) | The center around which the sketch will be twisted. Relative to the sketch's center. Only used if `twistAngle` is given, defaults to [0, 0] i.e. sketch's center. | No |
|
|
|
|
### Returns
|
|
|
|
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
|
|
|
|
|
|
### Examples
|
|
|
|
```kcl
|
|
example = startSketchOn(XZ)
|
|
|> startProfile(at = [0, 0])
|
|
|> line(end = [10, 0])
|
|
|> arc(angleStart = 120deg, angleEnd = 0, radius = 5)
|
|
|> line(end = [5, 0])
|
|
|> line(end = [0, 10])
|
|
|> bezierCurve(control1 = [-10, 0], control2 = [2, 10], end = [-5, 10])
|
|
|> line(end = [-5, -2])
|
|
|> close()
|
|
|> extrude(length = 10)
|
|
|
|
```
|
|
|
|

|
|
|
|
```kcl
|
|
exampleSketch = startSketchOn(XZ)
|
|
|> startProfile(at = [-10, 0])
|
|
|> arc(angleStart = 120deg, angleEnd = -60deg, radius = 5)
|
|
|> line(end = [10, 0])
|
|
|> line(end = [5, 0])
|
|
|> bezierCurve(control1 = [-3, 0], control2 = [2, 10], end = [-5, 10])
|
|
|> line(end = [-4, 10])
|
|
|> line(end = [-5, -2])
|
|
|> close()
|
|
|
|
example = extrude(exampleSketch, length = 10)
|
|
|
|
```
|
|
|
|

|
|
|
|
```kcl
|
|
exampleSketch = startSketchOn(XZ)
|
|
|> startProfile(at = [-10, 0])
|
|
|> arc(angleStart = 120deg, angleEnd = -60deg, radius = 5)
|
|
|> line(end = [10, 0])
|
|
|> line(end = [5, 0])
|
|
|> bezierCurve(control1 = [-3, 0], control2 = [2, 10], end = [-5, 10])
|
|
|> line(end = [-4, 10])
|
|
|> line(end = [-5, -2])
|
|
|> close()
|
|
|
|
example = extrude(exampleSketch, length = 20, symmetric = true)
|
|
|
|
```
|
|
|
|

|
|
|
|
```kcl
|
|
exampleSketch = startSketchOn(XZ)
|
|
|> startProfile(at = [-10, 0])
|
|
|> arc(angleStart = 120deg, angleEnd = -60deg, radius = 5)
|
|
|> line(end = [10, 0])
|
|
|> line(end = [5, 0])
|
|
|> bezierCurve(control1 = [-3, 0], control2 = [2, 10], end = [-5, 10])
|
|
|> line(end = [-4, 10])
|
|
|> line(end = [-5, -2])
|
|
|> close()
|
|
|
|
example = extrude(exampleSketch, length = 10, bidirectionalLength = 50)
|
|
|
|
```
|
|
|
|

|
|
|
|
```kcl
|
|
example = startSketchOn(XZ)
|
|
|> polygon(radius = 10, numSides = 3, center = [0, 0])
|
|
|> extrude(length = 10, twistAngle = 120deg)
|
|
|
|
```
|
|
|
|

|
|
|
|
|