106 lines
499 KiB
Markdown
106 lines
499 KiB
Markdown
---
|
|
title: "loft"
|
|
excerpt: "Create a 3D surface or solid by interpolating between two or more sketches."
|
|
layout: manual
|
|
---
|
|
|
|
Create a 3D surface or solid by interpolating between two or more sketches.
|
|
|
|
The sketches need to closed and on the same plane.
|
|
|
|
```js
|
|
loft(sketches: [Sketch], v_degree: NonZeroU32, bez_approximate_rational: bool, base_curve_index?: integer, tolerance?: number) -> Solid
|
|
```
|
|
|
|
|
|
### Arguments
|
|
|
|
| Name | Type | Description | Required |
|
|
|----------|------|-------------|----------|
|
|
| `sketches` | [`[Sketch]`](/docs/kcl/types/Sketch) | Which sketches to loft. Must include at least 2 sketches. | Yes |
|
|
| `v_degree` | `NonZeroU32` | Degree of the interpolation. Must be greater than zero. For example, use 2 for quadratic, or 3 for cubic interpolation in the V direction. This defaults to 2, if not specified. | Yes |
|
|
| `bez_approximate_rational` | `bool` | Attempt to approximate rational curves (such as arcs) using a bezier. This will remove banding around interpolations between arcs and non-arcs. It may produce errors in other scenarios Over time, this field won't be necessary. | Yes |
|
|
| `base_curve_index` | `integer` | This can be set to override the automatically determined topological base curve, which is usually the first section encountered. | No |
|
|
| `tolerance` | `number` | Tolerance for the loft operation. | No |
|
|
|
|
### Returns
|
|
|
|
[`Solid`](/docs/kcl/types/Solid) - An solid is a collection of extrude surfaces.
|
|
|
|
|
|
### Examples
|
|
|
|
```js
|
|
// Loft a square and a triangle.
|
|
squareSketch = startSketchOn('XY')
|
|
|> startProfileAt([-100, 200], %)
|
|
|> line([200, 0], %)
|
|
|> line([0, -200], %)
|
|
|> line([-200, 0], %)
|
|
|> lineTo([profileStartX(%), profileStartY(%)], %)
|
|
|> close(%)
|
|
|
|
triangleSketch = startSketchOn(offsetPlane('XY', 75))
|
|
|> startProfileAt([0, 125], %)
|
|
|> line([-15, -30], %)
|
|
|> line([30, 0], %)
|
|
|> lineTo([profileStartX(%), profileStartY(%)], %)
|
|
|> close(%)
|
|
|
|
loft([squareSketch, triangleSketch])
|
|
```
|
|
|
|

|
|
|
|
```js
|
|
// Loft a square, a circle, and another circle.
|
|
squareSketch = startSketchOn('XY')
|
|
|> startProfileAt([-100, 200], %)
|
|
|> line([200, 0], %)
|
|
|> line([0, -200], %)
|
|
|> line([-200, 0], %)
|
|
|> lineTo([profileStartX(%), profileStartY(%)], %)
|
|
|> close(%)
|
|
|
|
circleSketch0 = startSketchOn(offsetPlane('XY', 75))
|
|
|> circle({ center = [0, 100], radius = 50 }, %)
|
|
|
|
circleSketch1 = startSketchOn(offsetPlane('XY', 150))
|
|
|> circle({ center = [0, 100], radius = 20 }, %)
|
|
|
|
loft([
|
|
squareSketch,
|
|
circleSketch0,
|
|
circleSketch1
|
|
])
|
|
```
|
|
|
|

|
|
|
|
```js
|
|
// Loft a square, a circle, and another circle with options.
|
|
squareSketch = startSketchOn('XY')
|
|
|> startProfileAt([-100, 200], %)
|
|
|> line([200, 0], %)
|
|
|> line([0, -200], %)
|
|
|> line([-200, 0], %)
|
|
|> lineTo([profileStartX(%), profileStartY(%)], %)
|
|
|> close(%)
|
|
|
|
circleSketch0 = startSketchOn(offsetPlane('XY', 75))
|
|
|> circle({ center = [0, 100], radius = 50 }, %)
|
|
|
|
circleSketch1 = startSketchOn(offsetPlane('XY', 150))
|
|
|> circle({ center = [0, 100], radius = 20 }, %)
|
|
|
|
loft([
|
|
squareSketch,
|
|
circleSketch0,
|
|
circleSketch1
|
|
], baseCurveIndex = 0, bezApproximateRational = false, tolerance = 0.000001, vDegree = 2)
|
|
```
|
|
|
|

|
|
|
|
|