diff --git a/docs/kcl-std/functions/std-appearance-hexString.md b/docs/kcl-std/functions/std-appearance-hexString.md index dfcb93f4e..23aaf05f4 100644 --- a/docs/kcl-std/functions/std-appearance-hexString.md +++ b/docs/kcl-std/functions/std-appearance-hexString.md @@ -8,11 +8,13 @@ layout: manual Build a color from its red, green and blue components. These must be between 0 and 255. ```kcl -appearance::hexString(@rgb: [number(_); 3]): string +startSketchOn(-XZ) + |> circle(center = [0, 0], radius = 10) + |> extrude(length = 4) + |> appearance(color = appearance::hexString([50, 160, 160])) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +26,12 @@ appearance::hexString(@rgb: [number(_); 3]): string [`string`](/docs/kcl-std/types/std-types-string) - A sequence of characters +### Function signature + +```kcl +appearance::hexString(@rgb: [number(_); 3]): string +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-array-map.md b/docs/kcl-std/functions/std-array-map.md index 88f7cbb51..ee5fbc697 100644 --- a/docs/kcl-std/functions/std-array-map.md +++ b/docs/kcl-std/functions/std-array-map.md @@ -8,14 +8,18 @@ layout: manual Apply a function to every element of a list. ```kcl -map( - @array: [any], - f: fn(any): any, -): [any] -``` +r = 10 // radius +fn drawCircle(@id) { + return startSketchOn(XY) + |> circle(center = [id * 2 * r, 0], radius = r) +} -Given a list like `[a, b, c]`, and a function like `f`, returns -`[f(a), f(b), f(c)]` +// Call `drawCircle`, passing in each element of the array. +// The outputs from each `drawCircle` form a new array, +// which is the return value from `map`. +circles = map([1..3], f = drawCircle) + +``` ### Arguments @@ -28,6 +32,19 @@ Given a list like `[a, b, c]`, and a function like `f`, returns [`[any]`](/docs/kcl-std/types/std-types-any) +### Description + +Given a list like `[a, b, c]`, and a function like `f`, returns +`[f(a), f(b), f(c)]` + +### Function signature + +```kcl +map( + @array: [any], + f: fn(any): any, +): [any] +``` ### Examples diff --git a/docs/kcl-std/functions/std-array-pop.md b/docs/kcl-std/functions/std-array-pop.md index 3bf1723db..35abae7a6 100644 --- a/docs/kcl-std/functions/std-array-pop.md +++ b/docs/kcl-std/functions/std-array-pop.md @@ -8,10 +8,28 @@ layout: manual Remove the last element from an array. ```kcl -pop(@array: [any; 1+]): [any] -``` +arr = [1, 2, 3, 4] +new_arr = pop(arr) +assert( + new_arr[0], + isEqualTo = 1, + tolerance = 0.00001, + error = "1 is the first element of the array", +) +assert( + new_arr[1], + isEqualTo = 2, + tolerance = 0.00001, + error = "2 is the second element of the array", +) +assert( + new_arr[2], + isEqualTo = 3, + tolerance = 0.00001, + error = "3 is the third element of the array", +) -Returns a new array with the last element removed. +``` ### Arguments @@ -23,6 +41,15 @@ Returns a new array with the last element removed. [`[any]`](/docs/kcl-std/types/std-types-any) +### Description + +Returns a new array with the last element removed. + +### Function signature + +```kcl +pop(@array: [any; 1+]): [any] +``` ### Examples diff --git a/docs/kcl-std/functions/std-array-push.md b/docs/kcl-std/functions/std-array-push.md index 98da8a968..0993114dc 100644 --- a/docs/kcl-std/functions/std-array-push.md +++ b/docs/kcl-std/functions/std-array-push.md @@ -8,13 +8,16 @@ layout: manual Append an element to the end of an array. ```kcl -push( - @array: [any], - item: any, -): [any; 1+] -``` +arr = [1, 2, 3] +new_arr = push(arr, item = 4) +assert( + new_arr[3], + isEqualTo = 4, + tolerance = 0.1, + error = "4 was added to the end of the array", +) -Returns a new array with the element appended. +``` ### Arguments @@ -27,6 +30,18 @@ Returns a new array with the element appended. [`[any; 1+]`](/docs/kcl-std/types/std-types-any) +### Description + +Returns a new array with the element appended. + +### Function signature + +```kcl +push( + @array: [any], + item: any, +): [any; 1+] +``` ### Examples diff --git a/docs/kcl-std/functions/std-array-reduce.md b/docs/kcl-std/functions/std-array-reduce.md index 4a862df3e..23a932185 100644 --- a/docs/kcl-std/functions/std-array-reduce.md +++ b/docs/kcl-std/functions/std-array-reduce.md @@ -8,15 +8,36 @@ layout: manual Take a starting value. Then, for each element of an array, calculate the next value, using the previous value and the element. ```kcl -reduce( - @array: [any], - initial: any, - f: fn(any, accum: any): any, -): any +// This function adds two numbers. +fn add(@a, accum) { + return a + accum +} + +// This function adds an array of numbers. +// It uses the `reduce` function, to call the `add` function on every +// element of the `arr` parameter. The starting value is 0. +fn sum(@arr) { + return reduce(arr, initial = 0, f = add) +} + +/* The above is basically like this pseudo-code: +fn sum(arr): + sumSoFar = 0 + for i in arr: + sumSoFar = add(i, sumSoFar) + return sumSoFar */ + +// We use `assert` to check that our `sum` function gives the +// expected result. It's good to check your work! +assert( + sum([1, 2, 3]), + isEqualTo = 6, + tolerance = 0.1, + error = "1 + 2 + 3 summed is 6", +) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -30,6 +51,16 @@ reduce( [`any`](/docs/kcl-std/types/std-types-any) - The [`any`](/docs/kcl-std/types/std-types-any) type is the type of all possible values in KCL. I.e., if a function accepts an argument with type [`any`](/docs/kcl-std/types/std-types-any), then it can accept any value. +### Function signature + +```kcl +reduce( + @array: [any], + initial: any, + f: fn(any, accum: any): any, +): any +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-assert.md b/docs/kcl-std/functions/std-assert.md index df83c32b8..646ad14c5 100644 --- a/docs/kcl-std/functions/std-assert.md +++ b/docs/kcl-std/functions/std-assert.md @@ -8,20 +8,23 @@ layout: manual Check a value meets some expected conditions at runtime. Program terminates with an error if conditions aren't met. If you provide multiple conditions, they will all be checked and all must be met. ```kcl +n = 10 +assert(n, isEqualTo = 10) assert( - @actual: number, - isGreaterThan?: number, - isLessThan?: number, - isGreaterThanOrEqual?: number, - isLessThanOrEqual?: number, - isEqualTo?: number, - tolerance?: number, - error?: string, + n, + isGreaterThanOrEqual = 0, + isLessThan = 100, + error = "number should be between 0 and 100", ) +assert( + 1.0000000000012, + isEqualTo = 1, + tolerance = 0.0001, + error = "number should be almost exactly 1", +) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -36,6 +39,21 @@ assert( | `error` | [`string`](/docs/kcl-std/types/std-types-string) | If the value was false, the program will terminate with this error message | No | +### Function signature + +```kcl +assert( + @actual: number, + isGreaterThan?: number, + isLessThan?: number, + isGreaterThanOrEqual?: number, + isLessThanOrEqual?: number, + isEqualTo?: number, + tolerance?: number, + error?: string, +) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-assertIs.md b/docs/kcl-std/functions/std-assertIs.md index 02eb27c2c..b2d9dfbdf 100644 --- a/docs/kcl-std/functions/std-assertIs.md +++ b/docs/kcl-std/functions/std-assertIs.md @@ -8,14 +8,11 @@ layout: manual Asserts that a value is the boolean value true. ```kcl -assertIs( - @actual: bool, - error?: string, -) +kclIsFun = true +assertIs(kclIsFun) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +21,15 @@ assertIs( | `error` | [`string`](/docs/kcl-std/types/std-types-string) | If the value was false, the program will terminate with this error message | No | +### Function signature + +```kcl +assertIs( + @actual: bool, + error?: string, +) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-clone.md b/docs/kcl-std/functions/std-clone.md index dc7a60e3c..929817f6f 100644 --- a/docs/kcl-std/functions/std-clone.md +++ b/docs/kcl-std/functions/std-clone.md @@ -8,18 +8,21 @@ layout: manual Clone a sketch or solid. ```kcl -clone(@geometry: Sketch | Solid | ImportedGeometry): Sketch | Solid | ImportedGeometry +// Clone a basic sketch and move it and extrude it. +exampleSketch = startSketchOn(XY) + |> startProfile(at = [0, 0]) + |> line(end = [10, 0]) + |> line(end = [0, 10]) + |> line(end = [-10, 0]) + |> close() + +clonedSketch = clone(exampleSketch) + |> scale(x = 1.0, y = 1.0, z = 2.5) + |> translate(x = 15.0, y = 0, z = 0) + |> extrude(length = 5) + ``` -This works essentially like a copy-paste operation. It creates a perfect replica -at that point in time that you can manipulate individually afterwards. - -This doesn't really have much utility unless you need the equivalent of a double -instance pattern with zero transformations. - -Really only use this function if YOU ARE SURE you need it. In most cases you -do not need clone and using a pattern with `instance = 2` is more appropriate. - ### Arguments | Name | Type | Description | Required | @@ -30,6 +33,22 @@ do not need clone and using a pattern with `instance = 2` is more appropriate. [`Sketch`](/docs/kcl-std/types/std-types-Sketch) or [`Solid`](/docs/kcl-std/types/std-types-Solid) or [`ImportedGeometry`](/docs/kcl-std/types/std-types-ImportedGeometry) +### Description + +This works essentially like a copy-paste operation. It creates a perfect replica +at that point in time that you can manipulate individually afterwards. + +This doesn't really have much utility unless you need the equivalent of a double +instance pattern with zero transformations. + +Really only use this function if YOU ARE SURE you need it. In most cases you +do not need clone and using a pattern with `instance = 2` is more appropriate. + +### Function signature + +```kcl +clone(@geometry: Sketch | Solid | ImportedGeometry): Sketch | Solid | ImportedGeometry +``` ### Examples diff --git a/docs/kcl-std/functions/std-helix.md b/docs/kcl-std/functions/std-helix.md index 6087dd2a0..25c9dc5f3 100644 --- a/docs/kcl-std/functions/std-helix.md +++ b/docs/kcl-std/functions/std-helix.md @@ -8,19 +8,23 @@ layout: manual Create a helix. ```kcl -helix( - revolutions: number(_), - angleStart: number(Angle), - ccw?: bool, - radius?: number(Length), - axis?: Axis3d | Edge, - length?: number(Length), - cylinder?: Solid, -): Helix +// Create a helix around the Z axis. +helixPath = helix( + angleStart = 0, + ccw = true, + revolutions = 5, + length = 10, + radius = 5, + axis = Z, +) + +// Create a spring by sweeping around the helix path. +springSketch = startSketchOn(XZ) + |> circle(center = [5, 0], radius = 0.5) + |> sweep(path = helixPath) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -38,6 +42,20 @@ helix( [`Helix`](/docs/kcl-std/types/std-types-Helix) - A helix; created by the `helix` function. +### Function signature + +```kcl +helix( + revolutions: number(_), + angleStart: number(Angle), + ccw?: bool, + radius?: number(Length), + axis?: Axis3d | Edge, + length?: number(Length), + cylinder?: Solid, +): Helix +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-abs.md b/docs/kcl-std/functions/std-math-abs.md index b93beb61d..296d7b83a 100644 --- a/docs/kcl-std/functions/std-math-abs.md +++ b/docs/kcl-std/functions/std-math-abs.md @@ -8,11 +8,20 @@ layout: manual Compute the absolute value of a number. ```kcl -abs(@input: number): number +myAngle = -120deg + +sketch001 = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [8, 0]) + |> angledLine(angle = abs(myAngle), length = 5) + |> line(end = [-5, 0]) + |> angledLine(angle = myAngle, length = 5) + |> close() + +baseExtrusion = extrude(sketch001, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +33,12 @@ abs(@input: number): number [`number`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +abs(@input: number): number +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-acos.md b/docs/kcl-std/functions/std-math-acos.md index 7e924c118..dd3b39f7d 100644 --- a/docs/kcl-std/functions/std-math-acos.md +++ b/docs/kcl-std/functions/std-math-acos.md @@ -8,11 +8,17 @@ layout: manual Compute the arccosine of a number. ```kcl -acos(@num: number(_)): number(rad) +sketch001 = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> angledLine(angle = acos(0.5), length = 10) + |> line(end = [5, 0]) + |> line(endAbsolute = [12, 0]) + |> close() + +extrude001 = extrude(sketch001, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +30,12 @@ acos(@num: number(_)): number(rad) [`number(rad)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +acos(@num: number(_)): number(rad) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-asin.md b/docs/kcl-std/functions/std-math-asin.md index 044db0be7..63dd1319c 100644 --- a/docs/kcl-std/functions/std-math-asin.md +++ b/docs/kcl-std/functions/std-math-asin.md @@ -8,11 +8,16 @@ layout: manual Compute the arcsine of a number. ```kcl -asin(@num: number(_)): number(rad) +sketch001 = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> angledLine(angle = asin(0.5), length = 20) + |> yLine(endAbsolute = 0) + |> close() + +extrude001 = extrude(sketch001, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +29,12 @@ asin(@num: number(_)): number(rad) [`number(rad)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +asin(@num: number(_)): number(rad) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-atan.md b/docs/kcl-std/functions/std-math-atan.md index 7dbc35780..88a63797c 100644 --- a/docs/kcl-std/functions/std-math-atan.md +++ b/docs/kcl-std/functions/std-math-atan.md @@ -8,10 +8,15 @@ layout: manual Compute the arctangent of a number. ```kcl -atan(@num: number(_)): number(rad) -``` +sketch001 = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> angledLine(angle = atan(1.25), length = 20) + |> yLine(endAbsolute = 0) + |> close() -Consider using `atan2()` instead for the true inverse of tangent. +extrude001 = extrude(sketch001, length = 5) + +``` ### Arguments @@ -23,6 +28,15 @@ Consider using `atan2()` instead for the true inverse of tangent. [`number(rad)`](/docs/kcl-std/types/std-types-number) - A number. +### Description + +Consider using `atan2()` instead for the true inverse of tangent. + +### Function signature + +```kcl +atan(@num: number(_)): number(rad) +``` ### Examples diff --git a/docs/kcl-std/functions/std-math-atan2.md b/docs/kcl-std/functions/std-math-atan2.md index 66714cfe0..4d2e6bc11 100644 --- a/docs/kcl-std/functions/std-math-atan2.md +++ b/docs/kcl-std/functions/std-math-atan2.md @@ -8,14 +8,16 @@ layout: manual Compute the four quadrant arctangent of Y and X. ```kcl -atan2( - y: number(Length), - x: number(Length), -): number(rad) +sketch001 = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> angledLine(angle = atan2(y = 1.25, x = 2), length = 20) + |> yLine(endAbsolute = 0) + |> close() + +extrude001 = extrude(sketch001, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -28,6 +30,15 @@ atan2( [`number(rad)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +atan2( + y: number(Length), + x: number(Length), +): number(rad) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-ceil.md b/docs/kcl-std/functions/std-math-ceil.md index 2572c45c0..9527eec14 100644 --- a/docs/kcl-std/functions/std-math-ceil.md +++ b/docs/kcl-std/functions/std-math-ceil.md @@ -8,11 +8,17 @@ layout: manual Compute the smallest integer greater than or equal to a number. ```kcl -ceil(@input: number): number +sketch001 = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(endAbsolute = [12, 10]) + |> line(end = [ceil(7.02986), 0]) + |> yLine(endAbsolute = 0) + |> close() + +extrude001 = extrude(sketch001, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +30,12 @@ ceil(@input: number): number [`number`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +ceil(@input: number): number +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-cos.md b/docs/kcl-std/functions/std-math-cos.md index cbd3a6f9f..7e502be5d 100644 --- a/docs/kcl-std/functions/std-math-cos.md +++ b/docs/kcl-std/functions/std-math-cos.md @@ -8,11 +8,16 @@ layout: manual Compute the cosine of a number. ```kcl -cos(@num: number(Angle)): number +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> angledLine(angle = 30deg, length = 3 / cos(30deg)) + |> yLine(endAbsolute = 0) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +29,12 @@ cos(@num: number(Angle)): number [`number`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +cos(@num: number(Angle)): number +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-floor.md b/docs/kcl-std/functions/std-math-floor.md index 28a609277..487f6ab00 100644 --- a/docs/kcl-std/functions/std-math-floor.md +++ b/docs/kcl-std/functions/std-math-floor.md @@ -8,11 +8,17 @@ layout: manual Compute the largest integer less than or equal to a number. ```kcl -floor(@input: number): number +sketch001 = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(endAbsolute = [12, 10]) + |> line(end = [floor(7.02986), 0]) + |> yLine(endAbsolute = 0) + |> close() + +extrude001 = extrude(sketch001, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +30,12 @@ floor(@input: number): number [`number`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +floor(@input: number): number +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-legAngX.md b/docs/kcl-std/functions/std-math-legAngX.md index fe05bf324..0c7c032c7 100644 --- a/docs/kcl-std/functions/std-math-legAngX.md +++ b/docs/kcl-std/functions/std-math-legAngX.md @@ -8,14 +8,10 @@ layout: manual Compute the angle of the given leg for x. ```kcl -legAngX( - hypotenuse: number(Length), - leg: number(Length), -): number(deg) +legAngX(hypotenuse = 5, leg = 3) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -28,6 +24,15 @@ legAngX( [`number(deg)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +legAngX( + hypotenuse: number(Length), + leg: number(Length), +): number(deg) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-legAngY.md b/docs/kcl-std/functions/std-math-legAngY.md index 68206ee2b..c7ebe9ecc 100644 --- a/docs/kcl-std/functions/std-math-legAngY.md +++ b/docs/kcl-std/functions/std-math-legAngY.md @@ -8,14 +8,10 @@ layout: manual Compute the angle of the given leg for y. ```kcl -legAngY( - hypotenuse: number(Length), - leg: number(Length), -): number(deg) +legAngY(hypotenuse = 5, leg = 3) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -28,6 +24,15 @@ legAngY( [`number(deg)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +legAngY( + hypotenuse: number(Length), + leg: number(Length), +): number(deg) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-legLen.md b/docs/kcl-std/functions/std-math-legLen.md index d14e5da52..ca2fbc61a 100644 --- a/docs/kcl-std/functions/std-math-legLen.md +++ b/docs/kcl-std/functions/std-math-legLen.md @@ -8,14 +8,10 @@ layout: manual Compute the length of the given leg. ```kcl -legLen( - hypotenuse: number(Length), - leg: number(Length), -): number(Length) +legLen(hypotenuse = 5, leg = 3) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -28,6 +24,15 @@ legLen( [`number(Length)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +legLen( + hypotenuse: number(Length), + leg: number(Length), +): number(Length) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-ln.md b/docs/kcl-std/functions/std-math-ln.md index 768164e19..ee63253f1 100644 --- a/docs/kcl-std/functions/std-math-ln.md +++ b/docs/kcl-std/functions/std-math-ln.md @@ -8,11 +8,17 @@ layout: manual Compute the natural logarithm of the number. ```kcl -ln(@input: number): number +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [ln(100), 15]) + |> line(end = [5, -6]) + |> line(end = [-10, -10]) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +30,12 @@ ln(@input: number): number [`number`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +ln(@input: number): number +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-log.md b/docs/kcl-std/functions/std-math-log.md index 106fa89d2..254aa7482 100644 --- a/docs/kcl-std/functions/std-math-log.md +++ b/docs/kcl-std/functions/std-math-log.md @@ -8,15 +8,16 @@ layout: manual Compute the logarithm of the number with respect to an arbitrary base. ```kcl -log( - @input: number, - base: number(_), -): number -``` +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [log(100, base = 5), 0]) + |> line(end = [5, 8]) + |> line(end = [-10, 0]) + |> close() -The result might not be correctly rounded owing to implementation -details; `log2` can produce more accurate results for base 2, -and `log10` can produce more accurate results for base 10. +example = extrude(exampleSketch, length = 5) + +``` ### Arguments @@ -29,6 +30,20 @@ and `log10` can produce more accurate results for base 10. [`number`](/docs/kcl-std/types/std-types-number) - A number. +### Description + +The result might not be correctly rounded owing to implementation +details; `log2` can produce more accurate results for base 2, +and `log10` can produce more accurate results for base 10. + +### Function signature + +```kcl +log( + @input: number, + base: number(_), +): number +``` ### Examples diff --git a/docs/kcl-std/functions/std-math-log10.md b/docs/kcl-std/functions/std-math-log10.md index bf77b75ca..07949295e 100644 --- a/docs/kcl-std/functions/std-math-log10.md +++ b/docs/kcl-std/functions/std-math-log10.md @@ -8,11 +8,17 @@ layout: manual Compute the base 10 logarithm of the number. ```kcl -log10(@input: number): number +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [log10(100), 0]) + |> line(end = [5, 8]) + |> line(end = [-10, 0]) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +30,12 @@ log10(@input: number): number [`number`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +log10(@input: number): number +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-log2.md b/docs/kcl-std/functions/std-math-log2.md index e3e10a8e1..aa9184f33 100644 --- a/docs/kcl-std/functions/std-math-log2.md +++ b/docs/kcl-std/functions/std-math-log2.md @@ -8,11 +8,17 @@ layout: manual Compute the base 2 logarithm of the number. ```kcl -log2(@input: number): number +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [log2(100), 0]) + |> line(end = [5, 8]) + |> line(end = [-10, 0]) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +30,12 @@ log2(@input: number): number [`number`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +log2(@input: number): number +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-max.md b/docs/kcl-std/functions/std-math-max.md index d45f48072..b945ae19f 100644 --- a/docs/kcl-std/functions/std-math-max.md +++ b/docs/kcl-std/functions/std-math-max.md @@ -8,11 +8,16 @@ layout: manual Compute the maximum of the given arguments. ```kcl -max(@input: [number; 1+]): number +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> angledLine(angle = 70deg, length = max([15, 31, 4, 13, 22])) + |> line(end = [20, 0]) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +29,12 @@ max(@input: [number; 1+]): number [`number`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +max(@input: [number; 1+]): number +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-min.md b/docs/kcl-std/functions/std-math-min.md index 4fc273e87..6a7040335 100644 --- a/docs/kcl-std/functions/std-math-min.md +++ b/docs/kcl-std/functions/std-math-min.md @@ -8,11 +8,16 @@ layout: manual Compute the minimum of the given arguments. ```kcl -min(@input: [number; 1+]): number +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> angledLine(angle = 70deg, length = min([15, 31, 4, 13, 22])) + |> line(end = [20, 0]) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +29,12 @@ min(@input: [number; 1+]): number [`number`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +min(@input: [number; 1+]): number +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-polar.md b/docs/kcl-std/functions/std-math-polar.md index b94a3cc8e..b654b806e 100644 --- a/docs/kcl-std/functions/std-math-polar.md +++ b/docs/kcl-std/functions/std-math-polar.md @@ -8,14 +8,18 @@ layout: manual Convert polar/sphere (azimuth, elevation, distance) coordinates to cartesian (x/y/z grid) coordinates. ```kcl -polar( - angle: number(rad), - length: number(Length), -): Point2d +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = polar(angle = 30deg, length = 5), tag = $thing) + |> line(end = [0, 5]) + |> line(end = [segEndX(thing), 0]) + |> line(end = [-20, 10]) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -28,6 +32,15 @@ polar( [`Point2d`](/docs/kcl-std/types/std-types-Point2d) - A point in two dimensional space. +### Function signature + +```kcl +polar( + angle: number(rad), + length: number(Length), +): Point2d +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-pow.md b/docs/kcl-std/functions/std-math-pow.md index 311a42848..408d538fc 100644 --- a/docs/kcl-std/functions/std-math-pow.md +++ b/docs/kcl-std/functions/std-math-pow.md @@ -8,14 +8,16 @@ layout: manual Compute the number to a power. ```kcl -pow( - @input: number, - exp: number(_), -): number +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> angledLine(angle = 50deg, length = pow(5, exp = 2)) + |> yLine(endAbsolute = 0) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -28,6 +30,15 @@ pow( [`number`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +pow( + @input: number, + exp: number(_), +): number +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-rem.md b/docs/kcl-std/functions/std-math-rem.md index cd3d41816..d8c1e522b 100644 --- a/docs/kcl-std/functions/std-math-rem.md +++ b/docs/kcl-std/functions/std-math-rem.md @@ -8,14 +8,17 @@ layout: manual Compute the remainder after dividing `num` by `div`. If `num` is negative, the result will be too. ```kcl -rem( - @num: number, - divisor: number, -): number +import rem from "std::math" + +assert(rem(7, divisor = 4), isEqualTo = 3, error = "remainder is 3") +assert(rem(-7, divisor = 4), isEqualTo = -3, error = "remainder is -3") +assert(rem(7, divisor = -4), isEqualTo = 3, error = "remainder is 3") +assert(rem(6, divisor = 2.5), isEqualTo = 1, error = "remainder is 1") +assert(rem(6.5, divisor = 2.5), isEqualTo = 1.5, error = "remainder is 1.5") +assert(rem(6.5, divisor = 2), isEqualTo = 0.5, error = "remainder is 0.5") + ``` - - ### Arguments | Name | Type | Description | Required | @@ -28,6 +31,15 @@ rem( [`number`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +rem( + @num: number, + divisor: number, +): number +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-round.md b/docs/kcl-std/functions/std-math-round.md index 5b0bef84a..ec1ccb899 100644 --- a/docs/kcl-std/functions/std-math-round.md +++ b/docs/kcl-std/functions/std-math-round.md @@ -8,11 +8,17 @@ layout: manual Round a number to the nearest integer. ```kcl -round(@input: number): number +sketch001 = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(endAbsolute = [12, 10]) + |> line(end = [round(7.02986), 0]) + |> yLine(endAbsolute = 0) + |> close() + +extrude001 = extrude(sketch001, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +30,12 @@ round(@input: number): number [`number`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +round(@input: number): number +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-sin.md b/docs/kcl-std/functions/std-math-sin.md index 68e53dadd..024cd94e1 100644 --- a/docs/kcl-std/functions/std-math-sin.md +++ b/docs/kcl-std/functions/std-math-sin.md @@ -8,11 +8,16 @@ layout: manual Compute the sine of a number. ```kcl -sin(@num: number(Angle)): number +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> angledLine(angle = 50deg, length = 15 / sin(135deg)) + |> yLine(endAbsolute = 0) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +29,12 @@ sin(@num: number(Angle)): number [`number`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +sin(@num: number(Angle)): number +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-sqrt.md b/docs/kcl-std/functions/std-math-sqrt.md index 3ff896242..635f8036a 100644 --- a/docs/kcl-std/functions/std-math-sqrt.md +++ b/docs/kcl-std/functions/std-math-sqrt.md @@ -8,11 +8,16 @@ layout: manual Compute the square root of a number. ```kcl -sqrt(@input: number): number +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> angledLine(angle = 50deg, length = sqrt(2500)) + |> yLine(endAbsolute = 0) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +29,12 @@ sqrt(@input: number): number [`number`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +sqrt(@input: number): number +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-math-tan.md b/docs/kcl-std/functions/std-math-tan.md index ca22123df..22d7b418c 100644 --- a/docs/kcl-std/functions/std-math-tan.md +++ b/docs/kcl-std/functions/std-math-tan.md @@ -8,11 +8,16 @@ layout: manual Compute the tangent of a number. ```kcl -tan(@num: number(Angle)): number +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> angledLine(angle = 50deg, length = 50 * tan((1 / 2): number(rad))) + |> yLine(endAbsolute = 0) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +29,12 @@ tan(@num: number(Angle)): number [`number`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +tan(@num: number(Angle)): number +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-offsetPlane.md b/docs/kcl-std/functions/std-offsetPlane.md index 589874c8b..ef9ab0880 100644 --- a/docs/kcl-std/functions/std-offsetPlane.md +++ b/docs/kcl-std/functions/std-offsetPlane.md @@ -8,14 +8,21 @@ layout: manual Offset a plane by a distance along its normal. ```kcl -offsetPlane( - @plane: Plane, - offset: number(Length), -): Plane -``` +// Loft a square and a circle on the `XY` plane using offset. +squareSketch = startSketchOn(XY) + |> startProfile(at = [-100, 200]) + |> line(end = [200, 0]) + |> line(end = [0, -200]) + |> line(end = [-200, 0]) + |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) + |> close() -For example, if you offset the `XZ` plane by 10, the new plane will be parallel to the `XZ` -plane and 10 units away from it. +circleSketch = startSketchOn(offsetPlane(XY, offset = 150)) + |> circle(center = [0, 100], radius = 50) + +loft([squareSketch, circleSketch]) + +``` ### Arguments @@ -28,6 +35,19 @@ plane and 10 units away from it. [`Plane`](/docs/kcl-std/types/std-types-Plane) - An abstract plane. +### Description + +For example, if you offset the `XZ` plane by 10, the new plane will be parallel to the `XZ` +plane and 10 units away from it. + +### Function signature + +```kcl +offsetPlane( + @plane: Plane, + offset: number(Length), +): Plane +``` ### Examples diff --git a/docs/kcl-std/functions/std-sketch-angledLine.md b/docs/kcl-std/functions/std-sketch-angledLine.md index e21af6675..d8180d165 100644 --- a/docs/kcl-std/functions/std-sketch-angledLine.md +++ b/docs/kcl-std/functions/std-sketch-angledLine.md @@ -8,20 +8,18 @@ layout: manual Draw a line segment relative to the current origin using the polar measure of some angle and distance. ```kcl -angledLine( - @sketch: Sketch, - angle: number(Angle), - length?: number(Length), - lengthX?: number(Length), - lengthY?: number(Length), - endAbsoluteX?: number(Length), - endAbsoluteY?: number(Length), - tag?: TagDecl, -): Sketch +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> yLine(endAbsolute = 15) + |> angledLine(angle = 30deg, length = 15) + |> line(end = [8, -10]) + |> yLine(endAbsolute = 0) + |> close() + +example = extrude(exampleSketch, length = 10) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -40,6 +38,21 @@ angledLine( [`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths. +### Function signature + +```kcl +angledLine( + @sketch: Sketch, + angle: number(Angle), + length?: number(Length), + lengthX?: number(Length), + lengthY?: number(Length), + endAbsoluteX?: number(Length), + endAbsoluteY?: number(Length), + tag?: TagDecl, +): Sketch +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-angledLineThatIntersects.md b/docs/kcl-std/functions/std-sketch-angledLineThatIntersects.md index c2862c108..ebeee89de 100644 --- a/docs/kcl-std/functions/std-sketch-angledLineThatIntersects.md +++ b/docs/kcl-std/functions/std-sketch-angledLineThatIntersects.md @@ -8,17 +8,18 @@ layout: manual Draw an angled line from the current origin, constructing a line segment such that the newly created line intersects the desired target line segment. ```kcl -angledLineThatIntersects( - @sketch: Sketch, - angle: number(Angle), - intersectTag: TaggedEdge, - offset?: number(Length), - tag?: TagDecl, -): Sketch +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(endAbsolute = [5, 10]) + |> line(endAbsolute = [-10, 10], tag = $lineToIntersect) + |> line(endAbsolute = [0, 20]) + |> angledLineThatIntersects(angle = 80deg, intersectTag = lineToIntersect, offset = 10) + |> close() + +example = extrude(exampleSketch, length = 10) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -34,6 +35,18 @@ angledLineThatIntersects( [`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths. +### Function signature + +```kcl +angledLineThatIntersects( + @sketch: Sketch, + angle: number(Angle), + intersectTag: TaggedEdge, + offset?: number(Length), + tag?: TagDecl, +): Sketch +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-arc.md b/docs/kcl-std/functions/std-sketch-arc.md index 71ca022a9..ec2bfdee3 100644 --- a/docs/kcl-std/functions/std-sketch-arc.md +++ b/docs/kcl-std/functions/std-sketch-arc.md @@ -8,27 +8,15 @@ layout: manual Draw a curved line segment along an imaginary circle. ```kcl -arc( - @sketch: Sketch, - angleStart?: number(Angle), - angleEnd?: number(Angle), - radius?: number(Length), - diameter?: number(Length), - interiorAbsolute?: Point2d, - endAbsolute?: Point2d, - tag?: TagDecl, -): Sketch +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [10, 0]) + |> arc(angleStart = 0, angleEnd = 280deg, radius = 16) + |> close() +example = extrude(exampleSketch, length = 10) + ``` -The arc is constructed such that the current position of the sketch is -placed along an imaginary circle of the specified radius, at angleStart -degrees. The resulting arc is the segment of the imaginary circle from -that origin point to angleEnd, radius away from the center of the imaginary -circle. - -Unless this makes a lot of sense and feels like what you're looking -for to construct your shape, you're likely looking for tangentialArc. - ### Arguments | Name | Type | Description | Required | @@ -46,6 +34,31 @@ for to construct your shape, you're likely looking for tangentialArc. [`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths. +### Description + +The arc is constructed such that the current position of the sketch is +placed along an imaginary circle of the specified radius, at angleStart +degrees. The resulting arc is the segment of the imaginary circle from +that origin point to angleEnd, radius away from the center of the imaginary +circle. + +Unless this makes a lot of sense and feels like what you're looking +for to construct your shape, you're likely looking for tangentialArc. + +### Function signature + +```kcl +arc( + @sketch: Sketch, + angleStart?: number(Angle), + angleEnd?: number(Angle), + radius?: number(Length), + diameter?: number(Length), + interiorAbsolute?: Point2d, + endAbsolute?: Point2d, + tag?: TagDecl, +): Sketch +``` ### Examples diff --git a/docs/kcl-std/functions/std-sketch-bezierCurve.md b/docs/kcl-std/functions/std-sketch-bezierCurve.md index a762e1b6f..122d4a434 100644 --- a/docs/kcl-std/functions/std-sketch-bezierCurve.md +++ b/docs/kcl-std/functions/std-sketch-bezierCurve.md @@ -8,20 +8,18 @@ layout: manual Draw a smooth, continuous, curved line segment from the current origin to the desired (x, y), using a number of control points to shape the curve's shape. ```kcl -bezierCurve( - @sketch: Sketch, - control1?: Point2d, - control2?: Point2d, - end?: Point2d, - control1Absolute?: Point2d, - control2Absolute?: Point2d, - endAbsolute?: Point2d, - tag?: TagDecl, -): Sketch +// Example using relative control points. +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [0, 10]) + |> bezierCurve(control1 = [5, 0], control2 = [5, 10], end = [10, 10]) + |> line(endAbsolute = [10, 0]) + |> close() + +example = extrude(exampleSketch, length = 10) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -40,6 +38,21 @@ bezierCurve( [`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths. +### Function signature + +```kcl +bezierCurve( + @sketch: Sketch, + control1?: Point2d, + control2?: Point2d, + end?: Point2d, + control1Absolute?: Point2d, + control2Absolute?: Point2d, + endAbsolute?: Point2d, + tag?: TagDecl, +): Sketch +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-circle.md b/docs/kcl-std/functions/std-sketch-circle.md index 9b4e80b99..030194809 100644 --- a/docs/kcl-std/functions/std-sketch-circle.md +++ b/docs/kcl-std/functions/std-sketch-circle.md @@ -8,17 +8,13 @@ layout: manual Construct a 2-dimensional circle, of the specified radius, centered at the provided (x, y) origin point. ```kcl -circle( - @sketchOrSurface: Sketch | Plane | Face, - center: Point2d, - radius?: number(Length), - diameter?: number(Length), - tag?: TagDecl, -): Sketch +exampleSketch = startSketchOn(-XZ) + |> circle(center = [0, 0], radius = 10) + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -34,6 +30,18 @@ circle( [`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths. +### Function signature + +```kcl +circle( + @sketchOrSurface: Sketch | Plane | Face, + center: Point2d, + radius?: number(Length), + diameter?: number(Length), + tag?: TagDecl, +): Sketch +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-circleThreePoint.md b/docs/kcl-std/functions/std-sketch-circleThreePoint.md index 61d5f0583..ce3f2a5b0 100644 --- a/docs/kcl-std/functions/std-sketch-circleThreePoint.md +++ b/docs/kcl-std/functions/std-sketch-circleThreePoint.md @@ -8,17 +8,12 @@ layout: manual Construct a circle derived from 3 points. ```kcl -circleThreePoint( - @sketchOrSurface: Sketch | Plane | Face, - p1: Point2d, - p2: Point2d, - p3: Point2d, - tag?: TagDecl, -): Sketch +exampleSketch = startSketchOn(XY) + |> circleThreePoint(p1 = [10, 10], p2 = [20, 8], p3 = [15, 5]) + |> extrude(length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -34,6 +29,18 @@ circleThreePoint( [`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths. +### Function signature + +```kcl +circleThreePoint( + @sketchOrSurface: Sketch | Plane | Face, + p1: Point2d, + p2: Point2d, + p3: Point2d, + tag?: TagDecl, +): Sketch +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-close.md b/docs/kcl-std/functions/std-sketch-close.md index 1eb6ff126..5ca27d061 100644 --- a/docs/kcl-std/functions/std-sketch-close.md +++ b/docs/kcl-std/functions/std-sketch-close.md @@ -8,16 +8,14 @@ layout: manual Construct a line segment from the current origin back to the profile's origin, ensuring the resulting 2-dimensional sketch is not open-ended. ```kcl -close( - @sketch: Sketch, - tag?: TagDecl, -): Sketch -``` +startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [10, 10]) + |> line(end = [10, 0]) + |> close() + |> extrude(length = 10) -If you want to perform some 3-dimensional operation on a sketch, like -extrude or sweep, you must `close` it first. `close` must be called even -if the end point of the last segment is coincident with the sketch -starting point. +``` ### Arguments @@ -30,6 +28,21 @@ starting point. [`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths. +### Description + +If you want to perform some 3-dimensional operation on a sketch, like +extrude or sweep, you must `close` it first. `close` must be called even +if the end point of the last segment is coincident with the sketch +starting point. + +### Function signature + +```kcl +close( + @sketch: Sketch, + tag?: TagDecl, +): Sketch +``` ### Examples diff --git a/docs/kcl-std/functions/std-sketch-extrude.md b/docs/kcl-std/functions/std-sketch-extrude.md index 274127ed2..12b516e81 100644 --- a/docs/kcl-std/functions/std-sketch-extrude.md +++ b/docs/kcl-std/functions/std-sketch-extrude.md @@ -8,21 +8,18 @@ layout: manual Extend a 2-dimensional sketch through a third dimension in order to create new 3-dimensional volume, or if extruded into an existing volume, cut into an existing solid. ```kcl -extrude( - @sketches: [Sketch; 1+], - length: number(Length), - symmetric?: bool, - bidirectionalLength?: number(Length), - tagStart?: TagDecl, - tagEnd?: TagDecl, - twistAngle?: number(Angle), - twistAngleStep?: number(Angle), - twistCenter?: Point2d, -): [Solid; 1+] -``` +example = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [10, 0]) + |> arc(angleStart = 120deg, angleEnd = 0, radius = 5) + |> line(end = [5, 0]) + |> line(end = [0, 10]) + |> bezierCurve(control1 = [-10, 0], control2 = [2, 10], end = [-5, 10]) + |> line(end = [-5, -2]) + |> close() + |> extrude(length = 10) -You can provide more than one sketch to extrude, and they will all be -extruded in the same direction. +``` ### Arguments @@ -42,6 +39,26 @@ extruded in the same direction. [`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) +### Description + +You can provide more than one sketch to extrude, and they will all be +extruded in the same direction. + +### Function signature + +```kcl +extrude( + @sketches: [Sketch; 1+], + length: number(Length), + symmetric?: bool, + bidirectionalLength?: number(Length), + tagStart?: TagDecl, + tagEnd?: TagDecl, + twistAngle?: number(Angle), + twistAngleStep?: number(Angle), + twistCenter?: Point2d, +): [Solid; 1+] +``` ### Examples diff --git a/docs/kcl-std/functions/std-sketch-getCommonEdge.md b/docs/kcl-std/functions/std-sketch-getCommonEdge.md index d9af9e010..fe5761340 100644 --- a/docs/kcl-std/functions/std-sketch-getCommonEdge.md +++ b/docs/kcl-std/functions/std-sketch-getCommonEdge.md @@ -8,11 +8,29 @@ layout: manual Get the shared edge between two faces. ```kcl -getCommonEdge(faces: [TaggedFace; 2]): Edge +// Get an edge shared between two faces, created after a chamfer. + + +scale = 20 +part001 = startSketchOn(XY) + |> startProfile(at = [0, 0]) + |> line(end = [0, scale]) + |> line(end = [scale, 0]) + |> line(end = [0, -scale]) + |> close(tag = $line0) + |> extrude(length = 20, tagEnd = $end0) + // We tag the chamfer to reference it later. + |> chamfer(length = 10, tags = [getOppositeEdge(line0)], tag = $chamfer0) + +// Get the shared edge between the chamfer and the extrusion. +commonEdge = getCommonEdge(faces = [chamfer0, end0]) + +// Chamfer the shared edge. +// TODO: uncomment this when ssi for fillets lands +// chamfer(part001, length = 5, tags = [commonEdge]) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +42,12 @@ getCommonEdge(faces: [TaggedFace; 2]): Edge [`Edge`](/docs/kcl-std/types/std-types-Edge) - An edge of a solid. +### Function signature + +```kcl +getCommonEdge(faces: [TaggedFace; 2]): Edge +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-getNextAdjacentEdge.md b/docs/kcl-std/functions/std-sketch-getNextAdjacentEdge.md index d5391b0b8..2aebde851 100644 --- a/docs/kcl-std/functions/std-sketch-getNextAdjacentEdge.md +++ b/docs/kcl-std/functions/std-sketch-getNextAdjacentEdge.md @@ -8,11 +8,20 @@ layout: manual Get the next adjacent edge to the edge given. ```kcl -getNextAdjacentEdge(@edge: TaggedEdge): Edge +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [10, 0]) + |> angledLine(angle = 60deg, length = 10) + |> angledLine(angle = 120deg, length = 10) + |> line(end = [-10, 0]) + |> angledLine(angle = 240deg, length = 10, tag = $referenceEdge) + |> close() + +example = extrude(exampleSketch, length = 5) + |> fillet(radius = 3, tags = [getNextAdjacentEdge(referenceEdge)]) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +33,12 @@ getNextAdjacentEdge(@edge: TaggedEdge): Edge [`Edge`](/docs/kcl-std/types/std-types-Edge) - An edge of a solid. +### Function signature + +```kcl +getNextAdjacentEdge(@edge: TaggedEdge): Edge +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-getOppositeEdge.md b/docs/kcl-std/functions/std-sketch-getOppositeEdge.md index 25b2827db..389e4f10b 100644 --- a/docs/kcl-std/functions/std-sketch-getOppositeEdge.md +++ b/docs/kcl-std/functions/std-sketch-getOppositeEdge.md @@ -8,11 +8,20 @@ layout: manual Get the opposite edge to the edge given. ```kcl -getOppositeEdge(@edge: TaggedEdge): Edge +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [10, 0]) + |> angledLine(angle = 60deg, length = 10) + |> angledLine(angle = 120deg, length = 10) + |> line(end = [-10, 0]) + |> angledLine(angle = 240deg, length = 10, tag = $referenceEdge) + |> close() + +example = extrude(exampleSketch, length = 5) + |> fillet(radius = 3, tags = [getOppositeEdge(referenceEdge)]) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +33,12 @@ getOppositeEdge(@edge: TaggedEdge): Edge [`Edge`](/docs/kcl-std/types/std-types-Edge) - An edge of a solid. +### Function signature + +```kcl +getOppositeEdge(@edge: TaggedEdge): Edge +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-getPreviousAdjacentEdge.md b/docs/kcl-std/functions/std-sketch-getPreviousAdjacentEdge.md index c4e0a50df..2c7bad65a 100644 --- a/docs/kcl-std/functions/std-sketch-getPreviousAdjacentEdge.md +++ b/docs/kcl-std/functions/std-sketch-getPreviousAdjacentEdge.md @@ -8,11 +8,20 @@ layout: manual Get the previous adjacent edge to the edge given. ```kcl -getPreviousAdjacentEdge(@edge: TaggedEdge): Edge +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [10, 0]) + |> angledLine(angle = 60deg, length = 10) + |> angledLine(angle = 120deg, length = 10) + |> line(end = [-10, 0]) + |> angledLine(angle = 240deg, length = 10, tag = $referenceEdge) + |> close() + +example = extrude(exampleSketch, length = 5) + |> fillet(radius = 3, tags = [getPreviousAdjacentEdge(referenceEdge)]) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +33,12 @@ getPreviousAdjacentEdge(@edge: TaggedEdge): Edge [`Edge`](/docs/kcl-std/types/std-types-Edge) - An edge of a solid. +### Function signature + +```kcl +getPreviousAdjacentEdge(@edge: TaggedEdge): Edge +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-involuteCircular.md b/docs/kcl-std/functions/std-sketch-involuteCircular.md index 3547b19b4..bf3c9745d 100644 --- a/docs/kcl-std/functions/std-sketch-involuteCircular.md +++ b/docs/kcl-std/functions/std-sketch-involuteCircular.md @@ -8,18 +8,20 @@ layout: manual Extend the current sketch with a new involute circular curve. ```kcl -involuteCircular( - @sketch: Sketch, - startRadius: number(Length), - endRadius: number(Length), - angle: number(Angle), - reverse?: bool, - tag?: TagDecl, -): Sketch +a = 10 +b = 14 +startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> involuteCircular(startRadius = a, endRadius = b, angle = 60deg) + |> involuteCircular( + startRadius = a, + endRadius = b, + angle = 60deg, + reverse = true, + ) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -36,6 +38,19 @@ involuteCircular( [`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths. +### Function signature + +```kcl +involuteCircular( + @sketch: Sketch, + startRadius: number(Length), + endRadius: number(Length), + angle: number(Angle), + reverse?: bool, + tag?: TagDecl, +): Sketch +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-lastSegX.md b/docs/kcl-std/functions/std-sketch-lastSegX.md index 2f023f8f2..7feadb87f 100644 --- a/docs/kcl-std/functions/std-sketch-lastSegX.md +++ b/docs/kcl-std/functions/std-sketch-lastSegX.md @@ -8,11 +8,18 @@ layout: manual Extract the 'x' axis value of the last line segment in the provided 2-d sketch. ```kcl -lastSegX(@sketch: Sketch): number(Length) +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [5, 0]) + |> line(end = [20, 5]) + |> line(end = [lastSegX(%), 0]) + |> line(end = [-15, 0]) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +31,12 @@ lastSegX(@sketch: Sketch): number(Length) [`number(Length)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +lastSegX(@sketch: Sketch): number(Length) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-lastSegY.md b/docs/kcl-std/functions/std-sketch-lastSegY.md index 4f8d8b3f4..dea241464 100644 --- a/docs/kcl-std/functions/std-sketch-lastSegY.md +++ b/docs/kcl-std/functions/std-sketch-lastSegY.md @@ -8,11 +8,18 @@ layout: manual Extract the 'y' axis value of the last line segment in the provided 2-d sketch. ```kcl -lastSegY(@sketch: Sketch): number(Length) +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [5, 0]) + |> line(end = [20, 5]) + |> line(end = [0, lastSegY(%)]) + |> line(end = [-15, 0]) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +31,12 @@ lastSegY(@sketch: Sketch): number(Length) [`number(Length)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +lastSegY(@sketch: Sketch): number(Length) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-line.md b/docs/kcl-std/functions/std-sketch-line.md index e83f9b580..feef7f912 100644 --- a/docs/kcl-std/functions/std-sketch-line.md +++ b/docs/kcl-std/functions/std-sketch-line.md @@ -8,16 +8,29 @@ layout: manual Extend the current sketch with a new straight line. ```kcl -line( - @sketch: Sketch, - endAbsolute?: Point2d, - end?: Point2d, - tag?: TagDecl, -): Sketch +triangle = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + // The END argument means it ends at exactly [10, 0]. + // This is an absolute measurement, it is NOT relative to + // the start of the sketch. + |> line(endAbsolute = [10, 0]) + |> line(endAbsolute = [0, 10]) + |> line(endAbsolute = [-10, 0], tag = $thirdLineOfTriangle) + |> close() + |> extrude(length = 5) + +box = startSketchOn(XZ) + |> startProfile(at = [10, 10]) + // The 'to' argument means move the pen this much. + // So, [10, 0] is a relative distance away from the current point. + |> line(end = [10, 0]) + |> line(end = [0, 10]) + |> line(end = [-10, 0], tag = $thirdLineOfBox) + |> close() + |> extrude(length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -32,6 +45,17 @@ line( [`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths. +### Function signature + +```kcl +line( + @sketch: Sketch, + endAbsolute?: Point2d, + end?: Point2d, + tag?: TagDecl, +): Sketch +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-loft.md b/docs/kcl-std/functions/std-sketch-loft.md index 897a37b9f..9edff91d6 100644 --- a/docs/kcl-std/functions/std-sketch-loft.md +++ b/docs/kcl-std/functions/std-sketch-loft.md @@ -8,18 +8,25 @@ layout: manual Create a 3D surface or solid by interpolating between two or more sketches. ```kcl -loft( - @sketches: [Sketch; 2+], - vDegree?: number(_), - bezApproximateRational?: bool, - baseCurveIndex?: number(_), - tolerance?: number(Length), - tagStart?: TagDecl, - tagEnd?: TagDecl, -): Solid -``` +// Loft a square and a triangle. +squareSketch = startSketchOn(XY) + |> startProfile(at = [-100, 200]) + |> line(end = [200, 0]) + |> line(end = [0, -200]) + |> line(end = [-200, 0]) + |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) + |> close() -The sketches need to be closed and on different planes that are parallel. +triangleSketch = startSketchOn(offsetPlane(XY, offset = 75)) + |> startProfile(at = [0, 125]) + |> line(end = [-15, -30]) + |> line(end = [30, 0]) + |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) + |> close() + +loft([triangleSketch, squareSketch]) + +``` ### Arguments @@ -37,6 +44,23 @@ The sketches need to be closed and on different planes that are parallel. [`Solid`](/docs/kcl-std/types/std-types-Solid) - A solid is a collection of extruded surfaces. +### Description + +The sketches need to be closed and on different planes that are parallel. + +### Function signature + +```kcl +loft( + @sketches: [Sketch; 2+], + vDegree?: number(_), + bezApproximateRational?: bool, + baseCurveIndex?: number(_), + tolerance?: number(Length), + tagStart?: TagDecl, + tagEnd?: TagDecl, +): Solid +``` ### Examples diff --git a/docs/kcl-std/functions/std-sketch-patternCircular2d.md b/docs/kcl-std/functions/std-sketch-patternCircular2d.md index c8436faf5..fcbed965e 100644 --- a/docs/kcl-std/functions/std-sketch-patternCircular2d.md +++ b/docs/kcl-std/functions/std-sketch-patternCircular2d.md @@ -8,18 +8,23 @@ layout: manual Repeat a 2-dimensional sketch some number of times along a partial or complete circle some specified number of times. Each object may additionally be rotated along the circle, ensuring orientation of the solid with respect to the center of the circle is maintained. ```kcl -patternCircular2d( - @sketches: [Sketch; 1+], - instances: number(_), - center: Point2d, - arcDegrees?: number(Angle), - rotateDuplicates?: bool, - useOriginal?: bool, -): [Sketch; 1+] +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [.5, 25]) + |> line(end = [0, 5]) + |> line(end = [-1, 0]) + |> line(end = [0, -5]) + |> close() + |> patternCircular2d( + center = [0, 0], + instances = 13, + arcDegrees = 360, + rotateDuplicates = true, + ) + +example = extrude(exampleSketch, length = 1) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -36,6 +41,19 @@ patternCircular2d( [`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch) +### Function signature + +```kcl +patternCircular2d( + @sketches: [Sketch; 1+], + instances: number(_), + center: Point2d, + arcDegrees?: number(Angle), + rotateDuplicates?: bool, + useOriginal?: bool, +): [Sketch; 1+] +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-patternLinear2d.md b/docs/kcl-std/functions/std-sketch-patternLinear2d.md index 7a26a046c..4dc0f6d6a 100644 --- a/docs/kcl-std/functions/std-sketch-patternLinear2d.md +++ b/docs/kcl-std/functions/std-sketch-patternLinear2d.md @@ -8,17 +8,17 @@ layout: manual Repeat a 2-dimensional sketch along some dimension, with a dynamic amount of distance between each repetition, some specified number of times. ```kcl -patternLinear2d( - @sketches: [Sketch; 1+], - instances: number(_), - distance: number(Length), - axis: Axis2d | Point2d, - useOriginal?: bool, -): [Sketch; 1+] +// / Pattern using a named axis. + + +exampleSketch = startSketchOn(XZ) + |> circle(center = [0, 0], radius = 1) + |> patternLinear2d(axis = X, instances = 7, distance = 4) + +example = extrude(exampleSketch, length = 1) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -34,6 +34,18 @@ patternLinear2d( [`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch) +### Function signature + +```kcl +patternLinear2d( + @sketches: [Sketch; 1+], + instances: number(_), + distance: number(Length), + axis: Axis2d | Point2d, + useOriginal?: bool, +): [Sketch; 1+] +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-patternTransform2d.md b/docs/kcl-std/functions/std-sketch-patternTransform2d.md index 68da45b3f..e3c3b5209 100644 --- a/docs/kcl-std/functions/std-sketch-patternTransform2d.md +++ b/docs/kcl-std/functions/std-sketch-patternTransform2d.md @@ -8,16 +8,18 @@ layout: manual Just like `patternTransform`, but works on 2D sketches not 3D solids. ```kcl -patternTransform2d( - @sketches: [Sketch; 1+], - instances: number(_), - transform: fn(number(_)): { }, - useOriginal?: boolean, -): [Sketch; 1+] +// Each instance will be shifted along the X axis. +fn transform(@id) { + return { translate = [4 * id, 0] } +} + +// Sketch 4 circles. +sketch001 = startSketchOn(XZ) + |> circle(center = [0, 0], radius = 2) + |> patternTransform2d(instances = 4, transform = transform) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -32,6 +34,17 @@ patternTransform2d( [`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch) +### Function signature + +```kcl +patternTransform2d( + @sketches: [Sketch; 1+], + instances: number(_), + transform: fn(number(_)): { }, + useOriginal?: boolean, +): [Sketch; 1+] +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-polygon.md b/docs/kcl-std/functions/std-sketch-polygon.md index 93cf4c0a6..401b1c066 100644 --- a/docs/kcl-std/functions/std-sketch-polygon.md +++ b/docs/kcl-std/functions/std-sketch-polygon.md @@ -8,17 +8,19 @@ layout: manual Create a regular polygon with the specified number of sides that is either inscribed or circumscribed around a circle of the specified radius. ```kcl -polygon( - @sketchOrSurface: Sketch | Plane | Face, - radius: number(Length), - numSides: number(_), - center: Point2d, - inscribed?: bool, -): Sketch +// Create a regular hexagon inscribed in a circle of radius 10 +hex = startSketchOn(XY) + |> polygon( + radius = 10, + numSides = 6, + center = [0, 0], + inscribed = true, + ) + +example = extrude(hex, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -34,6 +36,18 @@ polygon( [`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths. +### Function signature + +```kcl +polygon( + @sketchOrSurface: Sketch | Plane | Face, + radius: number(Length), + numSides: number(_), + center: Point2d, + inscribed?: bool, +): Sketch +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-profileStart.md b/docs/kcl-std/functions/std-sketch-profileStart.md index 35909a36d..305c888c4 100644 --- a/docs/kcl-std/functions/std-sketch-profileStart.md +++ b/docs/kcl-std/functions/std-sketch-profileStart.md @@ -8,11 +8,16 @@ layout: manual Extract the provided 2-dimensional sketch's profile's origin value. ```kcl -profileStart(@profile: Sketch): Point2d +sketch001 = startSketchOn(XY) + |> startProfile(at = [5, 2]) + |> angledLine(angle = 120, length = 50, tag = $seg01) + |> angledLine(angle = segAng(seg01) + 120deg, length = 50) + |> line(end = profileStart(%)) + |> close() + |> extrude(length = 20) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +29,12 @@ profileStart(@profile: Sketch): Point2d [`Point2d`](/docs/kcl-std/types/std-types-Point2d) - A point in two dimensional space. +### Function signature + +```kcl +profileStart(@profile: Sketch): Point2d +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-profileStartX.md b/docs/kcl-std/functions/std-sketch-profileStartX.md index 2f61afa9f..8e05d423b 100644 --- a/docs/kcl-std/functions/std-sketch-profileStartX.md +++ b/docs/kcl-std/functions/std-sketch-profileStartX.md @@ -8,11 +8,14 @@ layout: manual Extract the provided 2-dimensional sketch's profile's origin's 'x' value. ```kcl -profileStartX(@profile: Sketch): number(Length) +sketch001 = startSketchOn(XY) + |> startProfile(at = [5, 2]) + |> angledLine(angle = -26.6, length = 50) + |> angledLine(angle = 90deg, length = 50) + |> angledLine(angle = 30deg, endAbsoluteX = profileStartX(%)) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +27,12 @@ profileStartX(@profile: Sketch): number(Length) [`number(Length)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +profileStartX(@profile: Sketch): number(Length) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-profileStartY.md b/docs/kcl-std/functions/std-sketch-profileStartY.md index a259d035d..da94cc30b 100644 --- a/docs/kcl-std/functions/std-sketch-profileStartY.md +++ b/docs/kcl-std/functions/std-sketch-profileStartY.md @@ -8,11 +8,13 @@ layout: manual Extract the provided 2-dimensional sketch's profile's origin's 'y' value. ```kcl -profileStartY(@profile: Sketch): number(Length) +sketch001 = startSketchOn(XY) + |> startProfile(at = [5, 2]) + |> angledLine(angle = -60deg, length = 14) + |> angledLine(angle = 30deg, endAbsoluteY = profileStartY(%)) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +26,12 @@ profileStartY(@profile: Sketch): number(Length) [`number(Length)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +profileStartY(@profile: Sketch): number(Length) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-revolve.md b/docs/kcl-std/functions/std-sketch-revolve.md index 1b8063436..4d2cafb09 100644 --- a/docs/kcl-std/functions/std-sketch-revolve.md +++ b/docs/kcl-std/functions/std-sketch-revolve.md @@ -8,29 +8,20 @@ layout: manual Rotate a sketch around some provided axis, creating a solid from its extent. ```kcl -revolve( - @sketches: [Sketch; 1+], - axis: Axis2d | Edge, - angle?: number(Angle), - tolerance?: number(Length), - symmetric?: bool, - bidirectionalAngle?: number(Angle), - tagStart?: TagDecl, - tagEnd?: TagDecl, -): [Solid; 1+] +part001 = startSketchOn(XY) + |> startProfile(at = [4, 12]) + |> line(end = [2, 0]) + |> line(end = [0, -6]) + |> line(end = [4, -6]) + |> line(end = [0, -6]) + |> line(end = [-3.75, -4.5]) + |> line(end = [0, -5.5]) + |> line(end = [-2, 0]) + |> close() + |> revolve(axis = Y) // default angle is 360deg + ``` -This, like extrude, is able to create a 3-dimensional solid from a -2-dimensional sketch. However, unlike extrude, this creates a solid -by using the extent of the sketch as its revolved around an axis rather -than using the extent of the sketch linearly translated through a third -dimension. - -Revolve occurs around a local sketch axis rather than a global axis. - -You can provide more than one sketch to revolve, and they will all be -revolved around the same axis. - ### Arguments | Name | Type | Description | Required | @@ -48,6 +39,33 @@ revolved around the same axis. [`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) +### Description + +This, like extrude, is able to create a 3-dimensional solid from a +2-dimensional sketch. However, unlike extrude, this creates a solid +by using the extent of the sketch as its revolved around an axis rather +than using the extent of the sketch linearly translated through a third +dimension. + +Revolve occurs around a local sketch axis rather than a global axis. + +You can provide more than one sketch to revolve, and they will all be +revolved around the same axis. + +### Function signature + +```kcl +revolve( + @sketches: [Sketch; 1+], + axis: Axis2d | Edge, + angle?: number(Angle), + tolerance?: number(Length), + symmetric?: bool, + bidirectionalAngle?: number(Angle), + tagStart?: TagDecl, + tagEnd?: TagDecl, +): [Solid; 1+] +``` ### Examples diff --git a/docs/kcl-std/functions/std-sketch-segAng.md b/docs/kcl-std/functions/std-sketch-segAng.md index d337eaeaa..f86ff3b3e 100644 --- a/docs/kcl-std/functions/std-sketch-segAng.md +++ b/docs/kcl-std/functions/std-sketch-segAng.md @@ -8,11 +8,20 @@ layout: manual Compute the angle (in degrees) of the provided line segment. ```kcl -segAng(@tag: TaggedEdge): number(Angle) +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [10, 0]) + |> line(end = [5, 10], tag = $seg01) + |> line(end = [-10, 0]) + |> angledLine(angle = segAng(seg01), length = 10) + |> line(end = [-10, 0]) + |> angledLine(angle = segAng(seg01), length = -15) + |> close() + +example = extrude(exampleSketch, length = 4) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +33,12 @@ segAng(@tag: TaggedEdge): number(Angle) [`number(Angle)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +segAng(@tag: TaggedEdge): number(Angle) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-segEnd.md b/docs/kcl-std/functions/std-sketch-segEnd.md index 3879741ae..82c4dec01 100644 --- a/docs/kcl-std/functions/std-sketch-segEnd.md +++ b/docs/kcl-std/functions/std-sketch-segEnd.md @@ -8,11 +8,30 @@ layout: manual Compute the ending point of the provided line segment. ```kcl -segEnd(@tag: TaggedEdge): Point2d +w = 15 +cube = startSketchOn(XY) + |> startProfile(at = [0, 0]) + |> line(end = [w, 0], tag = $line1) + |> line(end = [0, w], tag = $line2) + |> line(end = [-w, 0], tag = $line3) + |> line(end = [0, -w], tag = $line4) + |> close() + |> extrude(length = 5) + +fn cylinder(radius, tag) { + return startSketchOn(XY) + |> startProfile(at = [0, 0]) + |> circle(radius = radius, center = segEnd(tag)) + |> extrude(length = radius) +} + +cylinder(radius = 1, tag = line1) +cylinder(radius = 2, tag = line2) +cylinder(radius = 3, tag = line3) +cylinder(radius = 4, tag = line4) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +43,12 @@ segEnd(@tag: TaggedEdge): Point2d [`Point2d`](/docs/kcl-std/types/std-types-Point2d) - A point in two dimensional space. +### Function signature + +```kcl +segEnd(@tag: TaggedEdge): Point2d +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-segEndX.md b/docs/kcl-std/functions/std-sketch-segEndX.md index 1581e95e3..ac9f1a4d9 100644 --- a/docs/kcl-std/functions/std-sketch-segEndX.md +++ b/docs/kcl-std/functions/std-sketch-segEndX.md @@ -8,11 +8,18 @@ layout: manual Compute the ending point of the provided line segment along the 'x' axis. ```kcl -segEndX(@tag: TaggedEdge): number(Length) +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [20, 0], tag = $thing) + |> line(end = [0, 5]) + |> line(end = [segEndX(thing), 0]) + |> line(end = [-20, 10]) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +31,12 @@ segEndX(@tag: TaggedEdge): number(Length) [`number(Length)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +segEndX(@tag: TaggedEdge): number(Length) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-segEndY.md b/docs/kcl-std/functions/std-sketch-segEndY.md index bb85d127c..ff758a8a9 100644 --- a/docs/kcl-std/functions/std-sketch-segEndY.md +++ b/docs/kcl-std/functions/std-sketch-segEndY.md @@ -8,11 +8,19 @@ layout: manual Compute the ending point of the provided line segment along the 'y' axis. ```kcl -segEndY(@tag: TaggedEdge): number(Length) +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [20, 0]) + |> line(end = [0, 3], tag = $thing) + |> line(end = [-10, 0]) + |> line(end = [0, segEndY(thing)]) + |> line(end = [-10, 0]) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +32,12 @@ segEndY(@tag: TaggedEdge): number(Length) [`number(Length)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +segEndY(@tag: TaggedEdge): number(Length) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-segLen.md b/docs/kcl-std/functions/std-sketch-segLen.md index e39c0e141..ea852ccfc 100644 --- a/docs/kcl-std/functions/std-sketch-segLen.md +++ b/docs/kcl-std/functions/std-sketch-segLen.md @@ -8,11 +8,17 @@ layout: manual Compute the length of the provided line segment. ```kcl -segLen(@tag: TaggedEdge): number(Length) +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> angledLine(angle = 60, length = 10, tag = $thing) + |> tangentialArc(angle = -120deg, radius = 5) + |> angledLine(angle = -60deg, length = segLen(thing)) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +30,12 @@ segLen(@tag: TaggedEdge): number(Length) [`number(Length)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +segLen(@tag: TaggedEdge): number(Length) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-segStart.md b/docs/kcl-std/functions/std-sketch-segStart.md index bd5d32426..33b48a099 100644 --- a/docs/kcl-std/functions/std-sketch-segStart.md +++ b/docs/kcl-std/functions/std-sketch-segStart.md @@ -8,11 +8,30 @@ layout: manual Compute the starting point of the provided line segment. ```kcl -segStart(@tag: TaggedEdge): Point2d +w = 15 +cube = startSketchOn(XY) + |> startProfile(at = [0, 0]) + |> line(end = [w, 0], tag = $line1) + |> line(end = [0, w], tag = $line2) + |> line(end = [-w, 0], tag = $line3) + |> line(end = [0, -w], tag = $line4) + |> close() + |> extrude(length = 5) + +fn cylinder(radius, tag) { + return startSketchOn(XY) + |> startProfile(at = [0, 0]) + |> circle(radius = radius, center = segStart(tag)) + |> extrude(length = radius) +} + +cylinder(radius = 1, tag = line1) +cylinder(radius = 2, tag = line2) +cylinder(radius = 3, tag = line3) +cylinder(radius = 4, tag = line4) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +43,12 @@ segStart(@tag: TaggedEdge): Point2d [`Point2d`](/docs/kcl-std/types/std-types-Point2d) - A point in two dimensional space. +### Function signature + +```kcl +segStart(@tag: TaggedEdge): Point2d +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-segStartX.md b/docs/kcl-std/functions/std-sketch-segStartX.md index 9afad6e8d..e6fb35b86 100644 --- a/docs/kcl-std/functions/std-sketch-segStartX.md +++ b/docs/kcl-std/functions/std-sketch-segStartX.md @@ -8,11 +8,18 @@ layout: manual Compute the starting point of the provided line segment along the 'x' axis. ```kcl -segStartX(@tag: TaggedEdge): number(Length) +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [20, 0], tag = $thing) + |> line(end = [0, 5]) + |> line(end = [20 - segStartX(thing), 0]) + |> line(end = [-20, 10]) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +31,12 @@ segStartX(@tag: TaggedEdge): number(Length) [`number(Length)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +segStartX(@tag: TaggedEdge): number(Length) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-segStartY.md b/docs/kcl-std/functions/std-sketch-segStartY.md index 09d557426..2d25e43d6 100644 --- a/docs/kcl-std/functions/std-sketch-segStartY.md +++ b/docs/kcl-std/functions/std-sketch-segStartY.md @@ -8,11 +8,19 @@ layout: manual Compute the starting point of the provided line segment along the 'y' axis. ```kcl -segStartY(@tag: TaggedEdge): number(Length) +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [20, 0]) + |> line(end = [0, 3], tag = $thing) + |> line(end = [-10, 0]) + |> line(end = [0, 20 - segStartY(thing)]) + |> line(end = [-10, 0]) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +32,12 @@ segStartY(@tag: TaggedEdge): number(Length) [`number(Length)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +segStartY(@tag: TaggedEdge): number(Length) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-startProfile.md b/docs/kcl-std/functions/std-sketch-startProfile.md index 176460896..0b5fb7030 100644 --- a/docs/kcl-std/functions/std-sketch-startProfile.md +++ b/docs/kcl-std/functions/std-sketch-startProfile.md @@ -8,15 +8,17 @@ layout: manual Start a new profile at a given point. ```kcl -startProfile( - @startProfileOn: Plane | Face, - at: Point2d, - tag?: TagDecl, -): Sketch +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [10, 0]) + |> line(end = [0, 10]) + |> line(end = [-10, 0]) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -30,6 +32,16 @@ startProfile( [`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths. +### Function signature + +```kcl +startProfile( + @startProfileOn: Plane | Face, + at: Point2d, + tag?: TagDecl, +): Sketch +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-startSketchOn.md b/docs/kcl-std/functions/std-sketch-startSketchOn.md index 4ec022012..21e1dc798 100644 --- a/docs/kcl-std/functions/std-sketch-startSketchOn.md +++ b/docs/kcl-std/functions/std-sketch-startSketchOn.md @@ -8,12 +8,48 @@ layout: manual Start a new 2-dimensional sketch on a specific plane or face. ```kcl -startSketchOn( - @planeOrSolid: Solid | Plane, - face?: TaggedFace, -): Plane | Face +exampleSketch = startSketchOn(XY) + |> startProfile(at = [0, 0]) + |> line(end = [10, 0]) + |> line(end = [0, 10]) + |> line(end = [-10, 0]) + |> close() + +example = extrude(exampleSketch, length = 5) + +exampleSketch002 = startSketchOn(example, face = END) + |> startProfile(at = [1, 1]) + |> line(end = [8, 0]) + |> line(end = [0, 8]) + |> line(end = [-8, 0]) + |> close() + +example002 = extrude(exampleSketch002, length = 5) + +exampleSketch003 = startSketchOn(example002, face = END) + |> startProfile(at = [2, 2]) + |> line(end = [6, 0]) + |> line(end = [0, 6]) + |> line(end = [-6, 0]) + |> close() + +example003 = extrude(exampleSketch003, length = 5) + ``` +### Arguments + +| Name | Type | Description | Required | +|----------|------|-------------|----------| +| `planeOrSolid` | [`Solid`](/docs/kcl-std/types/std-types-Solid) or [`Plane`](/docs/kcl-std/types/std-types-Plane) | Profile whose start is being used. | Yes | +| `face` | [`TaggedFace`](/docs/kcl-std/types/std-types-TaggedFace) | Identify a face of a solid if a solid is specified as the input argument (`planeOrSolid`). | No | + +### Returns + +[`Plane`](/docs/kcl-std/types/std-types-Plane) or [`Face`](/docs/kcl-std/types/std-types-Face) + +### Description + ### Sketch on Face Behavior There are some important behaviors to understand when sketching on a face: @@ -31,17 +67,14 @@ The point is if you want to export the result of a sketch on a face, you only need to export the final Solid that was created from the sketch on the face, since it will include all the parent faces and Solids. -### Arguments - -| Name | Type | Description | Required | -|----------|------|-------------|----------| -| `planeOrSolid` | [`Solid`](/docs/kcl-std/types/std-types-Solid) or [`Plane`](/docs/kcl-std/types/std-types-Plane) | Profile whose start is being used. | Yes | -| `face` | [`TaggedFace`](/docs/kcl-std/types/std-types-TaggedFace) | Identify a face of a solid if a solid is specified as the input argument (`planeOrSolid`). | No | - -### Returns - -[`Plane`](/docs/kcl-std/types/std-types-Plane) or [`Face`](/docs/kcl-std/types/std-types-Face) +### Function signature +```kcl +startSketchOn( + @planeOrSolid: Solid | Plane, + face?: TaggedFace, +): Plane | Face +``` ### Examples diff --git a/docs/kcl-std/functions/std-sketch-subtract2d.md b/docs/kcl-std/functions/std-sketch-subtract2d.md index 144a63035..e39c0a0e1 100644 --- a/docs/kcl-std/functions/std-sketch-subtract2d.md +++ b/docs/kcl-std/functions/std-sketch-subtract2d.md @@ -8,14 +8,19 @@ layout: manual Use a 2-dimensional sketch to cut a hole in another 2-dimensional sketch. ```kcl -subtract2d( - @sketch: Sketch, - tool: [Sketch; 1+], -): Sketch +exampleSketch = startSketchOn(XY) + |> startProfile(at = [0, 0]) + |> line(end = [0, 5]) + |> line(end = [5, 0]) + |> line(end = [0, -5]) + |> close() + |> subtract2d(tool = circle(center = [1, 1], radius = .25)) + |> subtract2d(tool = circle(center = [1, 4], radius = .25)) + +example = extrude(exampleSketch, length = 1) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -28,6 +33,15 @@ subtract2d( [`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths. +### Function signature + +```kcl +subtract2d( + @sketch: Sketch, + tool: [Sketch; 1+], +): Sketch +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-sweep.md b/docs/kcl-std/functions/std-sketch-sweep.md index 84140a17d..b6e4bb0d2 100644 --- a/docs/kcl-std/functions/std-sketch-sweep.md +++ b/docs/kcl-std/functions/std-sketch-sweep.md @@ -8,26 +8,28 @@ layout: manual Extrude a sketch along a path. ```kcl -sweep( - @sketches: [Sketch; 1+], - path: Sketch | Helix, - sectional?: bool, - tolerance?: number(Length), - relativeTo?: string, - tagStart?: TagDecl, - tagEnd?: TagDecl, -): [Solid; 1+] +// Create a pipe using a sweep. + +// Create a path for the sweep. +sweepPath = startSketchOn(XZ) + |> startProfile(at = [0.05, 0.05]) + |> line(end = [0, 7]) + |> tangentialArc(angle = 90deg, radius = 5) + |> line(end = [-3, 0]) + |> tangentialArc(angle = -90deg, radius = 5) + |> line(end = [0, 7]) + +// Create a hole for the pipe. +pipeHole = startSketchOn(XY) + |> circle(center = [0, 0], radius = 1.5) + +sweepSketch = startSketchOn(XY) + |> circle(center = [0, 0], radius = 2) + |> subtract2d(tool = pipeHole) + |> sweep(path = sweepPath) + ``` -This, like extrude, is able to create a 3-dimensional solid from a -2-dimensional sketch. However, unlike extrude, this creates a solid -by using the extent of the sketch as its path. This is useful for -creating more complex shapes that can't be created with a simple -extrusion. - -You can provide more than one sketch to sweep, and they will all be -swept along the same path. - ### Arguments | Name | Type | Description | Required | @@ -44,6 +46,30 @@ swept along the same path. [`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) +### Description + +This, like extrude, is able to create a 3-dimensional solid from a +2-dimensional sketch. However, unlike extrude, this creates a solid +by using the extent of the sketch as its path. This is useful for +creating more complex shapes that can't be created with a simple +extrusion. + +You can provide more than one sketch to sweep, and they will all be +swept along the same path. + +### Function signature + +```kcl +sweep( + @sketches: [Sketch; 1+], + path: Sketch | Helix, + sectional?: bool, + tolerance?: number(Length), + relativeTo?: string, + tagStart?: TagDecl, + tagEnd?: TagDecl, +): [Solid; 1+] +``` ### Examples diff --git a/docs/kcl-std/functions/std-sketch-tangentToEnd.md b/docs/kcl-std/functions/std-sketch-tangentToEnd.md index 8a082380c..c07136910 100644 --- a/docs/kcl-std/functions/std-sketch-tangentToEnd.md +++ b/docs/kcl-std/functions/std-sketch-tangentToEnd.md @@ -8,11 +8,19 @@ layout: manual Returns the angle coming out of the end of the segment in degrees. ```kcl -tangentToEnd(@tag: TaggedEdge): number(Angle) +// Horizontal pill. +pillSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [20, 0]) + |> tangentialArc(end = [0, 10], tag = $arc1) + |> angledLine(angle = tangentToEnd(arc1), length = 20) + |> tangentialArc(end = [0, -10]) + |> close() + +pillExtrude = extrude(pillSketch, length = 10) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +32,12 @@ tangentToEnd(@tag: TaggedEdge): number(Angle) [`number(Angle)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +tangentToEnd(@tag: TaggedEdge): number(Angle) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-tangentialArc.md b/docs/kcl-std/functions/std-sketch-tangentialArc.md index fb6eaca45..4efdbb11e 100644 --- a/docs/kcl-std/functions/std-sketch-tangentialArc.md +++ b/docs/kcl-std/functions/std-sketch-tangentialArc.md @@ -8,22 +8,16 @@ layout: manual Starting at the current sketch's origin, draw a curved line segment along some part of an imaginary circle until it reaches the desired (x, y) coordinates. ```kcl -tangentialArc( - @sketch: Sketch, - endAbsolute?: Point2d, - end?: Point2d, - radius?: number(Length), - diameter?: number(Length), - angle?: number(Angle), - tag?: TagDecl, -): Sketch -``` +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> angledLine(angle = 45deg, length = 10) + |> tangentialArc(end = [0, -10]) + |> line(end = [-10, 0]) + |> close() -When using radius and angle, draw a curved line segment along part of an -imaginary circle. The arc is constructed such that the last line segment is -placed tangent to the imaginary circle of the specified radius. The -resulting arc is the segment of the imaginary circle from that tangent point -for 'angle' degrees along the imaginary circle. +example = extrude(exampleSketch, length = 10) + +``` ### Arguments @@ -41,6 +35,27 @@ for 'angle' degrees along the imaginary circle. [`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths. +### Description + +When using radius and angle, draw a curved line segment along part of an +imaginary circle. The arc is constructed such that the last line segment is +placed tangent to the imaginary circle of the specified radius. The +resulting arc is the segment of the imaginary circle from that tangent point +for 'angle' degrees along the imaginary circle. + +### Function signature + +```kcl +tangentialArc( + @sketch: Sketch, + endAbsolute?: Point2d, + end?: Point2d, + radius?: number(Length), + diameter?: number(Length), + angle?: number(Angle), + tag?: TagDecl, +): Sketch +``` ### Examples diff --git a/docs/kcl-std/functions/std-sketch-xLine.md b/docs/kcl-std/functions/std-sketch-xLine.md index 762005451..91c3a0edd 100644 --- a/docs/kcl-std/functions/std-sketch-xLine.md +++ b/docs/kcl-std/functions/std-sketch-xLine.md @@ -8,16 +8,20 @@ layout: manual Draw a line relative to the current origin to a specified distance away from the current position along the 'x' axis. ```kcl -xLine( - @sketch: Sketch, - length?: number(Length), - endAbsolute?: number(Length), - tag?: TagDecl, -): Sketch +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> xLine(length = 15) + |> angledLine(angle = 80deg, length = 15) + |> line(end = [8, -10]) + |> xLine(length = 10) + |> angledLine(angle = 120deg, length = 30) + |> xLine(length = -15) + |> close() + +example = extrude(exampleSketch, length = 10) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -32,6 +36,17 @@ xLine( [`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths. +### Function signature + +```kcl +xLine( + @sketch: Sketch, + length?: number(Length), + endAbsolute?: number(Length), + tag?: TagDecl, +): Sketch +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-sketch-yLine.md b/docs/kcl-std/functions/std-sketch-yLine.md index 9b8cc36ad..dff45d7c1 100644 --- a/docs/kcl-std/functions/std-sketch-yLine.md +++ b/docs/kcl-std/functions/std-sketch-yLine.md @@ -8,16 +8,18 @@ layout: manual Draw a line relative to the current origin to a specified distance away from the current position along the 'y' axis. ```kcl -yLine( - @sketch: Sketch, - length?: number(Length), - endAbsolute?: number(Length), - tag?: TagDecl, -): Sketch +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> yLine(length = 15) + |> angledLine(angle = 30deg, length = 15) + |> line(end = [8, -10]) + |> yLine(length = -5) + |> close() + +example = extrude(exampleSketch, length = 10) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -32,6 +34,17 @@ yLine( [`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths. +### Function signature + +```kcl +yLine( + @sketch: Sketch, + length?: number(Length), + endAbsolute?: number(Length), + tag?: TagDecl, +): Sketch +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-solid-appearance.md b/docs/kcl-std/functions/std-solid-appearance.md index 224de4d1e..b66b8e4ab 100644 --- a/docs/kcl-std/functions/std-solid-appearance.md +++ b/docs/kcl-std/functions/std-solid-appearance.md @@ -8,15 +8,19 @@ layout: manual Set the appearance of a solid. This only works on solids, not sketches or individual paths. ```kcl -appearance( - @solids: [Solid; 1+] | ImportedGeometry, - color: string, - metalness?: number(_), - roughness?: number(_), -): [Solid; 1+] | ImportedGeometry -``` +// Add color to an extruded solid. +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(endAbsolute = [10, 0]) + |> line(endAbsolute = [0, 10]) + |> line(endAbsolute = [-10, 0]) + |> close() -This will work on any solid, including extruded solids, revolved solids, and shelled solids. +example = extrude(exampleSketch, length = 5) + // There are other options besides 'color', but they're optional. + |> appearance(color = '#ff0000') + +``` ### Arguments @@ -31,6 +35,20 @@ This will work on any solid, including extruded solids, revolved solids, and she [`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) or [`ImportedGeometry`](/docs/kcl-std/types/std-types-ImportedGeometry) +### Description + +This will work on any solid, including extruded solids, revolved solids, and shelled solids. + +### Function signature + +```kcl +appearance( + @solids: [Solid; 1+] | ImportedGeometry, + color: string, + metalness?: number(_), + roughness?: number(_), +): [Solid; 1+] | ImportedGeometry +``` ### Examples diff --git a/docs/kcl-std/functions/std-solid-chamfer.md b/docs/kcl-std/functions/std-solid-chamfer.md index 215c1fbd1..dcc2081ff 100644 --- a/docs/kcl-std/functions/std-solid-chamfer.md +++ b/docs/kcl-std/functions/std-solid-chamfer.md @@ -8,17 +8,31 @@ layout: manual Cut a straight transitional edge along a tagged path. ```kcl -chamfer( - @solid: Solid, - length: number(Length), - tags: [Edge; 1+], - tag?: TagDecl, -): Solid -``` +// Chamfer a mounting plate. +width = 20 +length = 10 +thickness = 1 +chamferLength = 2 -Chamfer is similar in function and use to a fillet, except -a fillet will blend the transition along an edge, rather than cut -a sharp, straight transitional edge. +mountingPlateSketch = startSketchOn(XY) + |> startProfile(at = [-width / 2, -length / 2]) + |> line(endAbsolute = [width / 2, -length / 2], tag = $edge1) + |> line(endAbsolute = [width / 2, length / 2], tag = $edge2) + |> line(endAbsolute = [-width / 2, length / 2], tag = $edge3) + |> close(tag = $edge4) + +mountingPlate = extrude(mountingPlateSketch, length = thickness) + |> chamfer( + length = chamferLength, + tags = [ + getNextAdjacentEdge(edge1), + getNextAdjacentEdge(edge2), + getNextAdjacentEdge(edge3), + getNextAdjacentEdge(edge4) + ], + ) + +``` ### Arguments @@ -33,6 +47,22 @@ a sharp, straight transitional edge. [`Solid`](/docs/kcl-std/types/std-types-Solid) - A solid is a collection of extruded surfaces. +### Description + +Chamfer is similar in function and use to a fillet, except +a fillet will blend the transition along an edge, rather than cut +a sharp, straight transitional edge. + +### Function signature + +```kcl +chamfer( + @solid: Solid, + length: number(Length), + tags: [Edge; 1+], + tag?: TagDecl, +): Solid +``` ### Examples diff --git a/docs/kcl-std/functions/std-solid-fillet.md b/docs/kcl-std/functions/std-solid-fillet.md index 1a4dd3a1d..5c3cba204 100644 --- a/docs/kcl-std/functions/std-solid-fillet.md +++ b/docs/kcl-std/functions/std-solid-fillet.md @@ -8,18 +8,30 @@ layout: manual Blend a transitional edge along a tagged path, smoothing the sharp edge. ```kcl -fillet( - @solid: Solid, - radius: number(Length), - tags: [Edge; 1+], - tolerance?: number(Length), - tag?: TagDecl, -): Solid -``` +width = 20 +length = 10 +thickness = 1 +filletRadius = 2 -Fillet is similar in function and use to a chamfer, except -a chamfer will cut a sharp transition along an edge while fillet -will smoothly blend the transition. +mountingPlateSketch = startSketchOn(XY) + |> startProfile(at = [-width / 2, -length / 2]) + |> line(endAbsolute = [width / 2, -length / 2], tag = $edge1) + |> line(endAbsolute = [width / 2, length / 2], tag = $edge2) + |> line(endAbsolute = [-width / 2, length / 2], tag = $edge3) + |> close(tag = $edge4) + +mountingPlate = extrude(mountingPlateSketch, length = thickness) + |> fillet( + radius = filletRadius, + tags = [ + getNextAdjacentEdge(edge1), + getNextAdjacentEdge(edge2), + getNextAdjacentEdge(edge3), + getNextAdjacentEdge(edge4) + ], + ) + +``` ### Arguments @@ -35,6 +47,23 @@ will smoothly blend the transition. [`Solid`](/docs/kcl-std/types/std-types-Solid) - A solid is a collection of extruded surfaces. +### Description + +Fillet is similar in function and use to a chamfer, except +a chamfer will cut a sharp transition along an edge while fillet +will smoothly blend the transition. + +### Function signature + +```kcl +fillet( + @solid: Solid, + radius: number(Length), + tags: [Edge; 1+], + tolerance?: number(Length), + tag?: TagDecl, +): Solid +``` ### Examples diff --git a/docs/kcl-std/functions/std-solid-hollow.md b/docs/kcl-std/functions/std-solid-hollow.md index f3907d483..4f7af17f2 100644 --- a/docs/kcl-std/functions/std-solid-hollow.md +++ b/docs/kcl-std/functions/std-solid-hollow.md @@ -8,14 +8,17 @@ layout: manual Make the inside of a 3D object hollow. ```kcl -hollow( - @solid: Solid, - thickness: number(Length), -): Solid -``` +// Hollow a basic sketch. +firstSketch = startSketchOn(XY) + |> startProfile(at = [-12, 12]) + |> line(end = [24, 0]) + |> line(end = [0, -24]) + |> line(end = [-24, 0]) + |> close() + |> extrude(length = 6) + |> hollow(thickness = 0.25) -Remove volume from a 3-dimensional shape such that a wall of the -provided thickness remains around the exterior of the shape. +``` ### Arguments @@ -28,6 +31,19 @@ provided thickness remains around the exterior of the shape. [`Solid`](/docs/kcl-std/types/std-types-Solid) - A solid is a collection of extruded surfaces. +### Description + +Remove volume from a 3-dimensional shape such that a wall of the +provided thickness remains around the exterior of the shape. + +### Function signature + +```kcl +hollow( + @solid: Solid, + thickness: number(Length), +): Solid +``` ### Examples diff --git a/docs/kcl-std/functions/std-solid-intersect.md b/docs/kcl-std/functions/std-solid-intersect.md index c5f33efa2..f4107dae9 100644 --- a/docs/kcl-std/functions/std-solid-intersect.md +++ b/docs/kcl-std/functions/std-solid-intersect.md @@ -8,16 +8,26 @@ layout: manual Intersect returns the shared volume between multiple solids, preserving only overlapping regions. ```kcl -intersect( - @solids: [Solid; 2+], - tolerance?: number(Length), -): [Solid; 1+] -``` +// Intersect two cubes using the stdlib functions. -Intersect computes the geometric intersection of multiple solid bodies, -returning a new solid representing the volume that is common to all input -solids. This operation is useful for determining shared material regions, -verifying fit, and analyzing overlapping geometries in assemblies. + +fn cube(center, size) { + return startSketchOn(XY) + |> startProfile(at = [center[0] - size, center[1] - size]) + |> line(endAbsolute = [center[0] + size, center[1] - size]) + |> line(endAbsolute = [center[0] + size, center[1] + size]) + |> line(endAbsolute = [center[0] - size, center[1] + size]) + |> close() + |> extrude(length = 10) +} + +part001 = cube(center = [0, 0], size = 10) +part002 = cube(center = [7, 3], size = 5) + |> translate(z = 1) + +intersectedPart = intersect([part001, part002]) + +``` ### Arguments @@ -30,6 +40,21 @@ verifying fit, and analyzing overlapping geometries in assemblies. [`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) +### Description + +Intersect computes the geometric intersection of multiple solid bodies, +returning a new solid representing the volume that is common to all input +solids. This operation is useful for determining shared material regions, +verifying fit, and analyzing overlapping geometries in assemblies. + +### Function signature + +```kcl +intersect( + @solids: [Solid; 2+], + tolerance?: number(Length), +): [Solid; 1+] +``` ### Examples diff --git a/docs/kcl-std/functions/std-solid-patternCircular3d.md b/docs/kcl-std/functions/std-solid-patternCircular3d.md index a3bb12694..0912c28ed 100644 --- a/docs/kcl-std/functions/std-solid-patternCircular3d.md +++ b/docs/kcl-std/functions/std-solid-patternCircular3d.md @@ -8,19 +8,23 @@ layout: manual Repeat a 3-dimensional solid some number of times along a partial or complete circle some specified number of times. Each object may additionally be rotated along the circle, ensuring orientation of the solid with respect to the center of the circle is maintained. ```kcl -patternCircular3d( - @solids: [Solid; 1+], - instances: number(_), - axis: Axis3d | Point3d, - center: Point3d, - arcDegrees?: number(deg), - rotateDuplicates?: bool, - useOriginal?: bool, -): [Solid; 1+] +// / Pattern using a named axis. + + +exampleSketch = startSketchOn(XZ) + |> circle(center = [0, 0], radius = 1) + +example = extrude(exampleSketch, length = -5) + |> patternCircular3d( + axis = X, + center = [10, -20, 0], + instances = 11, + arcDegrees = 360, + rotateDuplicates = true, + ) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -38,6 +42,20 @@ patternCircular3d( [`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) +### Function signature + +```kcl +patternCircular3d( + @solids: [Solid; 1+], + instances: number(_), + axis: Axis3d | Point3d, + center: Point3d, + arcDegrees?: number(deg), + rotateDuplicates?: bool, + useOriginal?: bool, +): [Solid; 1+] +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-solid-patternLinear3d.md b/docs/kcl-std/functions/std-solid-patternLinear3d.md index ffa7958e6..d6a6fe0ec 100644 --- a/docs/kcl-std/functions/std-solid-patternLinear3d.md +++ b/docs/kcl-std/functions/std-solid-patternLinear3d.md @@ -8,17 +8,21 @@ layout: manual Repeat a 3-dimensional solid along a linear path, with a dynamic amount of distance between each repetition, some specified number of times. ```kcl -patternLinear3d( - @solids: [Solid; 1+], - instances: number(_), - distance: number(Length), - axis: Axis3d | Point3d, - useOriginal?: bool, -): [Solid; 1+] +// / Pattern using a named axis. + + +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> line(end = [0, 2]) + |> line(end = [3, 1]) + |> line(end = [0, -4]) + |> close() + +example = extrude(exampleSketch, length = 1) + |> patternLinear3d(axis = X, instances = 7, distance = 6) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -34,6 +38,18 @@ patternLinear3d( [`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) +### Function signature + +```kcl +patternLinear3d( + @solids: [Solid; 1+], + instances: number(_), + distance: number(Length), + axis: Axis3d | Point3d, + useOriginal?: bool, +): [Solid; 1+] +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-solid-patternTransform.md b/docs/kcl-std/functions/std-solid-patternTransform.md index 1d0564b63..9821372be 100644 --- a/docs/kcl-std/functions/std-solid-patternTransform.md +++ b/docs/kcl-std/functions/std-solid-patternTransform.md @@ -8,14 +8,34 @@ layout: manual Repeat a 3-dimensional solid, changing it each time. ```kcl -patternTransform( - @solids: [Solid; 1+], - instances: number(_), - transform: fn(number(_)): { }, - useOriginal?: bool, -): [Solid; 1+] +// Each instance will be shifted along the X axis. +fn transform(@id) { + return { translate = [4 * id, 0, 0] } +} + +// Sketch 4 cylinders. +sketch001 = startSketchOn(XZ) + |> circle(center = [0, 0], radius = 2) + |> extrude(length = 5) + |> patternTransform(instances = 4, transform = transform) + ``` +### Arguments + +| Name | Type | Description | Required | +|----------|------|-------------|----------| +| `solids` | [`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) | The solid(s) to duplicate. | Yes | +| `instances` | [`number(_)`](/docs/kcl-std/types/std-types-number) | The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect. | Yes | +| `transform` | [`fn(number(_)): { }`](/docs/kcl-std/types/std-types-fn) | How each replica should be transformed. The transform function takes a single parameter: an integer representing which number replication the transform is for. E.g. the first replica to be transformed will be passed the argument `1`. This simplifies your math: the transform function can rely on id `0` being the original instance passed into the `patternTransform`. See the examples. | Yes | +| `useOriginal` | [`bool`](/docs/kcl-std/types/std-types-bool) | If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. | No | + +### Returns + +[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) + +### Description + Replicates the 3D solid, applying a transformation function to each replica. Transformation function could alter rotation, scale, visibility, position, etc. @@ -54,19 +74,16 @@ Its properties are: - `rotation.origin` (either "local" i.e. rotate around its own center, "global" i.e. rotate around the scene's center, or a 3D point, defaults to "local") -### Arguments - -| Name | Type | Description | Required | -|----------|------|-------------|----------| -| `solids` | [`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) | The solid(s) to duplicate. | Yes | -| `instances` | [`number(_)`](/docs/kcl-std/types/std-types-number) | The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect. | Yes | -| `transform` | [`fn(number(_)): { }`](/docs/kcl-std/types/std-types-fn) | How each replica should be transformed. The transform function takes a single parameter: an integer representing which number replication the transform is for. E.g. the first replica to be transformed will be passed the argument `1`. This simplifies your math: the transform function can rely on id `0` being the original instance passed into the `patternTransform`. See the examples. | Yes | -| `useOriginal` | [`bool`](/docs/kcl-std/types/std-types-bool) | If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. | No | - -### Returns - -[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) +### Function signature +```kcl +patternTransform( + @solids: [Solid; 1+], + instances: number(_), + transform: fn(number(_)): { }, + useOriginal?: bool, +): [Solid; 1+] +``` ### Examples diff --git a/docs/kcl-std/functions/std-solid-shell.md b/docs/kcl-std/functions/std-solid-shell.md index f7cb1830b..403f83016 100644 --- a/docs/kcl-std/functions/std-solid-shell.md +++ b/docs/kcl-std/functions/std-solid-shell.md @@ -8,15 +8,20 @@ layout: manual Remove volume from a 3-dimensional shape such that a wall of the provided thickness remains, taking volume starting at the provided face, leaving it open in that direction. ```kcl -shell( - @solids: [Solid; 1+], - thickness: number(Length), - faces: [TaggedFace; 1+], -): [Solid] +// Remove the end face for the extrusion. +firstSketch = startSketchOn(XY) + |> startProfile(at = [-12, 12]) + |> line(end = [24, 0]) + |> line(end = [0, -24]) + |> line(end = [-24, 0]) + |> close() + |> extrude(length = 6) + +// Remove the end face for the extrusion. +shell(firstSketch, faces = [END], thickness = 0.25) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -30,6 +35,16 @@ shell( [`[Solid]`](/docs/kcl-std/types/std-types-Solid) +### Function signature + +```kcl +shell( + @solids: [Solid; 1+], + thickness: number(Length), + faces: [TaggedFace; 1+], +): [Solid] +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-solid-subtract.md b/docs/kcl-std/functions/std-solid-subtract.md index 4fcddc3c2..e2a7ed2ed 100644 --- a/docs/kcl-std/functions/std-solid-subtract.md +++ b/docs/kcl-std/functions/std-solid-subtract.md @@ -8,18 +8,26 @@ layout: manual Subtract removes tool solids from base solids, leaving the remaining material. ```kcl -subtract( - @solids: [Solid; 1+], - tools: [Solid], - tolerance?: number(Length), -): [Solid; 1+] -``` +// Subtract a cylinder from a cube using the stdlib functions. -Performs a bool subtraction operation, removing the volume of one or more -tool solids from one or more base solids. The result is a new solid -representing the material that remains after all tool solids have been cut -away. This function is essential for machining simulations, cavity creation, -and complex multi-body part modeling. + +fn cube(center, size) { + return startSketchOn(XY) + |> startProfile(at = [center[0] - size, center[1] - size]) + |> line(endAbsolute = [center[0] + size, center[1] - size]) + |> line(endAbsolute = [center[0] + size, center[1] + size]) + |> line(endAbsolute = [center[0] - size, center[1] + size]) + |> close() + |> extrude(length = 10) +} + +part001 = cube(center = [0, 0], size = 10) +part002 = cube(center = [7, 3], size = 5) + |> translate(z = 1) + +subtractedPart = subtract([part001], tools = [part002]) + +``` ### Arguments @@ -33,6 +41,23 @@ and complex multi-body part modeling. [`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) +### Description + +Performs a bool subtraction operation, removing the volume of one or more +tool solids from one or more base solids. The result is a new solid +representing the material that remains after all tool solids have been cut +away. This function is essential for machining simulations, cavity creation, +and complex multi-body part modeling. + +### Function signature + +```kcl +subtract( + @solids: [Solid; 1+], + tools: [Solid], + tolerance?: number(Length), +): [Solid; 1+] +``` ### Examples diff --git a/docs/kcl-std/functions/std-solid-union.md b/docs/kcl-std/functions/std-solid-union.md index 8efb460db..7a2c14b33 100644 --- a/docs/kcl-std/functions/std-solid-union.md +++ b/docs/kcl-std/functions/std-solid-union.md @@ -8,14 +8,27 @@ layout: manual Union two or more solids into a single solid. ```kcl -union( - @solids: [Solid; 2+], - tolerance?: number(Length), -): [Solid; 1+] +// Union two cubes using the stdlib functions. + + +fn cube(center, size) { + return startSketchOn(XY) + |> startProfile(at = [center[0] - size, center[1] - size]) + |> line(endAbsolute = [center[0] + size, center[1] - size]) + |> line(endAbsolute = [center[0] + size, center[1] + size]) + |> line(endAbsolute = [center[0] - size, center[1] + size]) + |> close() + |> extrude(length = 10) +} + +part001 = cube(center = [0, 0], size = 10) +part002 = cube(center = [7, 3], size = 5) + |> translate(z = 1) + +unionedPart = union([part001, part002]) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -28,6 +41,15 @@ union( [`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) +### Function signature + +```kcl +union( + @solids: [Solid; 2+], + tolerance?: number(Length), +): [Solid; 1+] +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-transform-mirror2d.md b/docs/kcl-std/functions/std-transform-mirror2d.md index 0f303c565..f88812071 100644 --- a/docs/kcl-std/functions/std-transform-mirror2d.md +++ b/docs/kcl-std/functions/std-transform-mirror2d.md @@ -8,13 +8,22 @@ layout: manual Mirror a sketch. ```kcl -mirror2d( - @sketches: [Sketch; 1+], - axis: Axis2d | Edge, -): Sketch -``` +// Mirror an un-closed sketch across the Y axis. +sketch001 = startSketchOn(XZ) + |> startProfile(at = [0, 10]) + |> line(end = [15, 0]) + |> line(end = [-7, -3]) + |> line(end = [9, -1]) + |> line(end = [-8, -5]) + |> line(end = [9, -3]) + |> line(end = [-8, -3]) + |> line(end = [9, -1]) + |> line(end = [-19, -0]) + |> mirror2d(axis = Y) -Mirror occurs around a local sketch axis rather than a global axis. +example = extrude(sketch001, length = 10) + +``` ### Arguments @@ -27,6 +36,18 @@ Mirror occurs around a local sketch axis rather than a global axis. [`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths. +### Description + +Mirror occurs around a local sketch axis rather than a global axis. + +### Function signature + +```kcl +mirror2d( + @sketches: [Sketch; 1+], + axis: Axis2d | Edge, +): Sketch +``` ### Examples diff --git a/docs/kcl-std/functions/std-transform-rotate.md b/docs/kcl-std/functions/std-transform-rotate.md index ddb68d8cc..168d8f4d1 100644 --- a/docs/kcl-std/functions/std-transform-rotate.md +++ b/docs/kcl-std/functions/std-transform-rotate.md @@ -8,17 +8,47 @@ layout: manual Rotate a solid or a sketch. ```kcl -rotate( - @objects: [Solid; 1+] | [Sketch; 1+] | ImportedGeometry, - roll?: number(Angle), - pitch?: number(Angle), - yaw?: number(Angle), - axis?: Axis3d | Point3d, - angle?: number(Angle), - global?: bool, -): [Solid; 1+] | [Sketch; 1+] | ImportedGeometry +// Rotate a pipe with roll, pitch, and yaw. + +// Create a path for the sweep. +sweepPath = startSketchOn(XZ) + |> startProfile(at = [0.05, 0.05]) + |> line(end = [0, 7]) + |> tangentialArc(angle = 90deg, radius = 5) + |> line(end = [-3, 0]) + |> tangentialArc(angle = -90deg, radius = 5) + |> line(end = [0, 7]) + +// Create a hole for the pipe. +pipeHole = startSketchOn(XY) + |> circle(center = [0, 0], radius = 1.5) + +sweepSketch = startSketchOn(XY) + |> circle(center = [0, 0], radius = 2) + |> subtract2d(tool = pipeHole) + |> sweep(path = sweepPath) + |> rotate(roll = 10, pitch = 10, yaw = 90) + ``` +### Arguments + +| Name | Type | Description | Required | +|----------|------|-------------|----------| +| `objects` | [`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) or [`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch) or [`ImportedGeometry`](/docs/kcl-std/types/std-types-ImportedGeometry) | The solid, sketch, or set of solids or sketches to rotate. | Yes | +| `roll` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | The roll angle. Must be between -360deg and 360deg. | No | +| `pitch` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | The pitch angle. Must be between -360deg and 360deg. | No | +| `yaw` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | The yaw angle. Must be between -360deg and 360deg. | No | +| `axis` | [`Axis3d`](/docs/kcl-std/types/std-types-Axis3d) or [`Point3d`](/docs/kcl-std/types/std-types-Point3d) | The axis to rotate around. Must be used with `angle`. | No | +| `angle` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | The angle to rotate. Must be used with `axis`. Must be between -360deg and 360deg. | No | +| `global` | [`bool`](/docs/kcl-std/types/std-types-bool) | If true, the transform is applied in global space. The origin of the model will move. By default, the transform is applied in local sketch axis, therefore the origin will not move. | No | + +### Returns + +[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) or [`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch) or [`ImportedGeometry`](/docs/kcl-std/types/std-types-ImportedGeometry) + +### Description + This is really useful for assembling parts together. You can create a part and then rotate it to the correct orientation. @@ -46,22 +76,19 @@ So, in the context of a 3D model: When rotating a part around an axis, you specify the axis of rotation and the angle of rotation. -### Arguments - -| Name | Type | Description | Required | -|----------|------|-------------|----------| -| `objects` | [`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) or [`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch) or [`ImportedGeometry`](/docs/kcl-std/types/std-types-ImportedGeometry) | The solid, sketch, or set of solids or sketches to rotate. | Yes | -| `roll` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | The roll angle. Must be between -360deg and 360deg. | No | -| `pitch` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | The pitch angle. Must be between -360deg and 360deg. | No | -| `yaw` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | The yaw angle. Must be between -360deg and 360deg. | No | -| `axis` | [`Axis3d`](/docs/kcl-std/types/std-types-Axis3d) or [`Point3d`](/docs/kcl-std/types/std-types-Point3d) | The axis to rotate around. Must be used with `angle`. | No | -| `angle` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | The angle to rotate. Must be used with `axis`. Must be between -360deg and 360deg. | No | -| `global` | [`bool`](/docs/kcl-std/types/std-types-bool) | If true, the transform is applied in global space. The origin of the model will move. By default, the transform is applied in local sketch axis, therefore the origin will not move. | No | - -### Returns - -[`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) or [`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch) or [`ImportedGeometry`](/docs/kcl-std/types/std-types-ImportedGeometry) +### Function signature +```kcl +rotate( + @objects: [Solid; 1+] | [Sketch; 1+] | ImportedGeometry, + roll?: number(Angle), + pitch?: number(Angle), + yaw?: number(Angle), + axis?: Axis3d | Point3d, + angle?: number(Angle), + global?: bool, +): [Solid; 1+] | [Sketch; 1+] | ImportedGeometry +``` ### Examples diff --git a/docs/kcl-std/functions/std-transform-scale.md b/docs/kcl-std/functions/std-transform-scale.md index 4a954a41e..154644c44 100644 --- a/docs/kcl-std/functions/std-transform-scale.md +++ b/docs/kcl-std/functions/std-transform-scale.md @@ -8,28 +8,29 @@ layout: manual Scale a solid or a sketch. ```kcl -scale( - @objects: [Solid; 1+] | [Sketch; 1+] | ImportedGeometry, - x?: number(_), - y?: number(_), - z?: number(_), - global?: bool, -): [Solid; 1+] | [Sketch; 1+] | ImportedGeometry +// Scale a pipe. + +// Create a path for the sweep. +sweepPath = startSketchOn(XZ) + |> startProfile(at = [0.05, 0.05]) + |> line(end = [0, 7]) + |> tangentialArc(angle = 90deg, radius = 5) + |> line(end = [-3, 0]) + |> tangentialArc(angle = -90deg, radius = 5) + |> line(end = [0, 7]) + +// Create a hole for the pipe. +pipeHole = startSketchOn(XY) + |> circle(center = [0, 0], radius = 1.5) + +sweepSketch = startSketchOn(XY) + |> circle(center = [0, 0], radius = 2) + |> subtract2d(tool = pipeHole) + |> sweep(path = sweepPath) + |> scale(z = 2.5) + ``` -This is really useful for resizing parts. You can create a part and then scale it to the -correct size. - -For sketches, you can use this to scale a sketch and then loft it with another sketch. - -By default the transform is applied in local sketch axis, therefore the origin will not move. - -If you want to apply the transform in global space, set `global` to `true`. The origin of the -model will move. If the model is not centered on origin and you scale globally it will -look like the model moves and gets bigger at the same time. Say you have a square -`(1,1) - (1,2) - (2,2) - (2,1)` and you scale by 2 globally it will become -`(2,2) - (2,4)`...etc so the origin has moved from `(1.5, 1.5)` to `(2,2)`. - ### Arguments | Name | Type | Description | Required | @@ -44,6 +45,32 @@ look like the model moves and gets bigger at the same time. Say you have a squar [`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) or [`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch) or [`ImportedGeometry`](/docs/kcl-std/types/std-types-ImportedGeometry) +### Description + +This is really useful for resizing parts. You can create a part and then scale it to the +correct size. + +For sketches, you can use this to scale a sketch and then loft it with another sketch. + +By default the transform is applied in local sketch axis, therefore the origin will not move. + +If you want to apply the transform in global space, set `global` to `true`. The origin of the +model will move. If the model is not centered on origin and you scale globally it will +look like the model moves and gets bigger at the same time. Say you have a square +`(1,1) - (1,2) - (2,2) - (2,1)` and you scale by 2 globally it will become +`(2,2) - (2,4)`...etc so the origin has moved from `(1.5, 1.5)` to `(2,2)`. + +### Function signature + +```kcl +scale( + @objects: [Solid; 1+] | [Sketch; 1+] | ImportedGeometry, + x?: number(_), + y?: number(_), + z?: number(_), + global?: bool, +): [Solid; 1+] | [Sketch; 1+] | ImportedGeometry +``` ### Examples diff --git a/docs/kcl-std/functions/std-transform-translate.md b/docs/kcl-std/functions/std-transform-translate.md index cedc1fd6e..1fd7c55a1 100644 --- a/docs/kcl-std/functions/std-transform-translate.md +++ b/docs/kcl-std/functions/std-transform-translate.md @@ -8,21 +8,29 @@ layout: manual Move a solid or a sketch. ```kcl -translate( - @objects: [Solid; 1+] | [Sketch; 1+] | ImportedGeometry, - x?: number(Length), - y?: number(Length), - z?: number(Length), - global?: bool, -): [Solid; 1+] | [Sketch; 1+] | ImportedGeometry +// Move a pipe. + +// Create a path for the sweep. +sweepPath = startSketchOn(XZ) + |> startProfile(at = [0.05, 0.05]) + |> line(end = [0, 7]) + |> tangentialArc(angle = 90deg, radius = 5) + |> line(end = [-3, 0]) + |> tangentialArc(angle = -90deg, radius = 5) + |> line(end = [0, 7]) + +// Create a hole for the pipe. +pipeHole = startSketchOn(XY) + |> circle(center = [0, 0], radius = 1.5) + +sweepSketch = startSketchOn(XY) + |> circle(center = [0, 0], radius = 2) + |> subtract2d(tool = pipeHole) + |> sweep(path = sweepPath) + |> translate(x = 1.0, y = 1.0, z = 2.5) + ``` -This is really useful for assembling parts together. You can create a part -and then move it to the correct location. - -Translate is really useful for sketches if you want to move a sketch -and then rotate it using the `rotate` function to create a loft. - ### Arguments | Name | Type | Description | Required | @@ -37,6 +45,25 @@ and then rotate it using the `rotate` function to create a loft. [`[Solid; 1+]`](/docs/kcl-std/types/std-types-Solid) or [`[Sketch; 1+]`](/docs/kcl-std/types/std-types-Sketch) or [`ImportedGeometry`](/docs/kcl-std/types/std-types-ImportedGeometry) +### Description + +This is really useful for assembling parts together. You can create a part +and then move it to the correct location. + +Translate is really useful for sketches if you want to move a sketch +and then rotate it using the `rotate` function to create a loft. + +### Function signature + +```kcl +translate( + @objects: [Solid; 1+] | [Sketch; 1+] | ImportedGeometry, + x?: number(Length), + y?: number(Length), + z?: number(Length), + global?: bool, +): [Solid; 1+] | [Sketch; 1+] | ImportedGeometry +``` ### Examples diff --git a/docs/kcl-std/functions/std-units-toCentimeters.md b/docs/kcl-std/functions/std-units-toCentimeters.md index 0f1d32e0a..f47dc6a9a 100644 --- a/docs/kcl-std/functions/std-units-toCentimeters.md +++ b/docs/kcl-std/functions/std-units-toCentimeters.md @@ -7,11 +7,6 @@ layout: manual Convert a number to centimeters from its current units. -```kcl -units::toCentimeters(@num: number(Length)): number(cm) -``` - - ### Arguments @@ -24,4 +19,10 @@ units::toCentimeters(@num: number(Length)): number(cm) [`number(cm)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +units::toCentimeters(@num: number(Length)): number(cm) +``` + diff --git a/docs/kcl-std/functions/std-units-toDegrees.md b/docs/kcl-std/functions/std-units-toDegrees.md index b5fd04e4a..bc94c62f6 100644 --- a/docs/kcl-std/functions/std-units-toDegrees.md +++ b/docs/kcl-std/functions/std-units-toDegrees.md @@ -8,11 +8,16 @@ layout: manual Converts a number to degrees from its current units. ```kcl -units::toDegrees(@num: number(Angle)): number(deg) +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> angledLine(angle = 50deg, length = 70 * cos(units::toDegrees((PI / 4): number(rad)))) + |> yLine(endAbsolute = 0) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +29,12 @@ units::toDegrees(@num: number(Angle)): number(deg) [`number(deg)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +units::toDegrees(@num: number(Angle)): number(deg) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-units-toFeet.md b/docs/kcl-std/functions/std-units-toFeet.md index 7129e5130..b6dd63641 100644 --- a/docs/kcl-std/functions/std-units-toFeet.md +++ b/docs/kcl-std/functions/std-units-toFeet.md @@ -7,11 +7,6 @@ layout: manual Convert a number to feet from its current units. -```kcl -units::toFeet(@num: number(Length)): number(ft) -``` - - ### Arguments @@ -24,4 +19,10 @@ units::toFeet(@num: number(Length)): number(ft) [`number(ft)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +units::toFeet(@num: number(Length)): number(ft) +``` + diff --git a/docs/kcl-std/functions/std-units-toInches.md b/docs/kcl-std/functions/std-units-toInches.md index a88572a02..d82815896 100644 --- a/docs/kcl-std/functions/std-units-toInches.md +++ b/docs/kcl-std/functions/std-units-toInches.md @@ -7,11 +7,6 @@ layout: manual Convert a number to inches from its current units. -```kcl -units::toInches(@num: number(Length)): number(in) -``` - - ### Arguments @@ -24,4 +19,10 @@ units::toInches(@num: number(Length)): number(in) [`number(in)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +units::toInches(@num: number(Length)): number(in) +``` + diff --git a/docs/kcl-std/functions/std-units-toMeters.md b/docs/kcl-std/functions/std-units-toMeters.md index 4cad9df8a..b2e348702 100644 --- a/docs/kcl-std/functions/std-units-toMeters.md +++ b/docs/kcl-std/functions/std-units-toMeters.md @@ -7,11 +7,6 @@ layout: manual Convert a number to meters from its current units. -```kcl -units::toMeters(@num: number(Length)): number(m) -``` - - ### Arguments @@ -24,4 +19,10 @@ units::toMeters(@num: number(Length)): number(m) [`number(m)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +units::toMeters(@num: number(Length)): number(m) +``` + diff --git a/docs/kcl-std/functions/std-units-toMillimeters.md b/docs/kcl-std/functions/std-units-toMillimeters.md index 52127fafd..49f3b7f67 100644 --- a/docs/kcl-std/functions/std-units-toMillimeters.md +++ b/docs/kcl-std/functions/std-units-toMillimeters.md @@ -7,11 +7,6 @@ layout: manual Convert a number to millimeters from its current units. -```kcl -units::toMillimeters(@num: number(Length)): number(mm) -``` - - ### Arguments @@ -24,4 +19,10 @@ units::toMillimeters(@num: number(Length)): number(mm) [`number(mm)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +units::toMillimeters(@num: number(Length)): number(mm) +``` + diff --git a/docs/kcl-std/functions/std-units-toRadians.md b/docs/kcl-std/functions/std-units-toRadians.md index ef5f47764..1280c29b0 100644 --- a/docs/kcl-std/functions/std-units-toRadians.md +++ b/docs/kcl-std/functions/std-units-toRadians.md @@ -8,11 +8,16 @@ layout: manual Converts a number to radians from its current units. ```kcl -units::toRadians(@num: number(Angle)): number(rad) +exampleSketch = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> angledLine(angle = 50deg, length = 70 * cos(units::toRadians(45deg))) + |> yLine(endAbsolute = 0) + |> close() + +example = extrude(exampleSketch, length = 5) + ``` - - ### Arguments | Name | Type | Description | Required | @@ -24,6 +29,12 @@ units::toRadians(@num: number(Angle)): number(rad) [`number(rad)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +units::toRadians(@num: number(Angle)): number(rad) +``` + ### Examples ```kcl diff --git a/docs/kcl-std/functions/std-units-toYards.md b/docs/kcl-std/functions/std-units-toYards.md index 9105fcbe9..29269540f 100644 --- a/docs/kcl-std/functions/std-units-toYards.md +++ b/docs/kcl-std/functions/std-units-toYards.md @@ -7,11 +7,6 @@ layout: manual Converts a number to yards from its current units. -```kcl -units::toYards(@num: number(Length)): number(yd) -``` - - ### Arguments @@ -24,4 +19,10 @@ units::toYards(@num: number(Length)): number(yd) [`number(yd)`](/docs/kcl-std/types/std-types-number) - A number. +### Function signature + +```kcl +units::toYards(@num: number(Length)): number(yd) +``` + diff --git a/rust/kcl-lib/src/docs/templates/function.hbs b/rust/kcl-lib/src/docs/templates/function.hbs index cce97e99b..e56debdff 100644 --- a/rust/kcl-lib/src/docs/templates/function.hbs +++ b/rust/kcl-lib/src/docs/templates/function.hbs @@ -11,11 +11,13 @@ layout: manual {{/if}} {{{summary}}} +{{#if examples}} +{{#if examples.0.content}} ```kcl -{{{fn_signature}}} +{{{examples.0.content}}} ``` - -{{{description}}} +{{/if}} +{{/if}} {{#if args}} ### Arguments @@ -33,6 +35,17 @@ layout: manual `{{return_value.type_}}`{{#if return_value.description}} - {{{firstLine return_value.description}}}{{/if}} {{/if}} +{{#if description}} +### Description + +{{{description}}} +{{/if}} + +### Function signature + +```kcl +{{{fn_signature}}} +``` {{#if examples}} ### Examples