Compare commits

...

1 Commits

Author SHA1 Message Date
ff1be99351 Make the function signature less prominent, add an early example to docs
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-06-19 17:08:46 +12:00
99 changed files with 2137 additions and 686 deletions

View File

@ -8,11 +8,13 @@ layout: manual
Build a color from its red, green and blue components. These must be between 0 and 255.
```kcl
appearance::hexString(@rgb: [number(_); 3]): string
startSketchOn(-XZ)
|> circle(center = [0, 0], radius = 10)
|> extrude(length = 4)
|> appearance(color = appearance::hexString([50, 160, 160]))
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +26,12 @@ appearance::hexString(@rgb: [number(_); 3]): string
[`string`](/docs/kcl-std/types/std-types-string) - A sequence of characters
### Function signature
```kcl
appearance::hexString(@rgb: [number(_); 3]): string
```
### Examples
```kcl

View File

@ -8,14 +8,18 @@ layout: manual
Apply a function to every element of a list.
```kcl
map(
@array: [any],
f: fn(any): any,
): [any]
```
r = 10 // radius
fn drawCircle(@id) {
return startSketchOn(XY)
|> circle(center = [id * 2 * r, 0], radius = r)
}
Given a list like `[a, b, c]`, and a function like `f`, returns
`[f(a), f(b), f(c)]`
// Call `drawCircle`, passing in each element of the array.
// The outputs from each `drawCircle` form a new array,
// which is the return value from `map`.
circles = map([1..3], f = drawCircle)
```
### Arguments
@ -28,6 +32,19 @@ Given a list like `[a, b, c]`, and a function like `f`, returns
[`[any]`](/docs/kcl-std/types/std-types-any)
### Description
Given a list like `[a, b, c]`, and a function like `f`, returns
`[f(a), f(b), f(c)]`
### Function signature
```kcl
map(
@array: [any],
f: fn(any): any,
): [any]
```
### Examples

View File

@ -8,10 +8,28 @@ layout: manual
Remove the last element from an array.
```kcl
pop(@array: [any; 1+]): [any]
```
arr = [1, 2, 3, 4]
new_arr = pop(arr)
assert(
new_arr[0],
isEqualTo = 1,
tolerance = 0.00001,
error = "1 is the first element of the array",
)
assert(
new_arr[1],
isEqualTo = 2,
tolerance = 0.00001,
error = "2 is the second element of the array",
)
assert(
new_arr[2],
isEqualTo = 3,
tolerance = 0.00001,
error = "3 is the third element of the array",
)
Returns a new array with the last element removed.
```
### Arguments
@ -23,6 +41,15 @@ Returns a new array with the last element removed.
[`[any]`](/docs/kcl-std/types/std-types-any)
### Description
Returns a new array with the last element removed.
### Function signature
```kcl
pop(@array: [any; 1+]): [any]
```
### Examples

View File

@ -8,13 +8,16 @@ layout: manual
Append an element to the end of an array.
```kcl
push(
@array: [any],
item: any,
): [any; 1+]
```
arr = [1, 2, 3]
new_arr = push(arr, item = 4)
assert(
new_arr[3],
isEqualTo = 4,
tolerance = 0.1,
error = "4 was added to the end of the array",
)
Returns a new array with the element appended.
```
### Arguments
@ -27,6 +30,18 @@ Returns a new array with the element appended.
[`[any; 1+]`](/docs/kcl-std/types/std-types-any)
### Description
Returns a new array with the element appended.
### Function signature
```kcl
push(
@array: [any],
item: any,
): [any; 1+]
```
### Examples

View File

@ -8,15 +8,36 @@ layout: manual
Take a starting value. Then, for each element of an array, calculate the next value, using the previous value and the element.
```kcl
reduce(
@array: [any],
initial: any,
f: fn(any, accum: any): any,
): any
// This function adds two numbers.
fn add(@a, accum) {
return a + accum
}
// This function adds an array of numbers.
// It uses the `reduce` function, to call the `add` function on every
// element of the `arr` parameter. The starting value is 0.
fn sum(@arr) {
return reduce(arr, initial = 0, f = add)
}
/* The above is basically like this pseudo-code:
fn sum(arr):
sumSoFar = 0
for i in arr:
sumSoFar = add(i, sumSoFar)
return sumSoFar */
// We use `assert` to check that our `sum` function gives the
// expected result. It's good to check your work!
assert(
sum([1, 2, 3]),
isEqualTo = 6,
tolerance = 0.1,
error = "1 + 2 + 3 summed is 6",
)
```
### Arguments
| Name | Type | Description | Required |
@ -30,6 +51,16 @@ reduce(
[`any`](/docs/kcl-std/types/std-types-any) - The [`any`](/docs/kcl-std/types/std-types-any) type is the type of all possible values in KCL. I.e., if a function accepts an argument with type [`any`](/docs/kcl-std/types/std-types-any), then it can accept any value.
### Function signature
```kcl
reduce(
@array: [any],
initial: any,
f: fn(any, accum: any): any,
): any
```
### Examples
```kcl

View File

