Move more functions to KCL decls (#7266)
* Move some sketch functions to KCL Signed-off-by: Nick Cameron <nrc@ncameron.org> * Move asserts to KCL Signed-off-by: Nick Cameron <nrc@ncameron.org> * sweep, loft -> KCL Signed-off-by: Nick Cameron <nrc@ncameron.org> * Move pattern transforms to KCL Signed-off-by: Nick Cameron <nrc@ncameron.org> --------- Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
50
docs/kcl-std/functions/std-assert.md
Normal file
50
docs/kcl-std/functions/std-assert.md
Normal file
@ -0,0 +1,50 @@
|
||||
---
|
||||
title: "assert"
|
||||
subtitle: "Function in std"
|
||||
excerpt: ""
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
||||
|
||||
```kcl
|
||||
assert(
|
||||
@actual: number,
|
||||
isGreaterThan?: number,
|
||||
isLessThan?: number,
|
||||
isGreaterThanOrEqual?: number,
|
||||
isLessThanOrEqual?: number,
|
||||
isEqualTo?: number,
|
||||
tolerance?: number,
|
||||
error?: string,
|
||||
)
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
### Arguments
|
||||
|
||||
| Name | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `actual` | [`number`](/docs/kcl-std/types/std-types-number) | Value to check. If this is the boolean value true, assert passes. Otherwise it fails.. | Yes |
|
||||
| `isGreaterThan` | [`number`](/docs/kcl-std/types/std-types-number) | Comparison argument. If given, checks the `actual` value is greater than this. | No |
|
||||
| `isLessThan` | [`number`](/docs/kcl-std/types/std-types-number) | Comparison argument. If given, checks the `actual` value is less than this. | No |
|
||||
| `isGreaterThanOrEqual` | [`number`](/docs/kcl-std/types/std-types-number) | Comparison argument. If given, checks the `actual` value is greater than or equal to this. | No |
|
||||
| `isLessThanOrEqual` | [`number`](/docs/kcl-std/types/std-types-number) | Comparison argument. If given, checks the `actual` value is less than or equal to this. | No |
|
||||
| `isEqualTo` | [`number`](/docs/kcl-std/types/std-types-number) | Comparison argument. If given, checks the `actual` value is less than or equal to this. | No |
|
||||
| `tolerance` | [`number`](/docs/kcl-std/types/std-types-number) | If `isEqualTo` is used, this is the tolerance to allow for the comparison. This tolerance is used because KCL's number system has some floating-point imprecision when used with very large decimal places. | No |
|
||||
| `error` | [`string`](/docs/kcl-std/types/std-types-string) | If the value was false, the program will terminate with this error message | No |
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
```kcl
|
||||
n = 10
|
||||
assert(n, isEqualTo = 10)
|
||||
assert(n, isGreaterThanOrEqual = 0, isLessThan = 100, error = "number should be between 0 and 100")
|
||||
assert(1.0000000000012, isEqualTo = 1, tolerance = 0.0001, error = "number should be almost exactly 1")
|
||||
```
|
||||
|
||||
|
||||
|
35
docs/kcl-std/functions/std-assertIs.md
Normal file
35
docs/kcl-std/functions/std-assertIs.md
Normal file
@ -0,0 +1,35 @@
|
||||
---
|
||||
title: "assertIs"
|
||||
subtitle: "Function in std"
|
||||
excerpt: "Asserts that a value is the boolean value true."
|
||||
layout: manual
|
||||
---
|
||||
|
||||
Asserts that a value is the boolean value true.
|
||||
|
||||
```kcl
|
||||
assertIs(
|
||||
@actual: bool,
|
||||
error?: string,
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Arguments
|
||||
|
||||
| Name | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `actual` | [`bool`](/docs/kcl-std/types/std-types-bool) | Value to check. If this is the boolean value true, assert passes. Otherwise it fails.. | Yes |
|
||||
| `error` | [`string`](/docs/kcl-std/types/std-types-string) | If the value was false, the program will terminate with this error message | No |
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
```kcl
|
||||
kclIsFun = true
|
||||
assertIs(kclIsFun)
|
||||
```
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@ layout: manual
|
||||
|
||||
```kcl
|
||||
circle(
|
||||
@sketch_or_surface: Sketch | Plane | Face,
|
||||
@sketchOrSurface: Sketch | Plane | Face,
|
||||
center: Point2d,
|
||||
radius?: number(Length),
|
||||
diameter?: number(Length),
|
||||
@ -24,7 +24,7 @@ the provided (x, y) origin point.
|
||||
|
||||
| Name | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `sketch_or_surface` | [`Sketch`](/docs/kcl-std/types/std-types-Sketch) or [`Plane`](/docs/kcl-std/types/std-types-Plane) or [`Face`](/docs/kcl-std/types/std-types-Face) | Sketch to extend, or plane or surface to sketch on. | Yes |
|
||||
| `sketchOrSurface` | [`Sketch`](/docs/kcl-std/types/std-types-Sketch) or [`Plane`](/docs/kcl-std/types/std-types-Plane) or [`Face`](/docs/kcl-std/types/std-types-Face) | Sketch to extend, or plane or surface to sketch on. | Yes |
|
||||
| `center` | [`Point2d`](/docs/kcl-std/types/std-types-Point2d) | The center of the circle. | Yes |
|
||||
| `radius` | [`number(Length)`](/docs/kcl-std/types/std-types-number) | The radius of the circle. Incompatible with `diameter`. | No |
|
||||
| `diameter` | [`number(Length)`](/docs/kcl-std/types/std-types-number) | The diameter of the circle. Incompatible with `radius`. | No |
|
||||
|
47
docs/kcl-std/functions/std-sketch-circleThreePoint.md
Normal file
47
docs/kcl-std/functions/std-sketch-circleThreePoint.md
Normal file
File diff suppressed because one or more lines are too long
140
docs/kcl-std/functions/std-sketch-extrude.md
Normal file
140
docs/kcl-std/functions/std-sketch-extrude.md
Normal file
File diff suppressed because one or more lines are too long
112
docs/kcl-std/functions/std-sketch-loft.md
Normal file
112
docs/kcl-std/functions/std-sketch-loft.md
Normal file
File diff suppressed because one or more lines are too long
62
docs/kcl-std/functions/std-sketch-patternCircular2d.md
Normal file
62
docs/kcl-std/functions/std-sketch-patternCircular2d.md
Normal file
File diff suppressed because one or more lines are too long
72
docs/kcl-std/functions/std-sketch-patternLinear2d.md
Normal file
72
docs/kcl-std/functions/std-sketch-patternLinear2d.md
Normal file
File diff suppressed because one or more lines are too long
68
docs/kcl-std/functions/std-sketch-polygon.md
Normal file
68
docs/kcl-std/functions/std-sketch-polygon.md
Normal file
File diff suppressed because one or more lines are too long
149
docs/kcl-std/functions/std-sketch-sweep.md
Normal file
149
docs/kcl-std/functions/std-sketch-sweep.md
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user