* Parse [T] instead of T[] for array types Signed-off-by: Nick Cameron <nrc@ncameron.org> * homogenous arrays, type coercion, remove solid set and sketch set, etc Signed-off-by: Nick Cameron <nrc@ncameron.org> --------- Signed-off-by: Nick Cameron <nrc@ncameron.org>
110 lines
272 KiB
Markdown
110 lines
272 KiB
Markdown
---
|
|
title: "scale"
|
|
excerpt: "Scale a solid."
|
|
layout: manual
|
|
---
|
|
|
|
Scale a solid.
|
|
|
|
By default the transform is applied in local sketch axis, therefore the origin will not move.
|
|
|
|
If you want to apply the transform in global space, set `global` to `true`. The origin of the model will move. If the model is not centered on origin and you scale globally it will look like the model moves and gets bigger at the same time. Say you have a square `(1,1) - (1,2) - (2,2) - (2,1)` and you scale by 2 globally it will become `(2,2) - (2,4)`...etc so the origin has moved from `(1.5, 1.5)` to `(2,2)`.
|
|
|
|
```js
|
|
scale(
|
|
solids: SolidOrImportedGeometry,
|
|
scale: [number],
|
|
global?: bool,
|
|
): SolidOrImportedGeometry
|
|
```
|
|
|
|
|
|
### Arguments
|
|
|
|
| Name | Type | Description | Required |
|
|
|----------|------|-------------|----------|
|
|
| `solids` | [`SolidOrImportedGeometry`](/docs/kcl/types/SolidOrImportedGeometry) | The solid or set of solids to scale. | Yes |
|
|
| `scale` | [`[number]`](/docs/kcl/types/number) | The scale factor for the x, y, and z axes. | Yes |
|
|
| `global` | [`bool`](/docs/kcl/types/bool) | If true, the transform is applied in global space. The origin of the model will move. By default, the transform is applied in local sketch axis, therefore the origin will not move. | No |
|
|
|
|
### Returns
|
|
|
|
[`SolidOrImportedGeometry`](/docs/kcl/types/SolidOrImportedGeometry) - Data for a solid or an imported geometry.
|
|
|
|
|
|
### Examples
|
|
|
|
```js
|
|
// Scale a pipe.
|
|
|
|
|
|
// Create a path for the sweep.
|
|
sweepPath = startSketchOn('XZ')
|
|
|> startProfileAt([0.05, 0.05], %)
|
|
|> line(end = [0, 7])
|
|
|> tangentialArc({ offset = 90, radius = 5 }, %)
|
|
|> line(end = [-3, 0])
|
|
|> tangentialArc({ offset = -90, radius = 5 }, %)
|
|
|> line(end = [0, 7])
|
|
|
|
// Create a hole for the pipe.
|
|
pipeHole = startSketchOn('XY')
|
|
|> circle(center = [0, 0], radius = 1.5)
|
|
|
|
sweepSketch = startSketchOn('XY')
|
|
|> circle(center = [0, 0], radius = 2)
|
|
|> hole(pipeHole, %)
|
|
|> sweep(path = sweepPath)
|
|
|> scale(scale = [1.0, 1.0, 2.5])
|
|
```
|
|
|
|

|
|
|
|
```js
|
|
// Scale an imported model.
|
|
|
|
|
|
import "tests/inputs/cube.sldprt" as cube
|
|
|
|
cube
|
|
|> scale(scale = [1.0, 1.0, 2.5])
|
|
```
|
|
|
|

|
|
|
|
```js
|
|
// Sweep two sketches along the same path.
|
|
|
|
|
|
sketch001 = startSketchOn('XY')
|
|
rectangleSketch = startProfileAt([-200, 23.86], sketch001)
|
|
|> angledLine([0, 73.47], %, $rectangleSegmentA001)
|
|
|> angledLine([
|
|
segAng(rectangleSegmentA001) - 90,
|
|
50.61
|
|
], %)
|
|
|> angledLine([
|
|
segAng(rectangleSegmentA001),
|
|
-segLen(rectangleSegmentA001)
|
|
], %)
|
|
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
|
|> close()
|
|
|
|
circleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)
|
|
|
|
sketch002 = startSketchOn('YZ')
|
|
sweepPath = startProfileAt([0, 0], sketch002)
|
|
|> yLine(length = 231.81)
|
|
|> tangentialArc({ radius = 80, offset = -90 }, %)
|
|
|> xLine(length = 384.93)
|
|
|
|
parts = sweep([rectangleSketch, circleSketch], path = sweepPath)
|
|
|
|
// Scale the sweep.
|
|
scale(parts, scale = [1.0, 1.0, 0.5])
|
|
```
|
|
|
|

|
|
|
|
|