@ -8,20 +8,23 @@ layout: manual
Check a value meets some expected conditions at runtime. Program terminates with an error if conditions aren't met. If you provide multiple conditions, they will all be checked and all must be met.
```kcl
n = 10
assert(n, isEqualTo = 10)
assert(
@actual: number,
isGreaterThan?: number,
isLessThan?: number,
isGreaterThanOrEqual?: number,
isLessThanOrEqual?: number,
isEqualTo?: number,
tolerance?: number,
error?: string,
n,
isGreaterThanOrEqual = 0,
isLessThan = 100,
error = "number should be between 0 and 100",
)
assert(
1.0000000000012,
isEqualTo = 1,
tolerance = 0.0001,
error = "number should be almost exactly 1",
)
```
### Arguments
| Name | Type | Description | Required |
@ -36,6 +39,21 @@ assert(
| `error` | [`string`](/docs/kcl-std/types/std-types-string) | If the value was false, the program will terminate with this error message | No |
### Function signature
```kcl
assert(
@actual: number,
isGreaterThan?: number,
isLessThan?: number,
isGreaterThanOrEqual?: number,
isLessThanOrEqual?: number,
isEqualTo?: number,
tolerance?: number,
error?: string,
)
```
### Examples
```kcl

View File

@ -8,14 +8,11 @@ layout: manual
Asserts that a value is the boolean value true.
```kcl
assertIs(
@actual: bool,
error?: string,
)
kclIsFun = true
assertIs(kclIsFun)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +21,15 @@ assertIs(
| `error` | [`string`](/docs/kcl-std/types/std-types-string) | If the value was false, the program will terminate with this error message | No |
### Function signature
```kcl
assertIs(
@actual: bool,
error?: string,
)
```
### Examples
```kcl

View File

@ -8,18 +8,21 @@ layout: manual
Clone a sketch or solid.
```kcl
clone(@geometry: Sketch | Solid | ImportedGeometry): Sketch | Solid | ImportedGeometry
// Clone a basic sketch and move it and extrude it.
exampleSketch = startSketchOn(XY)
|> startProfile(at = [0, 0])
|> line(end = [10, 0])
|> line(end = [0, 10])
|> line(end = [-10, 0])
|> close()
clonedSketch = clone(exampleSketch)
|> scale(x = 1.0, y = 1.0, z = 2.5)
|> translate(x = 15.0, y = 0, z = 0)
|> extrude(length = 5)
```
This works essentially like a copy-paste operation. It creates a perfect replica
at that point in time that you can manipulate individually afterwards.
This doesn't really have much utility unless you need the equivalent of a double
instance pattern with zero transformations.
Really only use this function if YOU ARE SURE you need it. In most cases you
do not need clone and using a pattern with `instance = 2` is more appropriate.
### Arguments
| Name | Type | Description | Required |
@ -30,6 +33,22 @@ do not need clone and using a pattern with `instance = 2` is more appropriate.
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) or [`Solid`](/docs/kcl-std/types/std-types-Solid) or [`ImportedGeometry`](/docs/kcl-std/types/std-types-ImportedGeometry)
### Description
This works essentially like a copy-paste operation. It creates a perfect replica
at that point in time that you can manipulate individually afterwards.
This doesn't really have much utility unless you need the equivalent of a double
instance pattern with zero transformations.
Really only use this function if YOU ARE SURE you need it. In most cases you
do not need clone and using a pattern with `instance = 2` is more appropriate.
### Function signature
```kcl
clone(@geometry: Sketch | Solid | ImportedGeometry): Sketch | Solid | ImportedGeometry
```
### Examples

View File

@ -8,19 +8,23 @@ layout: manual
Create a helix.
```kcl
helix(
revolutions: number(_),
angleStart: number(Angle),
ccw?: bool,
radius?: number(Length),
axis?: Axis3d | Edge,
length?: number(Length),
cylinder?: Solid,
): Helix
// Create a helix around the Z axis.
helixPath = helix(
angleStart = 0,
ccw = true,
revolutions = 5,
length = 10,
radius = 5,
axis = Z,
)
// Create a spring by sweeping around the helix path.
springSketch = startSketchOn(XZ)
|> circle(center = [5, 0], radius = 0.5)
|> sweep(path = helixPath)
```
### Arguments
| Name | Type | Description | Required |
@ -38,6 +42,20 @@ helix(
[`Helix`](/docs/kcl-std/types/std-types-Helix) - A helix; created by the `helix` function.
### Function signature
```kcl
helix(
revolutions: number(_),
angleStart: number(Angle),
ccw?: bool,
radius?: number(Length),
axis?: Axis3d | Edge,
length?: number(Length),
cylinder?: Solid,
): Helix
```
### Examples
```kcl

View File

@ -8,11 +8,20 @@ layout: manual
Compute the absolute value of a number.
```kcl
abs(@input: number): number
myAngle = -120deg
sketch001 = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [8, 0])
|> angledLine(angle = abs(myAngle), length = 5)
|> line(end = [-5, 0])
|> angledLine(angle = myAngle, length = 5)
|> close()
baseExtrusion = extrude(sketch001, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +33,12 @@ abs(@input: number): number
[`number`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
abs(@input: number): number
```
### Examples
```kcl

View File

@ -8,11 +8,17 @@ layout: manual
Compute the arccosine of a number.
```kcl
acos(@num: number(_)): number(rad)
sketch001 = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> angledLine(angle = acos(0.5), length = 10)
|> line(end = [5, 0])
|> line(endAbsolute = [12, 0])
|> close()
extrude001 = extrude(sketch001, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +30,12 @@ acos(@num: number(_)): number(rad)
[`number(rad)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
acos(@num: number(_)): number(rad)
```
### Examples
```kcl

View File

@ -8,11 +8,16 @@ layout: manual
Compute the arcsine of a number.
```kcl
asin(@num: number(_)): number(rad)
sketch001 = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> angledLine(angle = asin(0.5), length = 20)
|> yLine(endAbsolute = 0)
|> close()
extrude001 = extrude(sketch001, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +29,12 @@ asin(@num: number(_)): number(rad)
[`number(rad)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
asin(@num: number(_)): number(rad)
```
### Examples
```kcl

View File

@ -8,10 +8,15 @@ layout: manual
Compute the arctangent of a number.
```kcl
atan(@num: number(_)): number(rad)
```
sketch001 = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> angledLine(angle = atan(1.25), length = 20)
|> yLine(endAbsolute = 0)
|> close()
Consider using `atan2()` instead for the true inverse of tangent.
extrude001 = extrude(sketch001, length = 5)
```
### Arguments
@ -23,6 +28,15 @@ Consider using `atan2()` instead for the true inverse of tangent.
[`number(rad)`](/docs/kcl-std/types/std-types-number) - A number.
### Description
Consider using `atan2()` instead for the true inverse of tangent.
### Function signature
```kcl
atan(@num: number(_)): number(rad)
```
### Examples

View File

@ -8,14 +8,16 @@ layout: manual
Compute the four quadrant arctangent of Y and X.
```kcl
atan2(
y: number(Length),
x: number(Length),
): number(rad)
sketch001 = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> angledLine(angle = atan2(y = 1.25, x = 2), length = 20)
|> yLine(endAbsolute = 0)
|> close()
extrude001 = extrude(sketch001, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -28,6 +30,15 @@ atan2(
[`number(rad)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
atan2(
y: number(Length),
x: number(Length),
): number(rad)
```
### Examples
```kcl

View File

@ -8,11 +8,17 @@ layout: manual
Compute the smallest integer greater than or equal to a number.
```kcl
ceil(@input: number): number
sketch001 = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(endAbsolute = [12, 10])
|> line(end = [ceil(7.02986), 0])
|> yLine(endAbsolute = 0)
|> close()
extrude001 = extrude(sketch001, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +30,12 @@ ceil(@input: number): number
[`number`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
ceil(@input: number): number
```
### Examples
```kcl

View File

@ -8,11 +8,16 @@ layout: manual
Compute the cosine of a number.
```kcl
cos(@num: number(Angle)): number
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> angledLine(angle = 30deg, length = 3 / cos(30deg))
|> yLine(endAbsolute = 0)
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +29,12 @@ cos(@num: number(Angle)): number
[`number`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
cos(@num: number(Angle)): number
```
### Examples
```kcl

View File

@ -8,11 +8,17 @@ layout: manual
Compute the largest integer less than or equal to a number.
```kcl
floor(@input: number): number
sketch001 = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(endAbsolute = [12, 10])
|> line(end = [floor(7.02986), 0])
|> yLine(endAbsolute = 0)
|> close()
extrude001 = extrude(sketch001, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +30,12 @@ floor(@input: number): number
[`number`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
floor(@input: number): number
```
### Examples
```kcl

View File

@ -8,14 +8,10 @@ layout: manual
Compute the angle of the given leg for x.
```kcl
legAngX(
hypotenuse: number(Length),
leg: number(Length),
): number(deg)
legAngX(hypotenuse = 5, leg = 3)
```
### Arguments
| Name | Type | Description | Required |
@ -28,6 +24,15 @@ legAngX(
[`number(deg)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
legAngX(
hypotenuse: number(Length),
leg: number(Length),
): number(deg)
```
### Examples
```kcl

View File

@ -8,14 +8,10 @@ layout: manual
Compute the angle of the given leg for y.
```kcl
legAngY(
hypotenuse: number(Length),
leg: number(Length),
): number(deg)
legAngY(hypotenuse = 5, leg = 3)
```
### Arguments
| Name | Type | Description | Required |
@ -28,6 +24,15 @@ legAngY(
[`number(deg)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
legAngY(
hypotenuse: number(Length),
leg: number(Length),
): number(deg)
```
### Examples
```kcl

View File

@ -8,14 +8,10 @@ layout: manual
Compute the length of the given leg.
```kcl
legLen(
hypotenuse: number(Length),
leg: number(Length),
): number(Length)
legLen(hypotenuse = 5, leg = 3)
```
### Arguments
| Name | Type | Description | Required |
@ -28,6 +24,15 @@ legLen(
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
legLen(
hypotenuse: number(Length),
leg: number(Length),
): number(Length)
```
### Examples
```kcl

View File

@ -8,11 +8,17 @@ layout: manual
Compute the natural logarithm of the number.
```kcl
ln(@input: number): number
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [ln(100), 15])
|> line(end = [5, -6])
|> line(end = [-10, -10])
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +30,12 @@ ln(@input: number): number
[`number`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
ln(@input: number): number
```
### Examples
```kcl

View File

@ -8,15 +8,16 @@ layout: manual
Compute the logarithm of the number with respect to an arbitrary base.
```kcl
log(
@input: number,
base: number(_),
): number
```
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [log(100, base = 5), 0])
|> line(end = [5, 8])
|> line(end = [-10, 0])
|> close()
The result might not be correctly rounded owing to implementation
details; `log2` can produce more accurate results for base 2,
and `log10` can produce more accurate results for base 10.
example = extrude(exampleSketch, length = 5)
```
### Arguments
@ -29,6 +30,20 @@ and `log10` can produce more accurate results for base 10.
[`number`](/docs/kcl-std/types/std-types-number) - A number.
### Description
The result might not be correctly rounded owing to implementation
details; `log2` can produce more accurate results for base 2,
and `log10` can produce more accurate results for base 10.
### Function signature
```kcl
log(
@input: number,
base: number(_),
): number
```
### Examples

View File

@ -8,11 +8,17 @@ layout: manual
Compute the base 10 logarithm of the number.
```kcl
log10(@input: number): number
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [log10(100), 0])
|> line(end = [5, 8])
|> line(end = [-10, 0])
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +30,12 @@ log10(@input: number): number
[`number`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
log10(@input: number): number
```
### Examples
```kcl

View File

@ -8,11 +8,17 @@ layout: manual
Compute the base 2 logarithm of the number.
```kcl
log2(@input: number): number
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [log2(100), 0])
|> line(end = [5, 8])
|> line(end = [-10, 0])
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +30,12 @@ log2(@input: number): number
[`number`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
log2(@input: number): number
```
### Examples
```kcl

View File

@ -8,11 +8,16 @@ layout: manual
Compute the maximum of the given arguments.
```kcl
max(@input: [number; 1+]): number
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> angledLine(angle = 70deg, length = max([15, 31, 4, 13, 22]))
|> line(end = [20, 0])
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +29,12 @@ max(@input: [number; 1+]): number
[`number`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
max(@input: [number; 1+]): number
```
### Examples
```kcl

View File

@ -8,11 +8,16 @@ layout: manual
Compute the minimum of the given arguments.
```kcl
min(@input: [number; 1+]): number
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> angledLine(angle = 70deg, length = min([15, 31, 4, 13, 22]))
|> line(end = [20, 0])
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +29,12 @@ min(@input: [number; 1+]): number
[`number`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
min(@input: [number; 1+]): number
```
### Examples
```kcl

View File

@ -8,14 +8,18 @@ layout: manual
Convert polar/sphere (azimuth, elevation, distance) coordinates to cartesian (x/y/z grid) coordinates.
```kcl
polar(
angle: number(rad),
length: number(Length),
): Point2d
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = polar(angle = 30deg, length = 5), tag = $thing)
|> line(end = [0, 5])
|> line(end = [segEndX(thing), 0])
|> line(end = [-20, 10])
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -28,6 +32,15 @@ polar(
[`Point2d`](/docs/kcl-std/types/std-types-Point2d) - A point in two dimensional space.
### Function signature
```kcl
polar(
angle: number(rad),
length: number(Length),
): Point2d
```
### Examples
```kcl

View File

@ -8,14 +8,16 @@ layout: manual
Compute the number to a power.
```kcl
pow(
@input: number,
exp: number(_),
): number
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> angledLine(angle = 50deg, length = pow(5, exp = 2))
|> yLine(endAbsolute = 0)
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -28,6 +30,15 @@ pow(
[`number`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
pow(
@input: number,
exp: number(_),
): number
```
### Examples
```kcl

View File

@ -8,14 +8,17 @@ layout: manual
Compute the remainder after dividing `num` by `div`. If `num` is negative, the result will be too.
```kcl
rem(
@num: number,
divisor: number,
): number
import rem from "std::math"
assert(rem(7, divisor = 4), isEqualTo = 3, error = "remainder is 3")
assert(rem(-7, divisor = 4), isEqualTo = -3, error = "remainder is -3")
assert(rem(7, divisor = -4), isEqualTo = 3, error = "remainder is 3")
assert(rem(6, divisor = 2.5), isEqualTo = 1, error = "remainder is 1")
assert(rem(6.5, divisor = 2.5), isEqualTo = 1.5, error = "remainder is 1.5")
assert(rem(6.5, divisor = 2), isEqualTo = 0.5, error = "remainder is 0.5")
```
### Arguments
| Name | Type | Description | Required |
@ -28,6 +31,15 @@ rem(
[`number`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
rem(
@num: number,
divisor: number,
): number
```
### Examples
```kcl

View File

@ -8,11 +8,17 @@ layout: manual
Round a number to the nearest integer.
```kcl
round(@input: number): number
sketch001 = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(endAbsolute = [12, 10])
|> line(end = [round(7.02986), 0])
|> yLine(endAbsolute = 0)
|> close()
extrude001 = extrude(sketch001, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +30,12 @@ round(@input: number): number
[`number`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
round(@input: number): number
```
### Examples
```kcl

View File

@ -8,11 +8,16 @@ layout: manual
Compute the sine of a number.
```kcl
sin(@num: number(Angle)): number
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> angledLine(angle = 50deg, length = 15 / sin(135deg))
|> yLine(endAbsolute = 0)
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +29,12 @@ sin(@num: number(Angle)): number
[`number`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
sin(@num: number(Angle)): number
```
### Examples
```kcl

View File

@ -8,11 +8,16 @@ layout: manual
Compute the square root of a number.
```kcl
sqrt(@input: number): number
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> angledLine(angle = 50deg, length = sqrt(2500))
|> yLine(endAbsolute = 0)
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +29,12 @@ sqrt(@input: number): number
[`number`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
sqrt(@input: number): number
```
### Examples
```kcl

View File

@ -8,11 +8,16 @@ layout: manual
Compute the tangent of a number.
```kcl
tan(@num: number(Angle)): number
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> angledLine(angle = 50deg, length = 50 * tan((1 / 2): number(rad)))
|> yLine(endAbsolute = 0)
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +29,12 @@ tan(@num: number(Angle)): number
[`number`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
tan(@num: number(Angle)): number
```
### Examples
```kcl

View File

@ -8,14 +8,21 @@ layout: manual
Offset a plane by a distance along its normal.
```kcl
offsetPlane(
@plane: Plane,
offset: number(Length),
): Plane
```
// Loft a square and a circle on the `XY` plane using offset.
squareSketch = startSketchOn(XY)
|> startProfile(at = [-100, 200])
|> line(end = [200, 0])
|> line(end = [0, -200])
|> line(end = [-200, 0])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
For example, if you offset the `XZ` plane by 10, the new plane will be parallel to the `XZ`
plane and 10 units away from it.
circleSketch = startSketchOn(offsetPlane(XY, offset = 150))
|> circle(center = [0, 100], radius = 50)
loft([squareSketch, circleSketch])
```
### Arguments
@ -28,6 +35,19 @@ plane and 10 units away from it.
[`Plane`](/docs/kcl-std/types/std-types-Plane) - An abstract plane.
### Description
For example, if you offset the `XZ` plane by 10, the new plane will be parallel to the `XZ`
plane and 10 units away from it.
### Function signature
```kcl
offsetPlane(
@plane: Plane,
offset: number(Length),
): Plane
```
### Examples

View File

@ -8,20 +8,18 @@ layout: manual
Draw a line segment relative to the current origin using the polar measure of some angle and distance.
```kcl
angledLine(
@sketch: Sketch,
angle: number(Angle),
length?: number(Length),
lengthX?: number(Length),
lengthY?: number(Length),
endAbsoluteX?: number(Length),
endAbsoluteY?: number(Length),
tag?: TagDecl,
): Sketch
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> yLine(endAbsolute = 15)
|> angledLine(angle = 30deg, length = 15)
|> line(end = [8, -10])
|> yLine(endAbsolute = 0)
|> close()
example = extrude(exampleSketch, length = 10)
```
### Arguments
| Name | Type | Description | Required |
@ -40,6 +38,21 @@ angledLine(
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
### Function signature
```kcl
angledLine(
@sketch: Sketch,
angle: number(Angle),
length?: number(Length),
lengthX?: number(Length),
lengthY?: number(Length),
endAbsoluteX?: number(Length),
endAbsoluteY?: number(Length),
tag?: TagDecl,
): Sketch
```
### Examples
```kcl

View File

@ -8,17 +8,18 @@ layout: manual
Draw an angled line from the current origin, constructing a line segment such that the newly created line intersects the desired target line segment.
```kcl
angledLineThatIntersects(
@sketch: Sketch,
angle: number(Angle),
intersectTag: TaggedEdge,
offset?: number(Length),
tag?: TagDecl,
): Sketch
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(endAbsolute = [5, 10])
|> line(endAbsolute = [-10, 10], tag = $lineToIntersect)
|> line(endAbsolute = [0, 20])
|> angledLineThatIntersects(angle = 80deg, intersectTag = lineToIntersect, offset = 10)
|> close()
example = extrude(exampleSketch, length = 10)
```
### Arguments
| Name | Type | Description | Required |
@ -34,6 +35,18 @@ angledLineThatIntersects(
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
### Function signature
```kcl
angledLineThatIntersects(
@sketch: Sketch,
angle: number(Angle),
intersectTag: TaggedEdge,
offset?: number(Length),
tag?: TagDecl,
): Sketch
```
### Examples
```kcl

View File

@ -8,27 +8,15 @@ layout: manual
Draw a curved line segment along an imaginary circle.
```kcl
arc(
@sketch: Sketch,
angleStart?: number(Angle),
angleEnd?: number(Angle),
radius?: number(Length),
diameter?: number(Length),
interiorAbsolute?: Point2d,
endAbsolute?: Point2d,
tag?: TagDecl,
): Sketch
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [10, 0])
|> arc(angleStart = 0, angleEnd = 280deg, radius = 16)
|> close()
example = extrude(exampleSketch, length = 10)
```
The arc is constructed such that the current position of the sketch is
placed along an imaginary circle of the specified radius, at angleStart
degrees. The resulting arc is the segment of the imaginary circle from
that origin point to angleEnd, radius away from the center of the imaginary
circle.
Unless this makes a lot of sense and feels like what you're looking
for to construct your shape, you're likely looking for tangentialArc.
### Arguments
| Name | Type | Description | Required |
@ -46,6 +34,31 @@ for to construct your shape, you're likely looking for tangentialArc.
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
### Description
The arc is constructed such that the current position of the sketch is
placed along an imaginary circle of the specified radius, at angleStart
degrees. The resulting arc is the segment of the imaginary circle from
that origin point to angleEnd, radius away from the center of the imaginary
circle.
Unless this makes a lot of sense and feels like what you're looking
for to construct your shape, you're likely looking for tangentialArc.
### Function signature
```kcl
arc(
@sketch: Sketch,
angleStart?: number(Angle),
angleEnd?: number(Angle),
radius?: number(Length),
diameter?: number(Length),
interiorAbsolute?: Point2d,
endAbsolute?: Point2d,
tag?: TagDecl,
): Sketch
```
### Examples

View File

@ -8,20 +8,18 @@ layout: manual
Draw a smooth, continuous, curved line segment from the current origin to the desired (x, y), using a number of control points to shape the curve's shape.
```kcl
bezierCurve(
@sketch: Sketch,
control1?: Point2d,
control2?: Point2d,
end?: Point2d,
control1Absolute?: Point2d,
control2Absolute?: Point2d,
endAbsolute?: Point2d,
tag?: TagDecl,
): Sketch
// Example using relative control points.
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [0, 10])
|> bezierCurve(control1 = [5, 0], control2 = [5, 10], end = [10, 10])
|> line(endAbsolute = [10, 0])
|> close()
example = extrude(exampleSketch, length = 10)
```
### Arguments
| Name | Type | Description | Required |
@ -40,6 +38,21 @@ bezierCurve(
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
### Function signature
```kcl
bezierCurve(
@sketch: Sketch,
control1?: Point2d,
control2?: Point2d,
end?: Point2d,
control1Absolute?: Point2d,
control2Absolute?: Point2d,
endAbsolute?: Point2d,
tag?: TagDecl,
): Sketch
```
### Examples
```kcl

View File

@ -8,17 +8,13 @@ layout: manual
Construct a 2-dimensional circle, of the specified radius, centered at the provided (x, y) origin point.
```kcl
circle(
@sketchOrSurface: Sketch | Plane | Face,
center: Point2d,
radius?: number(Length),
diameter?: number(Length),
tag?: TagDecl,
): Sketch
exampleSketch = startSketchOn(-XZ)
|> circle(center = [0, 0], radius = 10)
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -34,6 +30,18 @@ circle(
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
### Function signature
```kcl
circle(
@sketchOrSurface: Sketch | Plane | Face,
center: Point2d,
radius?: number(Length),
diameter?: number(Length),
tag?: TagDecl,
): Sketch
```
### Examples
```kcl

View File

@ -8,17 +8,12 @@ layout: manual
Construct a circle derived from 3 points.
```kcl
circleThreePoint(
@sketchOrSurface: Sketch | Plane | Face,
p1: Point2d,
p2: Point2d,
p3: Point2d,
tag?: TagDecl,
): Sketch
exampleSketch = startSketchOn(XY)
|> circleThreePoint(p1 = [10, 10], p2 = [20, 8], p3 = [15, 5])
|> extrude(length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -34,6 +29,18 @@ circleThreePoint(
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
### Function signature
```kcl
circleThreePoint(
@sketchOrSurface: Sketch | Plane | Face,
p1: Point2d,
p2: Point2d,
p3: Point2d,
tag?: TagDecl,
): Sketch
```
### Examples
```kcl

View File

@ -8,16 +8,14 @@ layout: manual
Construct a line segment from the current origin back to the profile's origin, ensuring the resulting 2-dimensional sketch is not open-ended.
```kcl
close(
@sketch: Sketch,
tag?: TagDecl,
): Sketch
```
startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [10, 10])
|> line(end = [10, 0])
|> close()
|> extrude(length = 10)
If you want to perform some 3-dimensional operation on a sketch, like
extrude or sweep, you must `close` it first. `close` must be called even
if the end point of the last segment is coincident with the sketch
starting point.
```
### Arguments
@ -30,6 +28,21 @@ starting point.
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
### Description
If you want to perform some 3-dimensional operation on a sketch, like
extrude or sweep, you must `close` it first. `close` must be called even
if the end point of the last segment is coincident with the sketch
starting point.
### Function signature
```kcl
close(
@sketch: Sketch,
tag?: TagDecl,
): Sketch
```
### Examples

View File

@ -8,21 +8,18 @@ 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+]
```
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)
You can provide more than one sketch to extrude, and they will all be
extruded in the same direction.
```
### Arguments
@ -42,6 +39,26 @@ extruded in the same direction.
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
### Description
You can provide more than one sketch to extrude, and they will all be
extruded in the same direction.
### Function signature
```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+]
```
### Examples

View File

@ -8,11 +8,29 @@ layout: manual
Get the shared edge between two faces.
```kcl
getCommonEdge(faces: [TaggedFace; 2]): Edge
// Get an edge shared between two faces, created after a chamfer.
scale = 20
part001 = startSketchOn(XY)
|> startProfile(at = [0, 0])
|> line(end = [0, scale])
|> line(end = [scale, 0])
|> line(end = [0, -scale])
|> close(tag = $line0)
|> extrude(length = 20, tagEnd = $end0)
// We tag the chamfer to reference it later.
|> chamfer(length = 10, tags = [getOppositeEdge(line0)], tag = $chamfer0)
// Get the shared edge between the chamfer and the extrusion.
commonEdge = getCommonEdge(faces = [chamfer0, end0])
// Chamfer the shared edge.
// TODO: uncomment this when ssi for fillets lands
// chamfer(part001, length = 5, tags = [commonEdge])
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +42,12 @@ getCommonEdge(faces: [TaggedFace; 2]): Edge
[`Edge`](/docs/kcl-std/types/std-types-Edge) - An edge of a solid.
### Function signature
```kcl
getCommonEdge(faces: [TaggedFace; 2]): Edge
```
### Examples
```kcl

View File

@ -8,11 +8,20 @@ layout: manual
Get the next adjacent edge to the edge given.
```kcl
getNextAdjacentEdge(@edge: TaggedEdge): Edge
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [10, 0])
|> angledLine(angle = 60deg, length = 10)
|> angledLine(angle = 120deg, length = 10)
|> line(end = [-10, 0])
|> angledLine(angle = 240deg, length = 10, tag = $referenceEdge)
|> close()
example = extrude(exampleSketch, length = 5)
|> fillet(radius = 3, tags = [getNextAdjacentEdge(referenceEdge)])
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +33,12 @@ getNextAdjacentEdge(@edge: TaggedEdge): Edge
[`Edge`](/docs/kcl-std/types/std-types-Edge) - An edge of a solid.
### Function signature
```kcl
getNextAdjacentEdge(@edge: TaggedEdge): Edge
```
### Examples
```kcl

View File

@ -8,11 +8,20 @@ layout: manual
Get the opposite edge to the edge given.
```kcl
getOppositeEdge(@edge: TaggedEdge): Edge
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [10, 0])
|> angledLine(angle = 60deg, length = 10)
|> angledLine(angle = 120deg, length = 10)
|> line(end = [-10, 0])
|> angledLine(angle = 240deg, length = 10, tag = $referenceEdge)
|> close()
example = extrude(exampleSketch, length = 5)
|> fillet(radius = 3, tags = [getOppositeEdge(referenceEdge)])
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +33,12 @@ getOppositeEdge(@edge: TaggedEdge): Edge
[`Edge`](/docs/kcl-std/types/std-types-Edge) - An edge of a solid.
### Function signature
```kcl
getOppositeEdge(@edge: TaggedEdge): Edge
```
### Examples
```kcl

View File

@ -8,11 +8,20 @@ layout: manual
Get the previous adjacent edge to the edge given.
```kcl
getPreviousAdjacentEdge(@edge: TaggedEdge): Edge
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [10, 0])
|> angledLine(angle = 60deg, length = 10)
|> angledLine(angle = 120deg, length = 10)
|> line(end = [-10, 0])
|> angledLine(angle = 240deg, length = 10, tag = $referenceEdge)
|> close()
example = extrude(exampleSketch, length = 5)
|> fillet(radius = 3, tags = [getPreviousAdjacentEdge(referenceEdge)])
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +33,12 @@ getPreviousAdjacentEdge(@edge: TaggedEdge): Edge
[`Edge`](/docs/kcl-std/types/std-types-Edge) - An edge of a solid.
### Function signature
```kcl
getPreviousAdjacentEdge(@edge: TaggedEdge): Edge
```
### Examples
```kcl

View File

@ -8,18 +8,20 @@ layout: manual
Extend the current sketch with a new involute circular curve.
```kcl
involuteCircular(
@sketch: Sketch,
startRadius: number(Length),
endRadius: number(Length),
angle: number(Angle),
reverse?: bool,
tag?: TagDecl,
): Sketch
a = 10
b = 14
startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> involuteCircular(startRadius = a, endRadius = b, angle = 60deg)
|> involuteCircular(
startRadius = a,
endRadius = b,
angle = 60deg,
reverse = true,
)
```
### Arguments
| Name | Type | Description | Required |
@ -36,6 +38,19 @@ involuteCircular(
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
### Function signature
```kcl
involuteCircular(
@sketch: Sketch,
startRadius: number(Length),
endRadius: number(Length),
angle: number(Angle),
reverse?: bool,
tag?: TagDecl,
): Sketch
```
### Examples
```kcl

View File

@ -8,11 +8,18 @@ layout: manual
Extract the 'x' axis value of the last line segment in the provided 2-d sketch.
```kcl
lastSegX(@sketch: Sketch): number(Length)
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [5, 0])
|> line(end = [20, 5])
|> line(end = [lastSegX(%), 0])
|> line(end = [-15, 0])
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +31,12 @@ lastSegX(@sketch: Sketch): number(Length)
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
lastSegX(@sketch: Sketch): number(Length)
```
### Examples
```kcl

View File

@ -8,11 +8,18 @@ layout: manual
Extract the 'y' axis value of the last line segment in the provided 2-d sketch.
```kcl
lastSegY(@sketch: Sketch): number(Length)
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [5, 0])
|> line(end = [20, 5])
|> line(end = [0, lastSegY(%)])
|> line(end = [-15, 0])
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +31,12 @@ lastSegY(@sketch: Sketch): number(Length)
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
lastSegY(@sketch: Sketch): number(Length)
```
### Examples
```kcl

View File

@ -8,16 +8,29 @@ layout: manual
Extend the current sketch with a new straight line.
```kcl
line(
@sketch: Sketch,
endAbsolute?: Point2d,
end?: Point2d,
tag?: TagDecl,
): Sketch
triangle = startSketchOn(XZ)
|> startProfile(at = [0, 0])
// The END argument means it ends at exactly [10, 0].
// This is an absolute measurement, it is NOT relative to
// the start of the sketch.
|> line(endAbsolute = [10, 0])
|> line(endAbsolute = [0, 10])
|> line(endAbsolute = [-10, 0], tag = $thirdLineOfTriangle)
|> close()
|> extrude(length = 5)
box = startSketchOn(XZ)
|> startProfile(at = [10, 10])
// The 'to' argument means move the pen this much.
// So, [10, 0] is a relative distance away from the current point.
|> line(end = [10, 0])
|> line(end = [0, 10])
|> line(end = [-10, 0], tag = $thirdLineOfBox)
|> close()
|> extrude(length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -32,6 +45,17 @@ line(
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
### Function signature
```kcl
line(
@sketch: Sketch,
endAbsolute?: Point2d,
end?: Point2d,
tag?: TagDecl,
): Sketch
```
### Examples
```kcl

View File

@ -8,18 +8,25 @@ layout: manual
Create a 3D surface or solid by interpolating between two or more sketches.
```kcl
loft(
@sketches: [Sketch; 2+],
vDegree?: number(_),
bezApproximateRational?: bool,
baseCurveIndex?: number(_),
tolerance?: number(Length),
tagStart?: TagDecl,
tagEnd?: TagDecl,
): Solid
```
// Loft a square and a triangle.
squareSketch = startSketchOn(XY)
|> startProfile(at = [-100, 200])
|> line(end = [200, 0])
|> line(end = [0, -200])
|> line(end = [-200, 0])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
The sketches need to be closed and on different planes that are parallel.
triangleSketch = startSketchOn(offsetPlane(XY, offset = 75))
|> startProfile(at = [0, 125])
|> line(end = [-15, -30])
|> line(end = [30, 0])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
loft([triangleSketch, squareSketch])
```
### Arguments
@ -37,6 +44,23 @@ The sketches need to be closed and on different planes that are parallel.
[`Solid`](/docs/kcl-std/types/std-types-Solid) - A solid is a collection of extruded surfaces.
### Description
The sketches need to be closed and on different planes that are parallel.
### Function signature
```kcl
loft(
@sketches: [Sketch; 2+],
vDegree?: number(_),
bezApproximateRational?: bool,
baseCurveIndex?: number(_),
tolerance?: number(Length),
tagStart?: TagDecl,
tagEnd?: TagDecl,
): Solid
```
### Examples

View File

@ -8,18 +8,23 @@ layout: manual
Repeat a 2-dimensional sketch some number of times along a partial or complete circle some specified number of times. Each object may additionally be rotated along the circle, ensuring orientation of the solid with respect to the center of the circle is maintained.
```kcl
patternCircular2d(
@sketches: [Sketch; 1+],
instances: number(_),
center: Point2d,
arcDegrees?: number(Angle),
rotateDuplicates?: bool,
useOriginal?: bool,
): [Sketch; 1+]
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [.5, 25])
|> line(end = [0, 5])
|> line(end = [-1, 0])
|> line(end = [0, -5])
|> close()
|> patternCircular2d(
center = [0, 0],
instances = 13,
arcDegrees = 360,
rotateDuplicates = true,
)
example = extrude(exampleSketch, length = 1)
```
### Arguments
| Name | Type | Description | Required |
@ -36,6 +41,19 @@ patternCircular2d(
[`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch)
### Function signature
```kcl
patternCircular2d(
@sketches: [Sketch; 1+],
instances: number(_),
center: Point2d,
arcDegrees?: number(Angle),
rotateDuplicates?: bool,
useOriginal?: bool,
): [Sketch; 1+]
```
### Examples
```kcl

View File

@ -8,17 +8,17 @@ layout: manual
Repeat a 2-dimensional sketch along some dimension, with a dynamic amount of distance between each repetition, some specified number of times.
```kcl
patternLinear2d(
@sketches: [Sketch; 1+],
instances: number(_),
distance: number(Length),
axis: Axis2d | Point2d,
useOriginal?: bool,
): [Sketch; 1+]
// / Pattern using a named axis.
exampleSketch = startSketchOn(XZ)
|> circle(center = [0, 0], radius = 1)
|> patternLinear2d(axis = X, instances = 7, distance = 4)
example = extrude(exampleSketch, length = 1)
```
### Arguments
| Name | Type | Description | Required |
@ -34,6 +34,18 @@ patternLinear2d(
[`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch)
### Function signature
```kcl
patternLinear2d(
@sketches: [Sketch; 1+],
instances: number(_),
distance: number(Length),
axis: Axis2d | Point2d,
useOriginal?: bool,
): [Sketch; 1+]
```
### Examples
```kcl

View File

@ -8,16 +8,18 @@ layout: manual
Just like `patternTransform`, but works on 2D sketches not 3D solids.
```kcl
patternTransform2d(
@sketches: [Sketch; 1+],
instances: number(_),
transform: fn(number(_)): { },
useOriginal?: boolean,
): [Sketch; 1+]
// Each instance will be shifted along the X axis.
fn transform(@id) {
return { translate = [4 * id, 0] }
}
// Sketch 4 circles.
sketch001 = startSketchOn(XZ)
|> circle(center = [0, 0], radius = 2)
|> patternTransform2d(instances = 4, transform = transform)
```
### Arguments
| Name | Type | Description | Required |
@ -32,6 +34,17 @@ patternTransform2d(
[`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch)
### Function signature
```kcl
patternTransform2d(
@sketches: [Sketch; 1+],
instances: number(_),
transform: fn(number(_)): { },
useOriginal?: boolean,
): [Sketch; 1+]
```
### Examples
```kcl

View File

@ -8,17 +8,19 @@ layout: manual
Create a regular polygon with the specified number of sides that is either inscribed or circumscribed around a circle of the specified radius.
```kcl
polygon(
@sketchOrSurface: Sketch | Plane | Face,
radius: number(Length),
numSides: number(_),
center: Point2d,
inscribed?: bool,
): Sketch
// Create a regular hexagon inscribed in a circle of radius 10
hex = startSketchOn(XY)
|> polygon(
radius = 10,
numSides = 6,
center = [0, 0],
inscribed = true,
)
example = extrude(hex, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -34,6 +36,18 @@ polygon(
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
### Function signature
```kcl
polygon(
@sketchOrSurface: Sketch | Plane | Face,
radius: number(Length),
numSides: number(_),
center: Point2d,
inscribed?: bool,
): Sketch
```
### Examples
```kcl

View File

@ -8,11 +8,16 @@ layout: manual
Extract the provided 2-dimensional sketch's profile's origin value.
```kcl
profileStart(@profile: Sketch): Point2d
sketch001 = startSketchOn(XY)
|> startProfile(at = [5, 2])
|> angledLine(angle = 120, length = 50, tag = $seg01)
|> angledLine(angle = segAng(seg01) + 120deg, length = 50)
|> line(end = profileStart(%))
|> close()
|> extrude(length = 20)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +29,12 @@ profileStart(@profile: Sketch): Point2d
[`Point2d`](/docs/kcl-std/types/std-types-Point2d) - A point in two dimensional space.
### Function signature
```kcl
profileStart(@profile: Sketch): Point2d
```
### Examples
```kcl

View File

@ -8,11 +8,14 @@ layout: manual
Extract the provided 2-dimensional sketch's profile's origin's 'x' value.
```kcl
profileStartX(@profile: Sketch): number(Length)
sketch001 = startSketchOn(XY)
|> startProfile(at = [5, 2])
|> angledLine(angle = -26.6, length = 50)
|> angledLine(angle = 90deg, length = 50)
|> angledLine(angle = 30deg, endAbsoluteX = profileStartX(%))
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +27,12 @@ profileStartX(@profile: Sketch): number(Length)
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
profileStartX(@profile: Sketch): number(Length)
```
### Examples
```kcl

View File

@ -8,11 +8,13 @@ layout: manual
Extract the provided 2-dimensional sketch's profile's origin's 'y' value.
```kcl
profileStartY(@profile: Sketch): number(Length)
sketch001 = startSketchOn(XY)
|> startProfile(at = [5, 2])
|> angledLine(angle = -60deg, length = 14)
|> angledLine(angle = 30deg, endAbsoluteY = profileStartY(%))
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +26,12 @@ profileStartY(@profile: Sketch): number(Length)
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
profileStartY(@profile: Sketch): number(Length)
```
### Examples
```kcl

View File

@ -8,29 +8,20 @@ layout: manual
Rotate a sketch around some provided axis, creating a solid from its extent.
```kcl
revolve(
@sketches: [Sketch; 1+],
axis: Axis2d | Edge,
angle?: number(Angle),
tolerance?: number(Length),
symmetric?: bool,
bidirectionalAngle?: number(Angle),
tagStart?: TagDecl,
tagEnd?: TagDecl,
): [Solid; 1+]
part001 = startSketchOn(XY)
|> startProfile(at = [4, 12])
|> line(end = [2, 0])
|> line(end = [0, -6])
|> line(end = [4, -6])
|> line(end = [0, -6])
|> line(end = [-3.75, -4.5])
|> line(end = [0, -5.5])
|> line(end = [-2, 0])
|> close()
|> revolve(axis = Y) // default angle is 360deg
```
This, like extrude, is able to create a 3-dimensional solid from a
2-dimensional sketch. However, unlike extrude, this creates a solid
by using the extent of the sketch as its revolved around an axis rather
than using the extent of the sketch linearly translated through a third
dimension.
Revolve occurs around a local sketch axis rather than a global axis.
You can provide more than one sketch to revolve, and they will all be
revolved around the same axis.
### Arguments
| Name | Type | Description | Required |
@ -48,6 +39,33 @@ revolved around the same axis.
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
### Description
This, like extrude, is able to create a 3-dimensional solid from a
2-dimensional sketch. However, unlike extrude, this creates a solid
by using the extent of the sketch as its revolved around an axis rather
than using the extent of the sketch linearly translated through a third
dimension.
Revolve occurs around a local sketch axis rather than a global axis.
You can provide more than one sketch to revolve, and they will all be
revolved around the same axis.
### Function signature
```kcl
revolve(
@sketches: [Sketch; 1+],
axis: Axis2d | Edge,
angle?: number(Angle),
tolerance?: number(Length),
symmetric?: bool,
bidirectionalAngle?: number(Angle),
tagStart?: TagDecl,
tagEnd?: TagDecl,
): [Solid; 1+]
```
### Examples

View File

@ -8,11 +8,20 @@ layout: manual
Compute the angle (in degrees) of the provided line segment.
```kcl
segAng(@tag: TaggedEdge): number(Angle)
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [10, 0])
|> line(end = [5, 10], tag = $seg01)
|> line(end = [-10, 0])
|> angledLine(angle = segAng(seg01), length = 10)
|> line(end = [-10, 0])
|> angledLine(angle = segAng(seg01), length = -15)
|> close()
example = extrude(exampleSketch, length = 4)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +33,12 @@ segAng(@tag: TaggedEdge): number(Angle)
[`number(Angle)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
segAng(@tag: TaggedEdge): number(Angle)
```
### Examples
```kcl

View File

@ -8,11 +8,30 @@ layout: manual
Compute the ending point of the provided line segment.
```kcl
segEnd(@tag: TaggedEdge): Point2d
w = 15
cube = startSketchOn(XY)
|> startProfile(at = [0, 0])
|> line(end = [w, 0], tag = $line1)
|> line(end = [0, w], tag = $line2)
|> line(end = [-w, 0], tag = $line3)
|> line(end = [0, -w], tag = $line4)
|> close()
|> extrude(length = 5)
fn cylinder(radius, tag) {
return startSketchOn(XY)
|> startProfile(at = [0, 0])
|> circle(radius = radius, center = segEnd(tag))
|> extrude(length = radius)
}
cylinder(radius = 1, tag = line1)
cylinder(radius = 2, tag = line2)
cylinder(radius = 3, tag = line3)
cylinder(radius = 4, tag = line4)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +43,12 @@ segEnd(@tag: TaggedEdge): Point2d
[`Point2d`](/docs/kcl-std/types/std-types-Point2d) - A point in two dimensional space.
### Function signature
```kcl
segEnd(@tag: TaggedEdge): Point2d
```
### Examples
```kcl

View File

@ -8,11 +8,18 @@ layout: manual
Compute the ending point of the provided line segment along the 'x' axis.
```kcl
segEndX(@tag: TaggedEdge): number(Length)
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [20, 0], tag = $thing)
|> line(end = [0, 5])
|> line(end = [segEndX(thing), 0])
|> line(end = [-20, 10])
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +31,12 @@ segEndX(@tag: TaggedEdge): number(Length)
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
segEndX(@tag: TaggedEdge): number(Length)
```
### Examples
```kcl

View File

@ -8,11 +8,19 @@ layout: manual
Compute the ending point of the provided line segment along the 'y' axis.
```kcl
segEndY(@tag: TaggedEdge): number(Length)
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [20, 0])
|> line(end = [0, 3], tag = $thing)
|> line(end = [-10, 0])
|> line(end = [0, segEndY(thing)])
|> line(end = [-10, 0])
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +32,12 @@ segEndY(@tag: TaggedEdge): number(Length)
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
segEndY(@tag: TaggedEdge): number(Length)
```
### Examples
```kcl

View File

@ -8,11 +8,17 @@ layout: manual
Compute the length of the provided line segment.
```kcl
segLen(@tag: TaggedEdge): number(Length)
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> angledLine(angle = 60, length = 10, tag = $thing)
|> tangentialArc(angle = -120deg, radius = 5)
|> angledLine(angle = -60deg, length = segLen(thing))
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +30,12 @@ segLen(@tag: TaggedEdge): number(Length)
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
segLen(@tag: TaggedEdge): number(Length)
```
### Examples
```kcl

View File

@ -8,11 +8,30 @@ layout: manual
Compute the starting point of the provided line segment.
```kcl
segStart(@tag: TaggedEdge): Point2d
w = 15
cube = startSketchOn(XY)
|> startProfile(at = [0, 0])
|> line(end = [w, 0], tag = $line1)
|> line(end = [0, w], tag = $line2)
|> line(end = [-w, 0], tag = $line3)
|> line(end = [0, -w], tag = $line4)
|> close()
|> extrude(length = 5)
fn cylinder(radius, tag) {
return startSketchOn(XY)
|> startProfile(at = [0, 0])
|> circle(radius = radius, center = segStart(tag))
|> extrude(length = radius)
}
cylinder(radius = 1, tag = line1)
cylinder(radius = 2, tag = line2)
cylinder(radius = 3, tag = line3)
cylinder(radius = 4, tag = line4)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +43,12 @@ segStart(@tag: TaggedEdge): Point2d
[`Point2d`](/docs/kcl-std/types/std-types-Point2d) - A point in two dimensional space.
### Function signature
```kcl
segStart(@tag: TaggedEdge): Point2d
```
### Examples
```kcl

View File

@ -8,11 +8,18 @@ layout: manual
Compute the starting point of the provided line segment along the 'x' axis.
```kcl
segStartX(@tag: TaggedEdge): number(Length)
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [20, 0], tag = $thing)
|> line(end = [0, 5])
|> line(end = [20 - segStartX(thing), 0])
|> line(end = [-20, 10])
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +31,12 @@ segStartX(@tag: TaggedEdge): number(Length)
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
segStartX(@tag: TaggedEdge): number(Length)
```
### Examples
```kcl

View File

@ -8,11 +8,19 @@ layout: manual
Compute the starting point of the provided line segment along the 'y' axis.
```kcl
segStartY(@tag: TaggedEdge): number(Length)
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [20, 0])
|> line(end = [0, 3], tag = $thing)
|> line(end = [-10, 0])
|> line(end = [0, 20 - segStartY(thing)])
|> line(end = [-10, 0])
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +32,12 @@ segStartY(@tag: TaggedEdge): number(Length)
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
segStartY(@tag: TaggedEdge): number(Length)
```
### Examples
```kcl

View File

@ -8,15 +8,17 @@ layout: manual
Start a new profile at a given point.
```kcl
startProfile(
@startProfileOn: Plane | Face,
at: Point2d,
tag?: TagDecl,
): Sketch
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [10, 0])
|> line(end = [0, 10])
|> line(end = [-10, 0])
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -30,6 +32,16 @@ startProfile(
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
### Function signature
```kcl
startProfile(
@startProfileOn: Plane | Face,
at: Point2d,
tag?: TagDecl,
): Sketch
```
### Examples
```kcl

View File

@ -8,12 +8,48 @@ layout: manual
Start a new 2-dimensional sketch on a specific plane or face.
```kcl
startSketchOn(
@planeOrSolid: Solid | Plane,
face?: TaggedFace,
): Plane | Face
exampleSketch = startSketchOn(XY)
|> startProfile(at = [0, 0])
|> line(end = [10, 0])
|> line(end = [0, 10])
|> line(end = [-10, 0])
|> close()
example = extrude(exampleSketch, length = 5)
exampleSketch002 = startSketchOn(example, face = END)
|> startProfile(at = [1, 1])
|> line(end = [8, 0])
|> line(end = [0, 8])
|> line(end = [-8, 0])
|> close()
example002 = extrude(exampleSketch002, length = 5)
exampleSketch003 = startSketchOn(example002, face = END)
|> startProfile(at = [2, 2])
|> line(end = [6, 0])
|> line(end = [0, 6])
|> line(end = [-6, 0])
|> close()
example003 = extrude(exampleSketch003, length = 5)
```
### Arguments
| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `planeOrSolid` | [`Solid`](/docs/kcl-std/types/std-types-Solid) or [`Plane`](/docs/kcl-std/types/std-types-Plane) | Profile whose start is being used. | Yes |
| `face` | [`TaggedFace`](/docs/kcl-std/types/std-types-TaggedFace) | Identify a face of a solid if a solid is specified as the input argument (`planeOrSolid`). | No |
### Returns
[`Plane`](/docs/kcl-std/types/std-types-Plane) or [`Face`](/docs/kcl-std/types/std-types-Face)
### Description
### Sketch on Face Behavior
There are some important behaviors to understand when sketching on a face:
@ -31,17 +67,14 @@ The point is if you want to export the result of a sketch on a face, you
only need to export the final Solid that was created from the sketch on the
face, since it will include all the parent faces and Solids.
### Arguments
| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `planeOrSolid` | [`Solid`](/docs/kcl-std/types/std-types-Solid) or [`Plane`](/docs/kcl-std/types/std-types-Plane) | Profile whose start is being used. | Yes |
| `face` | [`TaggedFace`](/docs/kcl-std/types/std-types-TaggedFace) | Identify a face of a solid if a solid is specified as the input argument (`planeOrSolid`). | No |
### Returns
[`Plane`](/docs/kcl-std/types/std-types-Plane) or [`Face`](/docs/kcl-std/types/std-types-Face)
### Function signature
```kcl
startSketchOn(
@planeOrSolid: Solid | Plane,
face?: TaggedFace,
): Plane | Face
```
### Examples

View File

@ -8,14 +8,19 @@ layout: manual
Use a 2-dimensional sketch to cut a hole in another 2-dimensional sketch.
```kcl
subtract2d(
@sketch: Sketch,
tool: [Sketch; 1+],
): Sketch
exampleSketch = startSketchOn(XY)
|> startProfile(at = [0, 0])
|> line(end = [0, 5])
|> line(end = [5, 0])
|> line(end = [0, -5])
|> close()
|> subtract2d(tool = circle(center = [1, 1], radius = .25))
|> subtract2d(tool = circle(center = [1, 4], radius = .25))
example = extrude(exampleSketch, length = 1)
```
### Arguments
| Name | Type | Description | Required |
@ -28,6 +33,15 @@ subtract2d(
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
### Function signature
```kcl
subtract2d(
@sketch: Sketch,
tool: [Sketch; 1+],
): Sketch
```
### Examples
```kcl

View File

@ -8,26 +8,28 @@ layout: manual
Extrude a sketch along a path.
```kcl
sweep(
@sketches: [Sketch; 1+],
path: Sketch | Helix,
sectional?: bool,
tolerance?: number(Length),
relativeTo?: string,
tagStart?: TagDecl,
tagEnd?: TagDecl,
): [Solid; 1+]
// Create a pipe using a sweep.
// Create a path for the sweep.
sweepPath = startSketchOn(XZ)
|> startProfile(at = [0.05, 0.05])
|> line(end = [0, 7])
|> tangentialArc(angle = 90deg, radius = 5)
|> line(end = [-3, 0])
|> tangentialArc(angle = -90deg, 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)
|> subtract2d(tool = pipeHole)
|> sweep(path = sweepPath)
```
This, like extrude, is able to create a 3-dimensional solid from a
2-dimensional sketch. However, unlike extrude, this creates a solid
by using the extent of the sketch as its path. This is useful for
creating more complex shapes that can't be created with a simple
extrusion.
You can provide more than one sketch to sweep, and they will all be
swept along the same path.
### Arguments
| Name | Type | Description | Required |
@ -44,6 +46,30 @@ swept along the same path.
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
### Description
This, like extrude, is able to create a 3-dimensional solid from a
2-dimensional sketch. However, unlike extrude, this creates a solid
by using the extent of the sketch as its path. This is useful for
creating more complex shapes that can't be created with a simple
extrusion.
You can provide more than one sketch to sweep, and they will all be
swept along the same path.
### Function signature
```kcl
sweep(
@sketches: [Sketch; 1+],
path: Sketch | Helix,
sectional?: bool,
tolerance?: number(Length),
relativeTo?: string,
tagStart?: TagDecl,
tagEnd?: TagDecl,
): [Solid; 1+]
```
### Examples

View File

@ -8,11 +8,19 @@ layout: manual
Returns the angle coming out of the end of the segment in degrees.
```kcl
tangentToEnd(@tag: TaggedEdge): number(Angle)
// Horizontal pill.
pillSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [20, 0])
|> tangentialArc(end = [0, 10], tag = $arc1)
|> angledLine(angle = tangentToEnd(arc1), length = 20)
|> tangentialArc(end = [0, -10])
|> close()
pillExtrude = extrude(pillSketch, length = 10)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +32,12 @@ tangentToEnd(@tag: TaggedEdge): number(Angle)
[`number(Angle)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
tangentToEnd(@tag: TaggedEdge): number(Angle)
```
### Examples
```kcl

View File

@ -8,22 +8,16 @@ layout: manual
Starting at the current sketch's origin, draw a curved line segment along some part of an imaginary circle until it reaches the desired (x, y) coordinates.
```kcl
tangentialArc(
@sketch: Sketch,
endAbsolute?: Point2d,
end?: Point2d,
radius?: number(Length),
diameter?: number(Length),
angle?: number(Angle),
tag?: TagDecl,
): Sketch
```
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> angledLine(angle = 45deg, length = 10)
|> tangentialArc(end = [0, -10])
|> line(end = [-10, 0])
|> close()
When using radius and angle, draw a curved line segment along part of an
imaginary circle. The arc is constructed such that the last line segment is
placed tangent to the imaginary circle of the specified radius. The
resulting arc is the segment of the imaginary circle from that tangent point
for 'angle' degrees along the imaginary circle.
example = extrude(exampleSketch, length = 10)
```
### Arguments
@ -41,6 +35,27 @@ for 'angle' degrees along the imaginary circle.
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
### Description
When using radius and angle, draw a curved line segment along part of an
imaginary circle. The arc is constructed such that the last line segment is
placed tangent to the imaginary circle of the specified radius. The
resulting arc is the segment of the imaginary circle from that tangent point
for 'angle' degrees along the imaginary circle.
### Function signature
```kcl
tangentialArc(
@sketch: Sketch,
endAbsolute?: Point2d,
end?: Point2d,
radius?: number(Length),
diameter?: number(Length),
angle?: number(Angle),
tag?: TagDecl,
): Sketch
```
### Examples

View File

@ -8,16 +8,20 @@ layout: manual
Draw a line relative to the current origin to a specified distance away from the current position along the 'x' axis.
```kcl
xLine(
@sketch: Sketch,
length?: number(Length),
endAbsolute?: number(Length),
tag?: TagDecl,
): Sketch
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> xLine(length = 15)
|> angledLine(angle = 80deg, length = 15)
|> line(end = [8, -10])
|> xLine(length = 10)
|> angledLine(angle = 120deg, length = 30)
|> xLine(length = -15)
|> close()
example = extrude(exampleSketch, length = 10)
```
### Arguments
| Name | Type | Description | Required |
@ -32,6 +36,17 @@ xLine(
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
### Function signature
```kcl
xLine(
@sketch: Sketch,
length?: number(Length),
endAbsolute?: number(Length),
tag?: TagDecl,
): Sketch
```
### Examples
```kcl

View File

@ -8,16 +8,18 @@ layout: manual
Draw a line relative to the current origin to a specified distance away from the current position along the 'y' axis.
```kcl
yLine(
@sketch: Sketch,
length?: number(Length),
endAbsolute?: number(Length),
tag?: TagDecl,
): Sketch
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> yLine(length = 15)
|> angledLine(angle = 30deg, length = 15)
|> line(end = [8, -10])
|> yLine(length = -5)
|> close()
example = extrude(exampleSketch, length = 10)
```
### Arguments
| Name | Type | Description | Required |
@ -32,6 +34,17 @@ yLine(
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
### Function signature
```kcl
yLine(
@sketch: Sketch,
length?: number(Length),
endAbsolute?: number(Length),
tag?: TagDecl,
): Sketch
```
### Examples
```kcl

View File

@ -8,15 +8,19 @@ layout: manual
Set the appearance of a solid. This only works on solids, not sketches or individual paths.
```kcl
appearance(
@solids: [Solid; 1+] | ImportedGeometry,
color: string,
metalness?: number(_),
roughness?: number(_),
): [Solid; 1+] | ImportedGeometry
```
// Add color to an extruded solid.
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(endAbsolute = [10, 0])
|> line(endAbsolute = [0, 10])
|> line(endAbsolute = [-10, 0])
|> close()
This will work on any solid, including extruded solids, revolved solids, and shelled solids.
example = extrude(exampleSketch, length = 5)
// There are other options besides 'color', but they're optional.
|> appearance(color = '#ff0000')
```
### Arguments
@ -31,6 +35,20 @@ This will work on any solid, including extruded solids, revolved solids, and she
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) or [`ImportedGeometry`](/docs/kcl-std/types/std-types-ImportedGeometry)
### Description
This will work on any solid, including extruded solids, revolved solids, and shelled solids.
### Function signature
```kcl
appearance(
@solids: [Solid; 1+] | ImportedGeometry,
color: string,
metalness?: number(_),
roughness?: number(_),
): [Solid; 1+] | ImportedGeometry
```
### Examples

View File

@ -8,17 +8,31 @@ layout: manual
Cut a straight transitional edge along a tagged path.
```kcl
chamfer(
@solid: Solid,
length: number(Length),
tags: [Edge; 1+],
tag?: TagDecl,
): Solid
```
// Chamfer a mounting plate.
width = 20
length = 10
thickness = 1
chamferLength = 2
Chamfer is similar in function and use to a fillet, except
a fillet will blend the transition along an edge, rather than cut
a sharp, straight transitional edge.
mountingPlateSketch = startSketchOn(XY)
|> startProfile(at = [-width / 2, -length / 2])
|> line(endAbsolute = [width / 2, -length / 2], tag = $edge1)
|> line(endAbsolute = [width / 2, length / 2], tag = $edge2)
|> line(endAbsolute = [-width / 2, length / 2], tag = $edge3)
|> close(tag = $edge4)
mountingPlate = extrude(mountingPlateSketch, length = thickness)
|> chamfer(
length = chamferLength,
tags = [
getNextAdjacentEdge(edge1),
getNextAdjacentEdge(edge2),
getNextAdjacentEdge(edge3),
getNextAdjacentEdge(edge4)
],
)
```
### Arguments
@ -33,6 +47,22 @@ a sharp, straight transitional edge.
[`Solid`](/docs/kcl-std/types/std-types-Solid) - A solid is a collection of extruded surfaces.
### Description
Chamfer is similar in function and use to a fillet, except
a fillet will blend the transition along an edge, rather than cut
a sharp, straight transitional edge.
### Function signature
```kcl
chamfer(
@solid: Solid,
length: number(Length),
tags: [Edge; 1+],
tag?: TagDecl,
): Solid
```
### Examples

View File

@ -8,18 +8,30 @@ layout: manual
Blend a transitional edge along a tagged path, smoothing the sharp edge.
```kcl
fillet(
@solid: Solid,
radius: number(Length),
tags: [Edge; 1+],
tolerance?: number(Length),
tag?: TagDecl,
): Solid
```
width = 20
length = 10
thickness = 1
filletRadius = 2
Fillet is similar in function and use to a chamfer, except
a chamfer will cut a sharp transition along an edge while fillet
will smoothly blend the transition.
mountingPlateSketch = startSketchOn(XY)
|> startProfile(at = [-width / 2, -length / 2])
|> line(endAbsolute = [width / 2, -length / 2], tag = $edge1)
|> line(endAbsolute = [width / 2, length / 2], tag = $edge2)
|> line(endAbsolute = [-width / 2, length / 2], tag = $edge3)
|> close(tag = $edge4)
mountingPlate = extrude(mountingPlateSketch, length = thickness)
|> fillet(
radius = filletRadius,
tags = [
getNextAdjacentEdge(edge1),
getNextAdjacentEdge(edge2),
getNextAdjacentEdge(edge3),
getNextAdjacentEdge(edge4)
],
)
```
### Arguments
@ -35,6 +47,23 @@ will smoothly blend the transition.
[`Solid`](/docs/kcl-std/types/std-types-Solid) - A solid is a collection of extruded surfaces.
### Description
Fillet is similar in function and use to a chamfer, except
a chamfer will cut a sharp transition along an edge while fillet
will smoothly blend the transition.
### Function signature
```kcl
fillet(
@solid: Solid,
radius: number(Length),
tags: [Edge; 1+],
tolerance?: number(Length),
tag?: TagDecl,
): Solid
```
### Examples

View File

@ -8,14 +8,17 @@ layout: manual
Make the inside of a 3D object hollow.
```kcl
hollow(
@solid: Solid,
thickness: number(Length),
): Solid
```
// Hollow a basic sketch.
firstSketch = startSketchOn(XY)
|> startProfile(at = [-12, 12])
|> line(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0])
|> close()
|> extrude(length = 6)
|> hollow(thickness = 0.25)
Remove volume from a 3-dimensional shape such that a wall of the
provided thickness remains around the exterior of the shape.
```
### Arguments
@ -28,6 +31,19 @@ provided thickness remains around the exterior of the shape.
[`Solid`](/docs/kcl-std/types/std-types-Solid) - A solid is a collection of extruded surfaces.
### Description
Remove volume from a 3-dimensional shape such that a wall of the
provided thickness remains around the exterior of the shape.
### Function signature
```kcl
hollow(
@solid: Solid,
thickness: number(Length),
): Solid
```
### Examples

View File

@ -8,16 +8,26 @@ layout: manual
Intersect returns the shared volume between multiple solids, preserving only overlapping regions.
```kcl
intersect(
@solids: [Solid; 2+],
tolerance?: number(Length),
): [Solid; 1+]
```
// Intersect two cubes using the stdlib functions.
Intersect computes the geometric intersection of multiple solid bodies,
returning a new solid representing the volume that is common to all input
solids. This operation is useful for determining shared material regions,
verifying fit, and analyzing overlapping geometries in assemblies.
fn cube(center, size) {
return startSketchOn(XY)
|> startProfile(at = [center[0] - size, center[1] - size])
|> line(endAbsolute = [center[0] + size, center[1] - size])
|> line(endAbsolute = [center[0] + size, center[1] + size])
|> line(endAbsolute = [center[0] - size, center[1] + size])
|> close()
|> extrude(length = 10)
}
part001 = cube(center = [0, 0], size = 10)
part002 = cube(center = [7, 3], size = 5)
|> translate(z = 1)
intersectedPart = intersect([part001, part002])
```
### Arguments
@ -30,6 +40,21 @@ verifying fit, and analyzing overlapping geometries in assemblies.
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
### Description
Intersect computes the geometric intersection of multiple solid bodies,
returning a new solid representing the volume that is common to all input
solids. This operation is useful for determining shared material regions,
verifying fit, and analyzing overlapping geometries in assemblies.
### Function signature
```kcl
intersect(
@solids: [Solid; 2+],
tolerance?: number(Length),
): [Solid; 1+]
```
### Examples

View File

@ -8,19 +8,23 @@ layout: manual
Repeat a 3-dimensional solid some number of times along a partial or complete circle some specified number of times. Each object may additionally be rotated along the circle, ensuring orientation of the solid with respect to the center of the circle is maintained.
```kcl
patternCircular3d(
@solids: [Solid; 1+],
instances: number(_),
axis: Axis3d | Point3d,
center: Point3d,
arcDegrees?: number(deg),
rotateDuplicates?: bool,
useOriginal?: bool,
): [Solid; 1+]
// / Pattern using a named axis.
exampleSketch = startSketchOn(XZ)
|> circle(center = [0, 0], radius = 1)
example = extrude(exampleSketch, length = -5)
|> patternCircular3d(
axis = X,
center = [10, -20, 0],
instances = 11,
arcDegrees = 360,
rotateDuplicates = true,
)
```
### Arguments
| Name | Type | Description | Required |
@ -38,6 +42,20 @@ patternCircular3d(
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
### Function signature
```kcl
patternCircular3d(
@solids: [Solid; 1+],
instances: number(_),
axis: Axis3d | Point3d,
center: Point3d,
arcDegrees?: number(deg),
rotateDuplicates?: bool,
useOriginal?: bool,
): [Solid; 1+]
```
### Examples
```kcl

View File

@ -8,17 +8,21 @@ layout: manual
Repeat a 3-dimensional solid along a linear path, with a dynamic amount of distance between each repetition, some specified number of times.
```kcl
patternLinear3d(
@solids: [Solid; 1+],
instances: number(_),
distance: number(Length),
axis: Axis3d | Point3d,
useOriginal?: bool,
): [Solid; 1+]
// / Pattern using a named axis.
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> line(end = [0, 2])
|> line(end = [3, 1])
|> line(end = [0, -4])
|> close()
example = extrude(exampleSketch, length = 1)
|> patternLinear3d(axis = X, instances = 7, distance = 6)
```
### Arguments
| Name | Type | Description | Required |
@ -34,6 +38,18 @@ patternLinear3d(
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
### Function signature
```kcl
patternLinear3d(
@solids: [Solid; 1+],
instances: number(_),
distance: number(Length),
axis: Axis3d | Point3d,
useOriginal?: bool,
): [Solid; 1+]
```
### Examples
```kcl

View File

@ -8,14 +8,34 @@ layout: manual
Repeat a 3-dimensional solid, changing it each time.
```kcl
patternTransform(
@solids: [Solid; 1+],
instances: number(_),
transform: fn(number(_)): { },
useOriginal?: bool,
): [Solid; 1+]
// Each instance will be shifted along the X axis.
fn transform(@id) {
return { translate = [4 * id, 0, 0] }
}
// Sketch 4 cylinders.
sketch001 = startSketchOn(XZ)
|> circle(center = [0, 0], radius = 2)
|> extrude(length = 5)
|> patternTransform(instances = 4, transform = transform)
```
### Arguments
| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `solids` | [`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) | The solid(s) to duplicate. | Yes |
| `instances` | [`number(_)`](/docs/kcl-std/types/std-types-number) | The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect. | Yes |
| `transform` | [`fn(number(_)): { }`](/docs/kcl-std/types/std-types-fn) | How each replica should be transformed. The transform function takes a single parameter: an integer representing which number replication the transform is for. E.g. the first replica to be transformed will be passed the argument `1`. This simplifies your math: the transform function can rely on id `0` being the original instance passed into the `patternTransform`. See the examples. | Yes |
| `useOriginal` | [`bool`](/docs/kcl-std/types/std-types-bool) | If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. | No |
### Returns
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
### Description
Replicates the 3D solid, applying a transformation function to each replica.
Transformation function could alter rotation, scale, visibility, position, etc.
@ -54,19 +74,16 @@ Its properties are:
- `rotation.origin` (either "local" i.e. rotate around its own center, "global" i.e. rotate around the scene's center, or a 3D point, defaults to "local")
### Arguments
| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `solids` | [`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) | The solid(s) to duplicate. | Yes |
| `instances` | [`number(_)`](/docs/kcl-std/types/std-types-number) | The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect. | Yes |
| `transform` | [`fn(number(_)): { }`](/docs/kcl-std/types/std-types-fn) | How each replica should be transformed. The transform function takes a single parameter: an integer representing which number replication the transform is for. E.g. the first replica to be transformed will be passed the argument `1`. This simplifies your math: the transform function can rely on id `0` being the original instance passed into the `patternTransform`. See the examples. | Yes |
| `useOriginal` | [`bool`](/docs/kcl-std/types/std-types-bool) | If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. | No |
### Returns
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
### Function signature
```kcl
patternTransform(
@solids: [Solid; 1+],
instances: number(_),
transform: fn(number(_)): { },
useOriginal?: bool,
): [Solid; 1+]
```
### Examples

View File

@ -8,15 +8,20 @@ layout: manual
Remove volume from a 3-dimensional shape such that a wall of the provided thickness remains, taking volume starting at the provided face, leaving it open in that direction.
```kcl
shell(
@solids: [Solid; 1+],
thickness: number(Length),
faces: [TaggedFace; 1+],
): [Solid]
// Remove the end face for the extrusion.
firstSketch = startSketchOn(XY)
|> startProfile(at = [-12, 12])
|> line(end = [24, 0])
|> line(end = [0, -24])
|> line(end = [-24, 0])
|> close()
|> extrude(length = 6)
// Remove the end face for the extrusion.
shell(firstSketch, faces = [END], thickness = 0.25)
```
### Arguments
| Name | Type | Description | Required |
@ -30,6 +35,16 @@ shell(
[`[Solid]`](/docs/kcl-std/types/std-types-Solid)
### Function signature
```kcl
shell(
@solids: [Solid; 1+],
thickness: number(Length),
faces: [TaggedFace; 1+],
): [Solid]
```
### Examples
```kcl

View File

@ -8,18 +8,26 @@ layout: manual
Subtract removes tool solids from base solids, leaving the remaining material.
```kcl
subtract(
@solids: [Solid; 1+],
tools: [Solid],
tolerance?: number(Length),
): [Solid; 1+]
```
// Subtract a cylinder from a cube using the stdlib functions.
Performs a bool subtraction operation, removing the volume of one or more
tool solids from one or more base solids. The result is a new solid
representing the material that remains after all tool solids have been cut
away. This function is essential for machining simulations, cavity creation,
and complex multi-body part modeling.
fn cube(center, size) {
return startSketchOn(XY)
|> startProfile(at = [center[0] - size, center[1] - size])
|> line(endAbsolute = [center[0] + size, center[1] - size])
|> line(endAbsolute = [center[0] + size, center[1] + size])
|> line(endAbsolute = [center[0] - size, center[1] + size])
|> close()
|> extrude(length = 10)
}
part001 = cube(center = [0, 0], size = 10)
part002 = cube(center = [7, 3], size = 5)
|> translate(z = 1)
subtractedPart = subtract([part001], tools = [part002])
```
### Arguments
@ -33,6 +41,23 @@ and complex multi-body part modeling.
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
### Description
Performs a bool subtraction operation, removing the volume of one or more
tool solids from one or more base solids. The result is a new solid
representing the material that remains after all tool solids have been cut
away. This function is essential for machining simulations, cavity creation,
and complex multi-body part modeling.
### Function signature
```kcl
subtract(
@solids: [Solid; 1+],
tools: [Solid],
tolerance?: number(Length),
): [Solid; 1+]
```
### Examples

View File

@ -8,14 +8,27 @@ layout: manual
Union two or more solids into a single solid.
```kcl
union(
@solids: [Solid; 2+],
tolerance?: number(Length),
): [Solid; 1+]
// Union two cubes using the stdlib functions.
fn cube(center, size) {
return startSketchOn(XY)
|> startProfile(at = [center[0] - size, center[1] - size])
|> line(endAbsolute = [center[0] + size, center[1] - size])
|> line(endAbsolute = [center[0] + size, center[1] + size])
|> line(endAbsolute = [center[0] - size, center[1] + size])
|> close()
|> extrude(length = 10)
}
part001 = cube(center = [0, 0], size = 10)
part002 = cube(center = [7, 3], size = 5)
|> translate(z = 1)
unionedPart = union([part001, part002])
```
### Arguments
| Name | Type | Description | Required |
@ -28,6 +41,15 @@ union(
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
### Function signature
```kcl
union(
@solids: [Solid; 2+],
tolerance?: number(Length),
): [Solid; 1+]
```
### Examples
```kcl

View File

@ -8,13 +8,22 @@ layout: manual
Mirror a sketch.
```kcl
mirror2d(
@sketches: [Sketch; 1+],
axis: Axis2d | Edge,
): Sketch
```
// Mirror an un-closed sketch across the Y axis.
sketch001 = startSketchOn(XZ)
|> startProfile(at = [0, 10])
|> line(end = [15, 0])
|> line(end = [-7, -3])
|> line(end = [9, -1])
|> line(end = [-8, -5])
|> line(end = [9, -3])
|> line(end = [-8, -3])
|> line(end = [9, -1])
|> line(end = [-19, -0])
|> mirror2d(axis = Y)
Mirror occurs around a local sketch axis rather than a global axis.
example = extrude(sketch001, length = 10)
```
### Arguments
@ -27,6 +36,18 @@ Mirror occurs around a local sketch axis rather than a global axis.
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
### Description
Mirror occurs around a local sketch axis rather than a global axis.
### Function signature
```kcl
mirror2d(
@sketches: [Sketch; 1+],
axis: Axis2d | Edge,
): Sketch
```
### Examples

View File

@ -8,17 +8,47 @@ layout: manual
Rotate a solid or a sketch.
```kcl
rotate(
@objects: [Solid; 1+] | [Sketch; 1+] | ImportedGeometry,
roll?: number(Angle),
pitch?: number(Angle),
yaw?: number(Angle),
axis?: Axis3d | Point3d,
angle?: number(Angle),
global?: bool,
): [Solid; 1+] | [Sketch; 1+] | ImportedGeometry
// Rotate a pipe with roll, pitch, and yaw.
// Create a path for the sweep.
sweepPath = startSketchOn(XZ)
|> startProfile(at = [0.05, 0.05])
|> line(end = [0, 7])
|> tangentialArc(angle = 90deg, radius = 5)
|> line(end = [-3, 0])
|> tangentialArc(angle = -90deg, 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)
|> subtract2d(tool = pipeHole)
|> sweep(path = sweepPath)
|> rotate(roll = 10, pitch = 10, yaw = 90)
```
### Arguments
| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `objects` | [`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) or [`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch) or [`ImportedGeometry`](/docs/kcl-std/types/std-types-ImportedGeometry) | The solid, sketch, or set of solids or sketches to rotate. | Yes |
| `roll` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | The roll angle. Must be between -360deg and 360deg. | No |
| `pitch` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | The pitch angle. Must be between -360deg and 360deg. | No |
| `yaw` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | The yaw angle. Must be between -360deg and 360deg. | No |
| `axis` | [`Axis3d`](/docs/kcl-std/types/std-types-Axis3d) or [`Point3d`](/docs/kcl-std/types/std-types-Point3d) | The axis to rotate around. Must be used with `angle`. | No |
| `angle` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | The angle to rotate. Must be used with `axis`. Must be between -360deg and 360deg. | No |
| `global` | [`bool`](/docs/kcl-std/types/std-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
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) or [`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch) or [`ImportedGeometry`](/docs/kcl-std/types/std-types-ImportedGeometry)
### Description
This is really useful for assembling parts together. You can create a part
and then rotate it to the correct orientation.
@ -46,22 +76,19 @@ So, in the context of a 3D model:
When rotating a part around an axis, you specify the axis of rotation and the angle of
rotation.
### Arguments
| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `objects` | [`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) or [`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch) or [`ImportedGeometry`](/docs/kcl-std/types/std-types-ImportedGeometry) | The solid, sketch, or set of solids or sketches to rotate. | Yes |
| `roll` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | The roll angle. Must be between -360deg and 360deg. | No |
| `pitch` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | The pitch angle. Must be between -360deg and 360deg. | No |
| `yaw` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | The yaw angle. Must be between -360deg and 360deg. | No |
| `axis` | [`Axis3d`](/docs/kcl-std/types/std-types-Axis3d) or [`Point3d`](/docs/kcl-std/types/std-types-Point3d) | The axis to rotate around. Must be used with `angle`. | No |
| `angle` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | The angle to rotate. Must be used with `axis`. Must be between -360deg and 360deg. | No |
| `global` | [`bool`](/docs/kcl-std/types/std-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
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) or [`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch) or [`ImportedGeometry`](/docs/kcl-std/types/std-types-ImportedGeometry)
### Function signature
```kcl
rotate(
@objects: [Solid; 1+] | [Sketch; 1+] | ImportedGeometry,
roll?: number(Angle),
pitch?: number(Angle),
yaw?: number(Angle),
axis?: Axis3d | Point3d,
angle?: number(Angle),
global?: bool,
): [Solid; 1+] | [Sketch; 1+] | ImportedGeometry
```
### Examples

View File

@ -8,28 +8,29 @@ layout: manual
Scale a solid or a sketch.
```kcl
scale(
@objects: [Solid; 1+] | [Sketch; 1+] | ImportedGeometry,
x?: number(_),
y?: number(_),
z?: number(_),
global?: bool,
): [Solid; 1+] | [Sketch; 1+] | ImportedGeometry
// Scale a pipe.
// Create a path for the sweep.
sweepPath = startSketchOn(XZ)
|> startProfile(at = [0.05, 0.05])
|> line(end = [0, 7])
|> tangentialArc(angle = 90deg, radius = 5)
|> line(end = [-3, 0])
|> tangentialArc(angle = -90deg, 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)
|> subtract2d(tool = pipeHole)
|> sweep(path = sweepPath)
|> scale(z = 2.5)
```
This is really useful for resizing parts. You can create a part and then scale it to the
correct size.
For sketches, you can use this to scale a sketch and then loft it with another sketch.
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)`.
### Arguments
| Name | Type | Description | Required |
@ -44,6 +45,32 @@ look like the model moves and gets bigger at the same time. Say you have a squar
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) or [`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch) or [`ImportedGeometry`](/docs/kcl-std/types/std-types-ImportedGeometry)
### Description
This is really useful for resizing parts. You can create a part and then scale it to the
correct size.
For sketches, you can use this to scale a sketch and then loft it with another sketch.
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)`.
### Function signature
```kcl
scale(
@objects: [Solid; 1+] | [Sketch; 1+] | ImportedGeometry,
x?: number(_),
y?: number(_),
z?: number(_),
global?: bool,
): [Solid; 1+] | [Sketch; 1+] | ImportedGeometry
```
### Examples

View File

@ -8,21 +8,29 @@ layout: manual
Move a solid or a sketch.
```kcl
translate(
@objects: [Solid; 1+] | [Sketch; 1+] | ImportedGeometry,
x?: number(Length),
y?: number(Length),
z?: number(Length),
global?: bool,
): [Solid; 1+] | [Sketch; 1+] | ImportedGeometry
// Move a pipe.
// Create a path for the sweep.
sweepPath = startSketchOn(XZ)
|> startProfile(at = [0.05, 0.05])
|> line(end = [0, 7])
|> tangentialArc(angle = 90deg, radius = 5)
|> line(end = [-3, 0])
|> tangentialArc(angle = -90deg, 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)
|> subtract2d(tool = pipeHole)
|> sweep(path = sweepPath)
|> translate(x = 1.0, y = 1.0, z = 2.5)
```
This is really useful for assembling parts together. You can create a part
and then move it to the correct location.
Translate is really useful for sketches if you want to move a sketch
and then rotate it using the `rotate` function to create a loft.
### Arguments
| Name | Type | Description | Required |
@ -37,6 +45,25 @@ and then rotate it using the `rotate` function to create a loft.
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) or [`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch) or [`ImportedGeometry`](/docs/kcl-std/types/std-types-ImportedGeometry)
### Description
This is really useful for assembling parts together. You can create a part
and then move it to the correct location.
Translate is really useful for sketches if you want to move a sketch
and then rotate it using the `rotate` function to create a loft.
### Function signature
```kcl
translate(
@objects: [Solid; 1+] | [Sketch; 1+] | ImportedGeometry,
x?: number(Length),
y?: number(Length),
z?: number(Length),
global?: bool,
): [Solid; 1+] | [Sketch; 1+] | ImportedGeometry
```
### Examples

View File

@ -7,11 +7,6 @@ layout: manual
Convert a number to centimeters from its current units.
```kcl
units::toCentimeters(@num: number(Length)): number(cm)
```
### Arguments
@ -24,4 +19,10 @@ units::toCentimeters(@num: number(Length)): number(cm)
[`number(cm)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
units::toCentimeters(@num: number(Length)): number(cm)
```

View File

@ -8,11 +8,16 @@ layout: manual
Converts a number to degrees from its current units.
```kcl
units::toDegrees(@num: number(Angle)): number(deg)
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> angledLine(angle = 50deg, length = 70 * cos(units::toDegrees((PI / 4): number(rad))))
|> yLine(endAbsolute = 0)
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +29,12 @@ units::toDegrees(@num: number(Angle)): number(deg)
[`number(deg)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
units::toDegrees(@num: number(Angle)): number(deg)
```
### Examples
```kcl

View File

@ -7,11 +7,6 @@ layout: manual
Convert a number to feet from its current units.
```kcl
units::toFeet(@num: number(Length)): number(ft)
```
### Arguments
@ -24,4 +19,10 @@ units::toFeet(@num: number(Length)): number(ft)
[`number(ft)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
units::toFeet(@num: number(Length)): number(ft)
```

View File

@ -7,11 +7,6 @@ layout: manual
Convert a number to inches from its current units.
```kcl
units::toInches(@num: number(Length)): number(in)
```
### Arguments
@ -24,4 +19,10 @@ units::toInches(@num: number(Length)): number(in)
[`number(in)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
units::toInches(@num: number(Length)): number(in)
```

View File

@ -7,11 +7,6 @@ layout: manual
Convert a number to meters from its current units.
```kcl
units::toMeters(@num: number(Length)): number(m)
```
### Arguments
@ -24,4 +19,10 @@ units::toMeters(@num: number(Length)): number(m)
[`number(m)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
units::toMeters(@num: number(Length)): number(m)
```

View File

@ -7,11 +7,6 @@ layout: manual
Convert a number to millimeters from its current units.
```kcl
units::toMillimeters(@num: number(Length)): number(mm)
```
### Arguments
@ -24,4 +19,10 @@ units::toMillimeters(@num: number(Length)): number(mm)
[`number(mm)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
units::toMillimeters(@num: number(Length)): number(mm)
```

View File

@ -8,11 +8,16 @@ layout: manual
Converts a number to radians from its current units.
```kcl
units::toRadians(@num: number(Angle)): number(rad)
exampleSketch = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> angledLine(angle = 50deg, length = 70 * cos(units::toRadians(45deg)))
|> yLine(endAbsolute = 0)
|> close()
example = extrude(exampleSketch, length = 5)
```
### Arguments
| Name | Type | Description | Required |
@ -24,6 +29,12 @@ units::toRadians(@num: number(Angle)): number(rad)
[`number(rad)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
units::toRadians(@num: number(Angle)): number(rad)
```
### Examples
```kcl

View File

@ -7,11 +7,6 @@ layout: manual
Converts a number to yards from its current units.
```kcl
units::toYards(@num: number(Length)): number(yd)
```
### Arguments
@ -24,4 +19,10 @@ units::toYards(@num: number(Length)): number(yd)
[`number(yd)`](/docs/kcl-std/types/std-types-number) - A number.
### Function signature
```kcl
units::toYards(@num: number(Length)): number(yd)
```

View File

@ -11,11 +11,13 @@ layout: manual
{{/if}}
{{{summary}}}
{{#if examples}}
{{#if examples.0.content}}
```kcl
{{{fn_signature}}}
{{{examples.0.content}}}
```
{{{description}}}
{{/if}}
{{/if}}
{{#if args}}
### Arguments
@ -33,6 +35,17 @@ layout: manual
`{{return_value.type_}}`{{#if return_value.description}} - {{{firstLine return_value.description}}}{{/if}}
{{/if}}
{{#if description}}
### Description
{{{description}}}
{{/if}}
### Function signature
```kcl
{{{fn_signature}}}
```
{{#if examples}}
### Examples