Compare commits
1 Commits
main
...
nrc-doc-si
Author | SHA1 | Date | |
---|---|---|---|
ff1be99351 |
@ -8,11 +8,13 @@ layout: manual
|
|||||||
Build a color from its red, green and blue components. These must be between 0 and 255.
|
Build a color from its red, green and blue components. These must be between 0 and 255.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| 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
|
[`string`](/docs/kcl-std/types/std-types-string) - A sequence of characters
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
appearance::hexString(@rgb: [number(_); 3]): string
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,14 +8,18 @@ layout: manual
|
|||||||
Apply a function to every element of a list.
|
Apply a function to every element of a list.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
map(
|
r = 10 // radius
|
||||||
@array: [any],
|
fn drawCircle(@id) {
|
||||||
f: fn(any): any,
|
return startSketchOn(XY)
|
||||||
): [any]
|
|> circle(center = [id * 2 * r, 0], radius = r)
|
||||||
```
|
}
|
||||||
|
|
||||||
Given a list like `[a, b, c]`, and a function like `f`, returns
|
// Call `drawCircle`, passing in each element of the array.
|
||||||
`[f(a), f(b), f(c)]`
|
// The outputs from each `drawCircle` form a new array,
|
||||||
|
// which is the return value from `map`.
|
||||||
|
circles = map([1..3], f = drawCircle)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
### Arguments
|
### 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)
|
[`[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
|
### Examples
|
||||||
|
|
||||||
|
@ -8,10 +8,28 @@ layout: manual
|
|||||||
Remove the last element from an array.
|
Remove the last element from an array.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
@ -23,6 +41,15 @@ Returns a new array with the last element removed.
|
|||||||
|
|
||||||
[`[any]`](/docs/kcl-std/types/std-types-any)
|
[`[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
|
### Examples
|
||||||
|
|
||||||
|
@ -8,13 +8,16 @@ layout: manual
|
|||||||
Append an element to the end of an array.
|
Append an element to the end of an array.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
push(
|
arr = [1, 2, 3]
|
||||||
@array: [any],
|
new_arr = push(arr, item = 4)
|
||||||
item: any,
|
assert(
|
||||||
): [any; 1+]
|
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
|
### Arguments
|
||||||
|
|
||||||
@ -27,6 +30,18 @@ Returns a new array with the element appended.
|
|||||||
|
|
||||||
[`[any; 1+]`](/docs/kcl-std/types/std-types-any)
|
[`[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
|
### Examples
|
||||||
|
|
||||||
|
@ -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.
|
Take a starting value. Then, for each element of an array, calculate the next value, using the previous value and the element.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
reduce(
|
// This function adds two numbers.
|
||||||
@array: [any],
|
fn add(@a, accum) {
|
||||||
initial: any,
|
return a + accum
|
||||||
f: fn(any, accum: any): any,
|
}
|
||||||
): any
|
|
||||||
|
// 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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| 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.
|
[`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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -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.
|
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
|
```kcl
|
||||||
|
n = 10
|
||||||
|
assert(n, isEqualTo = 10)
|
||||||
assert(
|
assert(
|
||||||
@actual: number,
|
n,
|
||||||
isGreaterThan?: number,
|
isGreaterThanOrEqual = 0,
|
||||||
isLessThan?: number,
|
isLessThan = 100,
|
||||||
isGreaterThanOrEqual?: number,
|
error = "number should be between 0 and 100",
|
||||||
isLessThanOrEqual?: number,
|
|
||||||
isEqualTo?: number,
|
|
||||||
tolerance?: number,
|
|
||||||
error?: string,
|
|
||||||
)
|
)
|
||||||
|
assert(
|
||||||
|
1.0000000000012,
|
||||||
|
isEqualTo = 1,
|
||||||
|
tolerance = 0.0001,
|
||||||
|
error = "number should be almost exactly 1",
|
||||||
|
)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| 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 |
|
| `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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,14 +8,11 @@ layout: manual
|
|||||||
Asserts that a value is the boolean value true.
|
Asserts that a value is the boolean value true.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
assertIs(
|
kclIsFun = true
|
||||||
@actual: bool,
|
assertIs(kclIsFun)
|
||||||
error?: string,
|
|
||||||
)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| 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 |
|
| `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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,18 +8,21 @@ layout: manual
|
|||||||
Clone a sketch or solid.
|
Clone a sketch or solid.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| 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)
|
[`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
|
### Examples
|
||||||
|
|
||||||
|
@ -8,19 +8,23 @@ layout: manual
|
|||||||
Create a helix.
|
Create a helix.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
helix(
|
// Create a helix around the Z axis.
|
||||||
revolutions: number(_),
|
helixPath = helix(
|
||||||
angleStart: number(Angle),
|
angleStart = 0,
|
||||||
ccw?: bool,
|
ccw = true,
|
||||||
radius?: number(Length),
|
revolutions = 5,
|
||||||
axis?: Axis3d | Edge,
|
length = 10,
|
||||||
length?: number(Length),
|
radius = 5,
|
||||||
cylinder?: Solid,
|
axis = Z,
|
||||||
): Helix
|
)
|
||||||
|
|
||||||
|
// Create a spring by sweeping around the helix path.
|
||||||
|
springSketch = startSketchOn(XZ)
|
||||||
|
|> circle(center = [5, 0], radius = 0.5)
|
||||||
|
|> sweep(path = helixPath)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -38,6 +42,20 @@ helix(
|
|||||||
[`Helix`](/docs/kcl-std/types/std-types-Helix) - A helix; created by the `helix` function.
|
[`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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,20 @@ layout: manual
|
|||||||
Compute the absolute value of a number.
|
Compute the absolute value of a number.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +33,12 @@ abs(@input: number): number
|
|||||||
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
abs(@input: number): number
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,17 @@ layout: manual
|
|||||||
Compute the arccosine of a number.
|
Compute the arccosine of a number.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +30,12 @@ acos(@num: number(_)): number(rad)
|
|||||||
[`number(rad)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(rad)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
acos(@num: number(_)): number(rad)
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,16 @@ layout: manual
|
|||||||
Compute the arcsine of a number.
|
Compute the arcsine of a number.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +29,12 @@ asin(@num: number(_)): number(rad)
|
|||||||
[`number(rad)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(rad)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
asin(@num: number(_)): number(rad)
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,10 +8,15 @@ layout: manual
|
|||||||
Compute the arctangent of a number.
|
Compute the arctangent of a number.
|
||||||
|
|
||||||
```kcl
|
```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
|
### 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.
|
[`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
|
### Examples
|
||||||
|
|
||||||
|
@ -8,14 +8,16 @@ layout: manual
|
|||||||
Compute the four quadrant arctangent of Y and X.
|
Compute the four quadrant arctangent of Y and X.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
atan2(
|
sketch001 = startSketchOn(XZ)
|
||||||
y: number(Length),
|
|> startProfile(at = [0, 0])
|
||||||
x: number(Length),
|
|> angledLine(angle = atan2(y = 1.25, x = 2), length = 20)
|
||||||
): number(rad)
|
|> yLine(endAbsolute = 0)
|
||||||
|
|> close()
|
||||||
|
|
||||||
|
extrude001 = extrude(sketch001, length = 5)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -28,6 +30,15 @@ atan2(
|
|||||||
[`number(rad)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(rad)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
atan2(
|
||||||
|
y: number(Length),
|
||||||
|
x: number(Length),
|
||||||
|
): number(rad)
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,17 @@ layout: manual
|
|||||||
Compute the smallest integer greater than or equal to a number.
|
Compute the smallest integer greater than or equal to a number.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +30,12 @@ ceil(@input: number): number
|
|||||||
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
ceil(@input: number): number
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,16 @@ layout: manual
|
|||||||
Compute the cosine of a number.
|
Compute the cosine of a number.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +29,12 @@ cos(@num: number(Angle)): number
|
|||||||
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
cos(@num: number(Angle)): number
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,17 @@ layout: manual
|
|||||||
Compute the largest integer less than or equal to a number.
|
Compute the largest integer less than or equal to a number.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +30,12 @@ floor(@input: number): number
|
|||||||
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
floor(@input: number): number
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,14 +8,10 @@ layout: manual
|
|||||||
Compute the angle of the given leg for x.
|
Compute the angle of the given leg for x.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
legAngX(
|
legAngX(hypotenuse = 5, leg = 3)
|
||||||
hypotenuse: number(Length),
|
|
||||||
leg: number(Length),
|
|
||||||
): number(deg)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -28,6 +24,15 @@ legAngX(
|
|||||||
[`number(deg)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(deg)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
legAngX(
|
||||||
|
hypotenuse: number(Length),
|
||||||
|
leg: number(Length),
|
||||||
|
): number(deg)
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,14 +8,10 @@ layout: manual
|
|||||||
Compute the angle of the given leg for y.
|
Compute the angle of the given leg for y.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
legAngY(
|
legAngY(hypotenuse = 5, leg = 3)
|
||||||
hypotenuse: number(Length),
|
|
||||||
leg: number(Length),
|
|
||||||
): number(deg)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -28,6 +24,15 @@ legAngY(
|
|||||||
[`number(deg)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(deg)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
legAngY(
|
||||||
|
hypotenuse: number(Length),
|
||||||
|
leg: number(Length),
|
||||||
|
): number(deg)
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,14 +8,10 @@ layout: manual
|
|||||||
Compute the length of the given leg.
|
Compute the length of the given leg.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
legLen(
|
legLen(hypotenuse = 5, leg = 3)
|
||||||
hypotenuse: number(Length),
|
|
||||||
leg: number(Length),
|
|
||||||
): number(Length)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -28,6 +24,15 @@ legLen(
|
|||||||
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
legLen(
|
||||||
|
hypotenuse: number(Length),
|
||||||
|
leg: number(Length),
|
||||||
|
): number(Length)
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,17 @@ layout: manual
|
|||||||
Compute the natural logarithm of the number.
|
Compute the natural logarithm of the number.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +30,12 @@ ln(@input: number): number
|
|||||||
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
ln(@input: number): number
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,15 +8,16 @@ layout: manual
|
|||||||
Compute the logarithm of the number with respect to an arbitrary base.
|
Compute the logarithm of the number with respect to an arbitrary base.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
log(
|
exampleSketch = startSketchOn(XZ)
|
||||||
@input: number,
|
|> startProfile(at = [0, 0])
|
||||||
base: number(_),
|
|> line(end = [log(100, base = 5), 0])
|
||||||
): number
|
|> line(end = [5, 8])
|
||||||
```
|
|> line(end = [-10, 0])
|
||||||
|
|> close()
|
||||||
|
|
||||||
The result might not be correctly rounded owing to implementation
|
example = extrude(exampleSketch, length = 5)
|
||||||
details; `log2` can produce more accurate results for base 2,
|
|
||||||
and `log10` can produce more accurate results for base 10.
|
```
|
||||||
|
|
||||||
### Arguments
|
### 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.
|
[`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
|
### Examples
|
||||||
|
|
||||||
|
@ -8,11 +8,17 @@ layout: manual
|
|||||||
Compute the base 10 logarithm of the number.
|
Compute the base 10 logarithm of the number.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +30,12 @@ log10(@input: number): number
|
|||||||
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
log10(@input: number): number
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,17 @@ layout: manual
|
|||||||
Compute the base 2 logarithm of the number.
|
Compute the base 2 logarithm of the number.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +30,12 @@ log2(@input: number): number
|
|||||||
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
log2(@input: number): number
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,16 @@ layout: manual
|
|||||||
Compute the maximum of the given arguments.
|
Compute the maximum of the given arguments.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +29,12 @@ max(@input: [number; 1+]): number
|
|||||||
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
max(@input: [number; 1+]): number
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,16 @@ layout: manual
|
|||||||
Compute the minimum of the given arguments.
|
Compute the minimum of the given arguments.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +29,12 @@ min(@input: [number; 1+]): number
|
|||||||
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
min(@input: [number; 1+]): number
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,14 +8,18 @@ layout: manual
|
|||||||
Convert polar/sphere (azimuth, elevation, distance) coordinates to cartesian (x/y/z grid) coordinates.
|
Convert polar/sphere (azimuth, elevation, distance) coordinates to cartesian (x/y/z grid) coordinates.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
polar(
|
exampleSketch = startSketchOn(XZ)
|
||||||
angle: number(rad),
|
|> startProfile(at = [0, 0])
|
||||||
length: number(Length),
|
|> line(end = polar(angle = 30deg, length = 5), tag = $thing)
|
||||||
): Point2d
|
|> line(end = [0, 5])
|
||||||
|
|> line(end = [segEndX(thing), 0])
|
||||||
|
|> line(end = [-20, 10])
|
||||||
|
|> close()
|
||||||
|
|
||||||
|
example = extrude(exampleSketch, length = 5)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -28,6 +32,15 @@ polar(
|
|||||||
[`Point2d`](/docs/kcl-std/types/std-types-Point2d) - A point in two dimensional space.
|
[`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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,14 +8,16 @@ layout: manual
|
|||||||
Compute the number to a power.
|
Compute the number to a power.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
pow(
|
exampleSketch = startSketchOn(XZ)
|
||||||
@input: number,
|
|> startProfile(at = [0, 0])
|
||||||
exp: number(_),
|
|> angledLine(angle = 50deg, length = pow(5, exp = 2))
|
||||||
): number
|
|> yLine(endAbsolute = 0)
|
||||||
|
|> close()
|
||||||
|
|
||||||
|
example = extrude(exampleSketch, length = 5)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -28,6 +30,15 @@ pow(
|
|||||||
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
pow(
|
||||||
|
@input: number,
|
||||||
|
exp: number(_),
|
||||||
|
): number
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,14 +8,17 @@ layout: manual
|
|||||||
Compute the remainder after dividing `num` by `div`. If `num` is negative, the result will be too.
|
Compute the remainder after dividing `num` by `div`. If `num` is negative, the result will be too.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
rem(
|
import rem from "std::math"
|
||||||
@num: number,
|
|
||||||
divisor: number,
|
assert(rem(7, divisor = 4), isEqualTo = 3, error = "remainder is 3")
|
||||||
): number
|
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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -28,6 +31,15 @@ rem(
|
|||||||
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
rem(
|
||||||
|
@num: number,
|
||||||
|
divisor: number,
|
||||||
|
): number
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,17 @@ layout: manual
|
|||||||
Round a number to the nearest integer.
|
Round a number to the nearest integer.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +30,12 @@ round(@input: number): number
|
|||||||
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
round(@input: number): number
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,16 @@ layout: manual
|
|||||||
Compute the sine of a number.
|
Compute the sine of a number.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +29,12 @@ sin(@num: number(Angle)): number
|
|||||||
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
sin(@num: number(Angle)): number
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,16 @@ layout: manual
|
|||||||
Compute the square root of a number.
|
Compute the square root of a number.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +29,12 @@ sqrt(@input: number): number
|
|||||||
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
sqrt(@input: number): number
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,16 @@ layout: manual
|
|||||||
Compute the tangent of a number.
|
Compute the tangent of a number.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +29,12 @@ tan(@num: number(Angle)): number
|
|||||||
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
tan(@num: number(Angle)): number
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,14 +8,21 @@ layout: manual
|
|||||||
Offset a plane by a distance along its normal.
|
Offset a plane by a distance along its normal.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
offsetPlane(
|
// Loft a square and a circle on the `XY` plane using offset.
|
||||||
@plane: Plane,
|
squareSketch = startSketchOn(XY)
|
||||||
offset: number(Length),
|
|> startProfile(at = [-100, 200])
|
||||||
): Plane
|
|> 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`
|
circleSketch = startSketchOn(offsetPlane(XY, offset = 150))
|
||||||
plane and 10 units away from it.
|
|> circle(center = [0, 100], radius = 50)
|
||||||
|
|
||||||
|
loft([squareSketch, circleSketch])
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
@ -28,6 +35,19 @@ plane and 10 units away from it.
|
|||||||
|
|
||||||
[`Plane`](/docs/kcl-std/types/std-types-Plane) - An abstract plane.
|
[`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
|
### Examples
|
||||||
|
|
||||||
|
@ -8,20 +8,18 @@ layout: manual
|
|||||||
Draw a line segment relative to the current origin using the polar measure of some angle and distance.
|
Draw a line segment relative to the current origin using the polar measure of some angle and distance.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
angledLine(
|
exampleSketch = startSketchOn(XZ)
|
||||||
@sketch: Sketch,
|
|> startProfile(at = [0, 0])
|
||||||
angle: number(Angle),
|
|> yLine(endAbsolute = 15)
|
||||||
length?: number(Length),
|
|> angledLine(angle = 30deg, length = 15)
|
||||||
lengthX?: number(Length),
|
|> line(end = [8, -10])
|
||||||
lengthY?: number(Length),
|
|> yLine(endAbsolute = 0)
|
||||||
endAbsoluteX?: number(Length),
|
|> close()
|
||||||
endAbsoluteY?: number(Length),
|
|
||||||
tag?: TagDecl,
|
example = extrude(exampleSketch, length = 10)
|
||||||
): Sketch
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -40,6 +38,21 @@ angledLine(
|
|||||||
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
|
[`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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -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.
|
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
|
```kcl
|
||||||
angledLineThatIntersects(
|
exampleSketch = startSketchOn(XZ)
|
||||||
@sketch: Sketch,
|
|> startProfile(at = [0, 0])
|
||||||
angle: number(Angle),
|
|> line(endAbsolute = [5, 10])
|
||||||
intersectTag: TaggedEdge,
|
|> line(endAbsolute = [-10, 10], tag = $lineToIntersect)
|
||||||
offset?: number(Length),
|
|> line(endAbsolute = [0, 20])
|
||||||
tag?: TagDecl,
|
|> angledLineThatIntersects(angle = 80deg, intersectTag = lineToIntersect, offset = 10)
|
||||||
): Sketch
|
|> close()
|
||||||
|
|
||||||
|
example = extrude(exampleSketch, length = 10)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -34,6 +35,18 @@ angledLineThatIntersects(
|
|||||||
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
|
[`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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,27 +8,15 @@ layout: manual
|
|||||||
Draw a curved line segment along an imaginary circle.
|
Draw a curved line segment along an imaginary circle.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
arc(
|
exampleSketch = startSketchOn(XZ)
|
||||||
@sketch: Sketch,
|
|> startProfile(at = [0, 0])
|
||||||
angleStart?: number(Angle),
|
|> line(end = [10, 0])
|
||||||
angleEnd?: number(Angle),
|
|> arc(angleStart = 0, angleEnd = 280deg, radius = 16)
|
||||||
radius?: number(Length),
|
|> close()
|
||||||
diameter?: number(Length),
|
example = extrude(exampleSketch, length = 10)
|
||||||
interiorAbsolute?: Point2d,
|
|
||||||
endAbsolute?: Point2d,
|
|
||||||
tag?: TagDecl,
|
|
||||||
): Sketch
|
|
||||||
```
|
```
|
||||||
|
|
||||||
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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| 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.
|
[`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
|
### Examples
|
||||||
|
|
||||||
|
@ -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.
|
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
|
```kcl
|
||||||
bezierCurve(
|
// Example using relative control points.
|
||||||
@sketch: Sketch,
|
exampleSketch = startSketchOn(XZ)
|
||||||
control1?: Point2d,
|
|> startProfile(at = [0, 0])
|
||||||
control2?: Point2d,
|
|> line(end = [0, 10])
|
||||||
end?: Point2d,
|
|> bezierCurve(control1 = [5, 0], control2 = [5, 10], end = [10, 10])
|
||||||
control1Absolute?: Point2d,
|
|> line(endAbsolute = [10, 0])
|
||||||
control2Absolute?: Point2d,
|
|> close()
|
||||||
endAbsolute?: Point2d,
|
|
||||||
tag?: TagDecl,
|
example = extrude(exampleSketch, length = 10)
|
||||||
): Sketch
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -40,6 +38,21 @@ bezierCurve(
|
|||||||
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
|
[`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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,17 +8,13 @@ layout: manual
|
|||||||
Construct a 2-dimensional circle, of the specified radius, centered at the provided (x, y) origin point.
|
Construct a 2-dimensional circle, of the specified radius, centered at the provided (x, y) origin point.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
circle(
|
exampleSketch = startSketchOn(-XZ)
|
||||||
@sketchOrSurface: Sketch | Plane | Face,
|
|> circle(center = [0, 0], radius = 10)
|
||||||
center: Point2d,
|
|
||||||
radius?: number(Length),
|
example = extrude(exampleSketch, length = 5)
|
||||||
diameter?: number(Length),
|
|
||||||
tag?: TagDecl,
|
|
||||||
): Sketch
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -34,6 +30,18 @@ circle(
|
|||||||
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
|
[`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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,17 +8,12 @@ layout: manual
|
|||||||
Construct a circle derived from 3 points.
|
Construct a circle derived from 3 points.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
circleThreePoint(
|
exampleSketch = startSketchOn(XY)
|
||||||
@sketchOrSurface: Sketch | Plane | Face,
|
|> circleThreePoint(p1 = [10, 10], p2 = [20, 8], p3 = [15, 5])
|
||||||
p1: Point2d,
|
|> extrude(length = 5)
|
||||||
p2: Point2d,
|
|
||||||
p3: Point2d,
|
|
||||||
tag?: TagDecl,
|
|
||||||
): Sketch
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -34,6 +29,18 @@ circleThreePoint(
|
|||||||
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
|
[`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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -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.
|
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
|
```kcl
|
||||||
close(
|
startSketchOn(XZ)
|
||||||
@sketch: Sketch,
|
|> startProfile(at = [0, 0])
|
||||||
tag?: TagDecl,
|
|> line(end = [10, 10])
|
||||||
): Sketch
|
|> 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
|
### Arguments
|
||||||
|
|
||||||
@ -30,6 +28,21 @@ starting point.
|
|||||||
|
|
||||||
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
|
[`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
|
### Examples
|
||||||
|
|
||||||
|
@ -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.
|
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
|
```kcl
|
||||||
extrude(
|
example = startSketchOn(XZ)
|
||||||
@sketches: [Sketch; 1+],
|
|> startProfile(at = [0, 0])
|
||||||
length: number(Length),
|
|> line(end = [10, 0])
|
||||||
symmetric?: bool,
|
|> arc(angleStart = 120deg, angleEnd = 0, radius = 5)
|
||||||
bidirectionalLength?: number(Length),
|
|> line(end = [5, 0])
|
||||||
tagStart?: TagDecl,
|
|> line(end = [0, 10])
|
||||||
tagEnd?: TagDecl,
|
|> bezierCurve(control1 = [-10, 0], control2 = [2, 10], end = [-5, 10])
|
||||||
twistAngle?: number(Angle),
|
|> line(end = [-5, -2])
|
||||||
twistAngleStep?: number(Angle),
|
|> close()
|
||||||
twistCenter?: Point2d,
|
|> extrude(length = 10)
|
||||||
): [Solid; 1+]
|
|
||||||
```
|
|
||||||
|
|
||||||
You can provide more than one sketch to extrude, and they will all be
|
```
|
||||||
extruded in the same direction.
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
@ -42,6 +39,26 @@ extruded in the same direction.
|
|||||||
|
|
||||||
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
|
[`[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
|
### Examples
|
||||||
|
|
||||||
|
@ -8,11 +8,29 @@ layout: manual
|
|||||||
Get the shared edge between two faces.
|
Get the shared edge between two faces.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| 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.
|
[`Edge`](/docs/kcl-std/types/std-types-Edge) - An edge of a solid.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
getCommonEdge(faces: [TaggedFace; 2]): Edge
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,20 @@ layout: manual
|
|||||||
Get the next adjacent edge to the edge given.
|
Get the next adjacent edge to the edge given.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| 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.
|
[`Edge`](/docs/kcl-std/types/std-types-Edge) - An edge of a solid.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
getNextAdjacentEdge(@edge: TaggedEdge): Edge
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,20 @@ layout: manual
|
|||||||
Get the opposite edge to the edge given.
|
Get the opposite edge to the edge given.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| 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.
|
[`Edge`](/docs/kcl-std/types/std-types-Edge) - An edge of a solid.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
getOppositeEdge(@edge: TaggedEdge): Edge
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,20 @@ layout: manual
|
|||||||
Get the previous adjacent edge to the edge given.
|
Get the previous adjacent edge to the edge given.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| 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.
|
[`Edge`](/docs/kcl-std/types/std-types-Edge) - An edge of a solid.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
getPreviousAdjacentEdge(@edge: TaggedEdge): Edge
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,18 +8,20 @@ layout: manual
|
|||||||
Extend the current sketch with a new involute circular curve.
|
Extend the current sketch with a new involute circular curve.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
involuteCircular(
|
a = 10
|
||||||
@sketch: Sketch,
|
b = 14
|
||||||
startRadius: number(Length),
|
startSketchOn(XZ)
|
||||||
endRadius: number(Length),
|
|> startProfile(at = [0, 0])
|
||||||
angle: number(Angle),
|
|> involuteCircular(startRadius = a, endRadius = b, angle = 60deg)
|
||||||
reverse?: bool,
|
|> involuteCircular(
|
||||||
tag?: TagDecl,
|
startRadius = a,
|
||||||
): Sketch
|
endRadius = b,
|
||||||
|
angle = 60deg,
|
||||||
|
reverse = true,
|
||||||
|
)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -36,6 +38,19 @@ involuteCircular(
|
|||||||
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
|
[`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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,18 @@ layout: manual
|
|||||||
Extract the 'x' axis value of the last line segment in the provided 2-d sketch.
|
Extract the 'x' axis value of the last line segment in the provided 2-d sketch.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +31,12 @@ lastSegX(@sketch: Sketch): number(Length)
|
|||||||
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
lastSegX(@sketch: Sketch): number(Length)
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,18 @@ layout: manual
|
|||||||
Extract the 'y' axis value of the last line segment in the provided 2-d sketch.
|
Extract the 'y' axis value of the last line segment in the provided 2-d sketch.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +31,12 @@ lastSegY(@sketch: Sketch): number(Length)
|
|||||||
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
lastSegY(@sketch: Sketch): number(Length)
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,16 +8,29 @@ layout: manual
|
|||||||
Extend the current sketch with a new straight line.
|
Extend the current sketch with a new straight line.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
line(
|
triangle = startSketchOn(XZ)
|
||||||
@sketch: Sketch,
|
|> startProfile(at = [0, 0])
|
||||||
endAbsolute?: Point2d,
|
// The END argument means it ends at exactly [10, 0].
|
||||||
end?: Point2d,
|
// This is an absolute measurement, it is NOT relative to
|
||||||
tag?: TagDecl,
|
// the start of the sketch.
|
||||||
): 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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -32,6 +45,17 @@ line(
|
|||||||
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
|
[`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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,18 +8,25 @@ layout: manual
|
|||||||
Create a 3D surface or solid by interpolating between two or more sketches.
|
Create a 3D surface or solid by interpolating between two or more sketches.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
loft(
|
// Loft a square and a triangle.
|
||||||
@sketches: [Sketch; 2+],
|
squareSketch = startSketchOn(XY)
|
||||||
vDegree?: number(_),
|
|> startProfile(at = [-100, 200])
|
||||||
bezApproximateRational?: bool,
|
|> line(end = [200, 0])
|
||||||
baseCurveIndex?: number(_),
|
|> line(end = [0, -200])
|
||||||
tolerance?: number(Length),
|
|> line(end = [-200, 0])
|
||||||
tagStart?: TagDecl,
|
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||||
tagEnd?: TagDecl,
|
|> close()
|
||||||
): Solid
|
|
||||||
```
|
|
||||||
|
|
||||||
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
|
### 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.
|
[`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
|
### Examples
|
||||||
|
|
||||||
|
@ -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.
|
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
|
```kcl
|
||||||
patternCircular2d(
|
exampleSketch = startSketchOn(XZ)
|
||||||
@sketches: [Sketch; 1+],
|
|> startProfile(at = [.5, 25])
|
||||||
instances: number(_),
|
|> line(end = [0, 5])
|
||||||
center: Point2d,
|
|> line(end = [-1, 0])
|
||||||
arcDegrees?: number(Angle),
|
|> line(end = [0, -5])
|
||||||
rotateDuplicates?: bool,
|
|> close()
|
||||||
useOriginal?: bool,
|
|> patternCircular2d(
|
||||||
): [Sketch; 1+]
|
center = [0, 0],
|
||||||
|
instances = 13,
|
||||||
|
arcDegrees = 360,
|
||||||
|
rotateDuplicates = true,
|
||||||
|
)
|
||||||
|
|
||||||
|
example = extrude(exampleSketch, length = 1)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -36,6 +41,19 @@ patternCircular2d(
|
|||||||
[`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch)
|
[`[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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -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.
|
Repeat a 2-dimensional sketch along some dimension, with a dynamic amount of distance between each repetition, some specified number of times.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
patternLinear2d(
|
// / Pattern using a named axis.
|
||||||
@sketches: [Sketch; 1+],
|
|
||||||
instances: number(_),
|
|
||||||
distance: number(Length),
|
exampleSketch = startSketchOn(XZ)
|
||||||
axis: Axis2d | Point2d,
|
|> circle(center = [0, 0], radius = 1)
|
||||||
useOriginal?: bool,
|
|> patternLinear2d(axis = X, instances = 7, distance = 4)
|
||||||
): [Sketch; 1+]
|
|
||||||
|
example = extrude(exampleSketch, length = 1)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -34,6 +34,18 @@ patternLinear2d(
|
|||||||
[`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch)
|
[`[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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,16 +8,18 @@ layout: manual
|
|||||||
Just like `patternTransform`, but works on 2D sketches not 3D solids.
|
Just like `patternTransform`, but works on 2D sketches not 3D solids.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
patternTransform2d(
|
// Each instance will be shifted along the X axis.
|
||||||
@sketches: [Sketch; 1+],
|
fn transform(@id) {
|
||||||
instances: number(_),
|
return { translate = [4 * id, 0] }
|
||||||
transform: fn(number(_)): { },
|
}
|
||||||
useOriginal?: boolean,
|
|
||||||
): [Sketch; 1+]
|
// Sketch 4 circles.
|
||||||
|
sketch001 = startSketchOn(XZ)
|
||||||
|
|> circle(center = [0, 0], radius = 2)
|
||||||
|
|> patternTransform2d(instances = 4, transform = transform)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -32,6 +34,17 @@ patternTransform2d(
|
|||||||
[`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch)
|
[`[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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -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.
|
Create a regular polygon with the specified number of sides that is either inscribed or circumscribed around a circle of the specified radius.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
polygon(
|
// Create a regular hexagon inscribed in a circle of radius 10
|
||||||
@sketchOrSurface: Sketch | Plane | Face,
|
hex = startSketchOn(XY)
|
||||||
radius: number(Length),
|
|> polygon(
|
||||||
numSides: number(_),
|
radius = 10,
|
||||||
center: Point2d,
|
numSides = 6,
|
||||||
inscribed?: bool,
|
center = [0, 0],
|
||||||
): Sketch
|
inscribed = true,
|
||||||
|
)
|
||||||
|
|
||||||
|
example = extrude(hex, length = 5)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -34,6 +36,18 @@ polygon(
|
|||||||
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
|
[`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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,16 @@ layout: manual
|
|||||||
Extract the provided 2-dimensional sketch's profile's origin value.
|
Extract the provided 2-dimensional sketch's profile's origin value.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| 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.
|
[`Point2d`](/docs/kcl-std/types/std-types-Point2d) - A point in two dimensional space.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
profileStart(@profile: Sketch): Point2d
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,14 @@ layout: manual
|
|||||||
Extract the provided 2-dimensional sketch's profile's origin's 'x' value.
|
Extract the provided 2-dimensional sketch's profile's origin's 'x' value.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +27,12 @@ profileStartX(@profile: Sketch): number(Length)
|
|||||||
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
profileStartX(@profile: Sketch): number(Length)
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,13 @@ layout: manual
|
|||||||
Extract the provided 2-dimensional sketch's profile's origin's 'y' value.
|
Extract the provided 2-dimensional sketch's profile's origin's 'y' value.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
profileStartY(@profile: Sketch): number(Length)
|
sketch001 = startSketchOn(XY)
|
||||||
|
|> startProfile(at = [5, 2])
|
||||||
|
|> angledLine(angle = -60deg, length = 14)
|
||||||
|
|> angledLine(angle = 30deg, endAbsoluteY = profileStartY(%))
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +26,12 @@ profileStartY(@profile: Sketch): number(Length)
|
|||||||
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
profileStartY(@profile: Sketch): number(Length)
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,29 +8,20 @@ layout: manual
|
|||||||
Rotate a sketch around some provided axis, creating a solid from its extent.
|
Rotate a sketch around some provided axis, creating a solid from its extent.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
revolve(
|
part001 = startSketchOn(XY)
|
||||||
@sketches: [Sketch; 1+],
|
|> startProfile(at = [4, 12])
|
||||||
axis: Axis2d | Edge,
|
|> line(end = [2, 0])
|
||||||
angle?: number(Angle),
|
|> line(end = [0, -6])
|
||||||
tolerance?: number(Length),
|
|> line(end = [4, -6])
|
||||||
symmetric?: bool,
|
|> line(end = [0, -6])
|
||||||
bidirectionalAngle?: number(Angle),
|
|> line(end = [-3.75, -4.5])
|
||||||
tagStart?: TagDecl,
|
|> line(end = [0, -5.5])
|
||||||
tagEnd?: TagDecl,
|
|> line(end = [-2, 0])
|
||||||
): [Solid; 1+]
|
|> 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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -48,6 +39,33 @@ revolved around the same axis.
|
|||||||
|
|
||||||
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
|
[`[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
|
### Examples
|
||||||
|
|
||||||
|
@ -8,11 +8,20 @@ layout: manual
|
|||||||
Compute the angle (in degrees) of the provided line segment.
|
Compute the angle (in degrees) of the provided line segment.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +33,12 @@ segAng(@tag: TaggedEdge): number(Angle)
|
|||||||
[`number(Angle)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(Angle)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
segAng(@tag: TaggedEdge): number(Angle)
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,30 @@ layout: manual
|
|||||||
Compute the ending point of the provided line segment.
|
Compute the ending point of the provided line segment.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| 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.
|
[`Point2d`](/docs/kcl-std/types/std-types-Point2d) - A point in two dimensional space.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
segEnd(@tag: TaggedEdge): Point2d
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,18 @@ layout: manual
|
|||||||
Compute the ending point of the provided line segment along the 'x' axis.
|
Compute the ending point of the provided line segment along the 'x' axis.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +31,12 @@ segEndX(@tag: TaggedEdge): number(Length)
|
|||||||
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
segEndX(@tag: TaggedEdge): number(Length)
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,19 @@ layout: manual
|
|||||||
Compute the ending point of the provided line segment along the 'y' axis.
|
Compute the ending point of the provided line segment along the 'y' axis.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +32,12 @@ segEndY(@tag: TaggedEdge): number(Length)
|
|||||||
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
segEndY(@tag: TaggedEdge): number(Length)
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,17 @@ layout: manual
|
|||||||
Compute the length of the provided line segment.
|
Compute the length of the provided line segment.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +30,12 @@ segLen(@tag: TaggedEdge): number(Length)
|
|||||||
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
segLen(@tag: TaggedEdge): number(Length)
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,30 @@ layout: manual
|
|||||||
Compute the starting point of the provided line segment.
|
Compute the starting point of the provided line segment.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| 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.
|
[`Point2d`](/docs/kcl-std/types/std-types-Point2d) - A point in two dimensional space.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
segStart(@tag: TaggedEdge): Point2d
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,18 @@ layout: manual
|
|||||||
Compute the starting point of the provided line segment along the 'x' axis.
|
Compute the starting point of the provided line segment along the 'x' axis.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +31,12 @@ segStartX(@tag: TaggedEdge): number(Length)
|
|||||||
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
segStartX(@tag: TaggedEdge): number(Length)
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,11 +8,19 @@ layout: manual
|
|||||||
Compute the starting point of the provided line segment along the 'y' axis.
|
Compute the starting point of the provided line segment along the 'y' axis.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +32,12 @@ segStartY(@tag: TaggedEdge): number(Length)
|
|||||||
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(Length)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
segStartY(@tag: TaggedEdge): number(Length)
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,15 +8,17 @@ layout: manual
|
|||||||
Start a new profile at a given point.
|
Start a new profile at a given point.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
startProfile(
|
exampleSketch = startSketchOn(XZ)
|
||||||
@startProfileOn: Plane | Face,
|
|> startProfile(at = [0, 0])
|
||||||
at: Point2d,
|
|> line(end = [10, 0])
|
||||||
tag?: TagDecl,
|
|> line(end = [0, 10])
|
||||||
): Sketch
|
|> line(end = [-10, 0])
|
||||||
|
|> close()
|
||||||
|
|
||||||
|
example = extrude(exampleSketch, length = 5)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -30,6 +32,16 @@ startProfile(
|
|||||||
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
|
[`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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,12 +8,48 @@ layout: manual
|
|||||||
Start a new 2-dimensional sketch on a specific plane or face.
|
Start a new 2-dimensional sketch on a specific plane or face.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
startSketchOn(
|
exampleSketch = startSketchOn(XY)
|
||||||
@planeOrSolid: Solid | Plane,
|
|> startProfile(at = [0, 0])
|
||||||
face?: TaggedFace,
|
|> line(end = [10, 0])
|
||||||
): Plane | Face
|
|> 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
|
### Sketch on Face Behavior
|
||||||
|
|
||||||
There are some important behaviors to understand when sketching on a face:
|
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
|
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.
|
face, since it will include all the parent faces and Solids.
|
||||||
|
|
||||||
### Arguments
|
### Function signature
|
||||||
|
|
||||||
| 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)
|
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
startSketchOn(
|
||||||
|
@planeOrSolid: Solid | Plane,
|
||||||
|
face?: TaggedFace,
|
||||||
|
): Plane | Face
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
|
@ -8,14 +8,19 @@ layout: manual
|
|||||||
Use a 2-dimensional sketch to cut a hole in another 2-dimensional sketch.
|
Use a 2-dimensional sketch to cut a hole in another 2-dimensional sketch.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
subtract2d(
|
exampleSketch = startSketchOn(XY)
|
||||||
@sketch: Sketch,
|
|> startProfile(at = [0, 0])
|
||||||
tool: [Sketch; 1+],
|
|> line(end = [0, 5])
|
||||||
): Sketch
|
|> 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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -28,6 +33,15 @@ subtract2d(
|
|||||||
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
|
[`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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,26 +8,28 @@ layout: manual
|
|||||||
Extrude a sketch along a path.
|
Extrude a sketch along a path.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
sweep(
|
// Create a pipe using a sweep.
|
||||||
@sketches: [Sketch; 1+],
|
|
||||||
path: Sketch | Helix,
|
// Create a path for the sweep.
|
||||||
sectional?: bool,
|
sweepPath = startSketchOn(XZ)
|
||||||
tolerance?: number(Length),
|
|> startProfile(at = [0.05, 0.05])
|
||||||
relativeTo?: string,
|
|> line(end = [0, 7])
|
||||||
tagStart?: TagDecl,
|
|> tangentialArc(angle = 90deg, radius = 5)
|
||||||
tagEnd?: TagDecl,
|
|> line(end = [-3, 0])
|
||||||
): [Solid; 1+]
|
|> 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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -44,6 +46,30 @@ swept along the same path.
|
|||||||
|
|
||||||
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
|
[`[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
|
### Examples
|
||||||
|
|
||||||
|
@ -8,11 +8,19 @@ layout: manual
|
|||||||
Returns the angle coming out of the end of the segment in degrees.
|
Returns the angle coming out of the end of the segment in degrees.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -24,6 +32,12 @@ tangentToEnd(@tag: TaggedEdge): number(Angle)
|
|||||||
[`number(Angle)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(Angle)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
tangentToEnd(@tag: TaggedEdge): number(Angle)
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -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.
|
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
|
```kcl
|
||||||
tangentialArc(
|
exampleSketch = startSketchOn(XZ)
|
||||||
@sketch: Sketch,
|
|> startProfile(at = [0, 0])
|
||||||
endAbsolute?: Point2d,
|
|> angledLine(angle = 45deg, length = 10)
|
||||||
end?: Point2d,
|
|> tangentialArc(end = [0, -10])
|
||||||
radius?: number(Length),
|
|> line(end = [-10, 0])
|
||||||
diameter?: number(Length),
|
|> close()
|
||||||
angle?: number(Angle),
|
|
||||||
tag?: TagDecl,
|
|
||||||
): Sketch
|
|
||||||
```
|
|
||||||
|
|
||||||
When using radius and angle, draw a curved line segment along part of an
|
example = extrude(exampleSketch, length = 10)
|
||||||
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.
|
|
||||||
|
|
||||||
### Arguments
|
### 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.
|
[`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
|
### Examples
|
||||||
|
|
||||||
|
@ -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.
|
Draw a line relative to the current origin to a specified distance away from the current position along the 'x' axis.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
xLine(
|
exampleSketch = startSketchOn(XZ)
|
||||||
@sketch: Sketch,
|
|> startProfile(at = [0, 0])
|
||||||
length?: number(Length),
|
|> xLine(length = 15)
|
||||||
endAbsolute?: number(Length),
|
|> angledLine(angle = 80deg, length = 15)
|
||||||
tag?: TagDecl,
|
|> line(end = [8, -10])
|
||||||
): Sketch
|
|> xLine(length = 10)
|
||||||
|
|> angledLine(angle = 120deg, length = 30)
|
||||||
|
|> xLine(length = -15)
|
||||||
|
|> close()
|
||||||
|
|
||||||
|
example = extrude(exampleSketch, length = 10)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -32,6 +36,17 @@ xLine(
|
|||||||
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
|
[`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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -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.
|
Draw a line relative to the current origin to a specified distance away from the current position along the 'y' axis.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
yLine(
|
exampleSketch = startSketchOn(XZ)
|
||||||
@sketch: Sketch,
|
|> startProfile(at = [0, 0])
|
||||||
length?: number(Length),
|
|> yLine(length = 15)
|
||||||
endAbsolute?: number(Length),
|
|> angledLine(angle = 30deg, length = 15)
|
||||||
tag?: TagDecl,
|
|> line(end = [8, -10])
|
||||||
): Sketch
|
|> yLine(length = -5)
|
||||||
|
|> close()
|
||||||
|
|
||||||
|
example = extrude(exampleSketch, length = 10)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -32,6 +34,17 @@ yLine(
|
|||||||
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
|
[`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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,15 +8,19 @@ layout: manual
|
|||||||
Set the appearance of a solid. This only works on solids, not sketches or individual paths.
|
Set the appearance of a solid. This only works on solids, not sketches or individual paths.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
appearance(
|
// Add color to an extruded solid.
|
||||||
@solids: [Solid; 1+] | ImportedGeometry,
|
exampleSketch = startSketchOn(XZ)
|
||||||
color: string,
|
|> startProfile(at = [0, 0])
|
||||||
metalness?: number(_),
|
|> line(endAbsolute = [10, 0])
|
||||||
roughness?: number(_),
|
|> line(endAbsolute = [0, 10])
|
||||||
): [Solid; 1+] | ImportedGeometry
|
|> 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
|
### 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)
|
[`[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
|
### Examples
|
||||||
|
|
||||||
|
@ -8,17 +8,31 @@ layout: manual
|
|||||||
Cut a straight transitional edge along a tagged path.
|
Cut a straight transitional edge along a tagged path.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
chamfer(
|
// Chamfer a mounting plate.
|
||||||
@solid: Solid,
|
width = 20
|
||||||
length: number(Length),
|
length = 10
|
||||||
tags: [Edge; 1+],
|
thickness = 1
|
||||||
tag?: TagDecl,
|
chamferLength = 2
|
||||||
): Solid
|
|
||||||
```
|
|
||||||
|
|
||||||
Chamfer is similar in function and use to a fillet, except
|
mountingPlateSketch = startSketchOn(XY)
|
||||||
a fillet will blend the transition along an edge, rather than cut
|
|> startProfile(at = [-width / 2, -length / 2])
|
||||||
a sharp, straight transitional edge.
|
|> 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
|
### 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.
|
[`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
|
### Examples
|
||||||
|
|
||||||
|
@ -8,18 +8,30 @@ layout: manual
|
|||||||
Blend a transitional edge along a tagged path, smoothing the sharp edge.
|
Blend a transitional edge along a tagged path, smoothing the sharp edge.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
fillet(
|
width = 20
|
||||||
@solid: Solid,
|
length = 10
|
||||||
radius: number(Length),
|
thickness = 1
|
||||||
tags: [Edge; 1+],
|
filletRadius = 2
|
||||||
tolerance?: number(Length),
|
|
||||||
tag?: TagDecl,
|
|
||||||
): Solid
|
|
||||||
```
|
|
||||||
|
|
||||||
Fillet is similar in function and use to a chamfer, except
|
mountingPlateSketch = startSketchOn(XY)
|
||||||
a chamfer will cut a sharp transition along an edge while fillet
|
|> startProfile(at = [-width / 2, -length / 2])
|
||||||
will smoothly blend the transition.
|
|> 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
|
### 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.
|
[`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
|
### Examples
|
||||||
|
|
||||||
|
@ -8,14 +8,17 @@ layout: manual
|
|||||||
Make the inside of a 3D object hollow.
|
Make the inside of a 3D object hollow.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
hollow(
|
// Hollow a basic sketch.
|
||||||
@solid: Solid,
|
firstSketch = startSketchOn(XY)
|
||||||
thickness: number(Length),
|
|> startProfile(at = [-12, 12])
|
||||||
): Solid
|
|> 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
|
### 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.
|
[`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
|
### Examples
|
||||||
|
|
||||||
|
@ -8,16 +8,26 @@ layout: manual
|
|||||||
Intersect returns the shared volume between multiple solids, preserving only overlapping regions.
|
Intersect returns the shared volume between multiple solids, preserving only overlapping regions.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
intersect(
|
// Intersect two cubes using the stdlib functions.
|
||||||
@solids: [Solid; 2+],
|
|
||||||
tolerance?: number(Length),
|
|
||||||
): [Solid; 1+]
|
|
||||||
```
|
|
||||||
|
|
||||||
Intersect computes the geometric intersection of multiple solid bodies,
|
|
||||||
returning a new solid representing the volume that is common to all input
|
fn cube(center, size) {
|
||||||
solids. This operation is useful for determining shared material regions,
|
return startSketchOn(XY)
|
||||||
verifying fit, and analyzing overlapping geometries in assemblies.
|
|> 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
|
### Arguments
|
||||||
|
|
||||||
@ -30,6 +40,21 @@ verifying fit, and analyzing overlapping geometries in assemblies.
|
|||||||
|
|
||||||
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
|
[`[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
|
### Examples
|
||||||
|
|
||||||
|
@ -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.
|
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
|
```kcl
|
||||||
patternCircular3d(
|
// / Pattern using a named axis.
|
||||||
@solids: [Solid; 1+],
|
|
||||||
instances: number(_),
|
|
||||||
axis: Axis3d | Point3d,
|
exampleSketch = startSketchOn(XZ)
|
||||||
center: Point3d,
|
|> circle(center = [0, 0], radius = 1)
|
||||||
arcDegrees?: number(deg),
|
|
||||||
rotateDuplicates?: bool,
|
example = extrude(exampleSketch, length = -5)
|
||||||
useOriginal?: bool,
|
|> patternCircular3d(
|
||||||
): [Solid; 1+]
|
axis = X,
|
||||||
|
center = [10, -20, 0],
|
||||||
|
instances = 11,
|
||||||
|
arcDegrees = 360,
|
||||||
|
rotateDuplicates = true,
|
||||||
|
)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -38,6 +42,20 @@ patternCircular3d(
|
|||||||
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
|
[`[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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -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.
|
Repeat a 3-dimensional solid along a linear path, with a dynamic amount of distance between each repetition, some specified number of times.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
patternLinear3d(
|
// / Pattern using a named axis.
|
||||||
@solids: [Solid; 1+],
|
|
||||||
instances: number(_),
|
|
||||||
distance: number(Length),
|
exampleSketch = startSketchOn(XZ)
|
||||||
axis: Axis3d | Point3d,
|
|> startProfile(at = [0, 0])
|
||||||
useOriginal?: bool,
|
|> line(end = [0, 2])
|
||||||
): [Solid; 1+]
|
|> line(end = [3, 1])
|
||||||
|
|> line(end = [0, -4])
|
||||||
|
|> close()
|
||||||
|
|
||||||
|
example = extrude(exampleSketch, length = 1)
|
||||||
|
|> patternLinear3d(axis = X, instances = 7, distance = 6)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -34,6 +38,18 @@ patternLinear3d(
|
|||||||
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
|
[`[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
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,14 +8,34 @@ layout: manual
|
|||||||
Repeat a 3-dimensional solid, changing it each time.
|
Repeat a 3-dimensional solid, changing it each time.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
patternTransform(
|
// Each instance will be shifted along the X axis.
|
||||||
@solids: [Solid; 1+],
|
fn transform(@id) {
|
||||||
instances: number(_),
|
return { translate = [4 * id, 0, 0] }
|
||||||
transform: fn(number(_)): { },
|
}
|
||||||
useOriginal?: bool,
|
|
||||||
): [Solid; 1+]
|
// 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.
|
Replicates the 3D solid, applying a transformation function to each replica.
|
||||||
Transformation function could alter rotation, scale, visibility, position, etc.
|
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")
|
- `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
|
### Function signature
|
||||||
|
|
||||||
| 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)
|
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
patternTransform(
|
||||||
|
@solids: [Solid; 1+],
|
||||||
|
instances: number(_),
|
||||||
|
transform: fn(number(_)): { },
|
||||||
|
useOriginal?: bool,
|
||||||
|
): [Solid; 1+]
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
|
@ -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.
|
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
|
```kcl
|
||||||
shell(
|
// Remove the end face for the extrusion.
|
||||||
@solids: [Solid; 1+],
|
firstSketch = startSketchOn(XY)
|
||||||
thickness: number(Length),
|
|> startProfile(at = [-12, 12])
|
||||||
faces: [TaggedFace; 1+],
|
|> line(end = [24, 0])
|
||||||
): [Solid]
|
|> 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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -30,6 +35,16 @@ shell(
|
|||||||
[`[Solid]`](/docs/kcl-std/types/std-types-Solid)
|
[`[Solid]`](/docs/kcl-std/types/std-types-Solid)
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
shell(
|
||||||
|
@solids: [Solid; 1+],
|
||||||
|
thickness: number(Length),
|
||||||
|
faces: [TaggedFace; 1+],
|
||||||
|
): [Solid]
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,18 +8,26 @@ layout: manual
|
|||||||
Subtract removes tool solids from base solids, leaving the remaining material.
|
Subtract removes tool solids from base solids, leaving the remaining material.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
subtract(
|
// Subtract a cylinder from a cube using the stdlib functions.
|
||||||
@solids: [Solid; 1+],
|
|
||||||
tools: [Solid],
|
|
||||||
tolerance?: number(Length),
|
|
||||||
): [Solid; 1+]
|
|
||||||
```
|
|
||||||
|
|
||||||
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
|
fn cube(center, size) {
|
||||||
representing the material that remains after all tool solids have been cut
|
return startSketchOn(XY)
|
||||||
away. This function is essential for machining simulations, cavity creation,
|
|> startProfile(at = [center[0] - size, center[1] - size])
|
||||||
and complex multi-body part modeling.
|
|> 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
|
### Arguments
|
||||||
|
|
||||||
@ -33,6 +41,23 @@ and complex multi-body part modeling.
|
|||||||
|
|
||||||
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
|
[`[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
|
### Examples
|
||||||
|
|
||||||
|
@ -8,14 +8,27 @@ layout: manual
|
|||||||
Union two or more solids into a single solid.
|
Union two or more solids into a single solid.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
union(
|
// Union two cubes using the stdlib functions.
|
||||||
@solids: [Solid; 2+],
|
|
||||||
tolerance?: number(Length),
|
|
||||||
): [Solid; 1+]
|
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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
@ -28,6 +41,15 @@ union(
|
|||||||
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
|
[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid)
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
union(
|
||||||
|
@solids: [Solid; 2+],
|
||||||
|
tolerance?: number(Length),
|
||||||
|
): [Solid; 1+]
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -8,13 +8,22 @@ layout: manual
|
|||||||
Mirror a sketch.
|
Mirror a sketch.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
mirror2d(
|
// Mirror an un-closed sketch across the Y axis.
|
||||||
@sketches: [Sketch; 1+],
|
sketch001 = startSketchOn(XZ)
|
||||||
axis: Axis2d | Edge,
|
|> startProfile(at = [0, 10])
|
||||||
): Sketch
|
|> 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
|
### 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.
|
[`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
|
### Examples
|
||||||
|
|
||||||
|
@ -8,17 +8,47 @@ layout: manual
|
|||||||
Rotate a solid or a sketch.
|
Rotate a solid or a sketch.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
rotate(
|
// Rotate a pipe with roll, pitch, and yaw.
|
||||||
@objects: [Solid; 1+] | [Sketch; 1+] | ImportedGeometry,
|
|
||||||
roll?: number(Angle),
|
// Create a path for the sweep.
|
||||||
pitch?: number(Angle),
|
sweepPath = startSketchOn(XZ)
|
||||||
yaw?: number(Angle),
|
|> startProfile(at = [0.05, 0.05])
|
||||||
axis?: Axis3d | Point3d,
|
|> line(end = [0, 7])
|
||||||
angle?: number(Angle),
|
|> tangentialArc(angle = 90deg, radius = 5)
|
||||||
global?: bool,
|
|> line(end = [-3, 0])
|
||||||
): [Solid; 1+] | [Sketch; 1+] | ImportedGeometry
|
|> 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
|
This is really useful for assembling parts together. You can create a part
|
||||||
and then rotate it to the correct orientation.
|
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
|
When rotating a part around an axis, you specify the axis of rotation and the angle of
|
||||||
rotation.
|
rotation.
|
||||||
|
|
||||||
### Arguments
|
### Function signature
|
||||||
|
|
||||||
| 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)
|
|
||||||
|
|
||||||
|
```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
|
### Examples
|
||||||
|
|
||||||
|
@ -8,28 +8,29 @@ layout: manual
|
|||||||
Scale a solid or a sketch.
|
Scale a solid or a sketch.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
scale(
|
// Scale a pipe.
|
||||||
@objects: [Solid; 1+] | [Sketch; 1+] | ImportedGeometry,
|
|
||||||
x?: number(_),
|
// Create a path for the sweep.
|
||||||
y?: number(_),
|
sweepPath = startSketchOn(XZ)
|
||||||
z?: number(_),
|
|> startProfile(at = [0.05, 0.05])
|
||||||
global?: bool,
|
|> line(end = [0, 7])
|
||||||
): [Solid; 1+] | [Sketch; 1+] | ImportedGeometry
|
|> 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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| 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)
|
[`[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
|
### Examples
|
||||||
|
|
||||||
|
@ -8,21 +8,29 @@ layout: manual
|
|||||||
Move a solid or a sketch.
|
Move a solid or a sketch.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
translate(
|
// Move a pipe.
|
||||||
@objects: [Solid; 1+] | [Sketch; 1+] | ImportedGeometry,
|
|
||||||
x?: number(Length),
|
// Create a path for the sweep.
|
||||||
y?: number(Length),
|
sweepPath = startSketchOn(XZ)
|
||||||
z?: number(Length),
|
|> startProfile(at = [0.05, 0.05])
|
||||||
global?: bool,
|
|> line(end = [0, 7])
|
||||||
): [Solid; 1+] | [Sketch; 1+] | ImportedGeometry
|
|> 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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| 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)
|
[`[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
|
### Examples
|
||||||
|
|
||||||
|
@ -7,11 +7,6 @@ layout: manual
|
|||||||
|
|
||||||
Convert a number to centimeters from its current units.
|
Convert a number to centimeters from its current units.
|
||||||
|
|
||||||
```kcl
|
|
||||||
units::toCentimeters(@num: number(Length)): number(cm)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
@ -24,4 +19,10 @@ units::toCentimeters(@num: number(Length)): number(cm)
|
|||||||
[`number(cm)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(cm)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
units::toCentimeters(@num: number(Length)): number(cm)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,11 +8,16 @@ layout: manual
|
|||||||
Converts a number to degrees from its current units.
|
Converts a number to degrees from its current units.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| 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.
|
[`number(deg)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
units::toDegrees(@num: number(Angle)): number(deg)
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -7,11 +7,6 @@ layout: manual
|
|||||||
|
|
||||||
Convert a number to feet from its current units.
|
Convert a number to feet from its current units.
|
||||||
|
|
||||||
```kcl
|
|
||||||
units::toFeet(@num: number(Length)): number(ft)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
@ -24,4 +19,10 @@ units::toFeet(@num: number(Length)): number(ft)
|
|||||||
[`number(ft)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(ft)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
units::toFeet(@num: number(Length)): number(ft)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,11 +7,6 @@ layout: manual
|
|||||||
|
|
||||||
Convert a number to inches from its current units.
|
Convert a number to inches from its current units.
|
||||||
|
|
||||||
```kcl
|
|
||||||
units::toInches(@num: number(Length)): number(in)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
@ -24,4 +19,10 @@ units::toInches(@num: number(Length)): number(in)
|
|||||||
[`number(in)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(in)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
units::toInches(@num: number(Length)): number(in)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,11 +7,6 @@ layout: manual
|
|||||||
|
|
||||||
Convert a number to meters from its current units.
|
Convert a number to meters from its current units.
|
||||||
|
|
||||||
```kcl
|
|
||||||
units::toMeters(@num: number(Length)): number(m)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
@ -24,4 +19,10 @@ units::toMeters(@num: number(Length)): number(m)
|
|||||||
[`number(m)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(m)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
units::toMeters(@num: number(Length)): number(m)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,11 +7,6 @@ layout: manual
|
|||||||
|
|
||||||
Convert a number to millimeters from its current units.
|
Convert a number to millimeters from its current units.
|
||||||
|
|
||||||
```kcl
|
|
||||||
units::toMillimeters(@num: number(Length)): number(mm)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
@ -24,4 +19,10 @@ units::toMillimeters(@num: number(Length)): number(mm)
|
|||||||
[`number(mm)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(mm)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
units::toMillimeters(@num: number(Length)): number(mm)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,11 +8,16 @@ layout: manual
|
|||||||
Converts a number to radians from its current units.
|
Converts a number to radians from its current units.
|
||||||
|
|
||||||
```kcl
|
```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
|
### Arguments
|
||||||
|
|
||||||
| Name | Type | Description | Required |
|
| 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.
|
[`number(rad)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
units::toRadians(@num: number(Angle)): number(rad)
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
|
@ -7,11 +7,6 @@ layout: manual
|
|||||||
|
|
||||||
Converts a number to yards from its current units.
|
Converts a number to yards from its current units.
|
||||||
|
|
||||||
```kcl
|
|
||||||
units::toYards(@num: number(Length)): number(yd)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Arguments
|
### Arguments
|
||||||
|
|
||||||
@ -24,4 +19,10 @@ units::toYards(@num: number(Length)): number(yd)
|
|||||||
[`number(yd)`](/docs/kcl-std/types/std-types-number) - A number.
|
[`number(yd)`](/docs/kcl-std/types/std-types-number) - A number.
|
||||||
|
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
units::toYards(@num: number(Length)): number(yd)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
19
rust/kcl-lib/src/docs/templates/function.hbs
vendored
19
rust/kcl-lib/src/docs/templates/function.hbs
vendored
@ -11,11 +11,13 @@ layout: manual
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
{{{summary}}}
|
{{{summary}}}
|
||||||
|
|
||||||
|
{{#if examples}}
|
||||||
|
{{#if examples.0.content}}
|
||||||
```kcl
|
```kcl
|
||||||
{{{fn_signature}}}
|
{{{examples.0.content}}}
|
||||||
```
|
```
|
||||||
|
{{/if}}
|
||||||
{{{description}}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if args}}
|
{{#if args}}
|
||||||
### Arguments
|
### Arguments
|
||||||
@ -33,6 +35,17 @@ layout: manual
|
|||||||
`{{return_value.type_}}`{{#if return_value.description}} - {{{firstLine return_value.description}}}{{/if}}
|
`{{return_value.type_}}`{{#if return_value.description}} - {{{firstLine return_value.description}}}{{/if}}
|
||||||
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{#if description}}
|
||||||
|
### Description
|
||||||
|
|
||||||
|
{{{description}}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```kcl
|
||||||
|
{{{fn_signature}}}
|
||||||
|
```
|
||||||
|
|
||||||
{{#if examples}}
|
{{#if examples}}
|
||||||
### Examples
|
### Examples
|
||||||
|
Reference in New Issue
Block a user