KCL: User-defined KCL functions in examples etc now use keywords (#6603)

Preparing for the removal of positional functions from the language. The first big step is to change all our KCL code examples, test code, public samples etc to all use keyword functions.

Apologies for how large this PR is. Most of it is:

- Changing example KCL that defined its own functions, so the functions now use keyword arguments rather than positional arguments. E.g. change `cube([20, 20])` to be `cube(center = [20, 20])`.
- Some parts of the code assumed positional code and didn't handle keyword calls, e.g. the linter would only check for positional calls to startSketchOn. Now they should work with either positional or keyword.
- Update all the artifacts

This does _not_ remove support for positional calls. That will be in a follow-up PR.
This commit is contained in:
Adam Chalmers
2025-05-01 11:36:51 -05:00
committed by GitHub
parent 16f5d9c284
commit 89bae66257
254 changed files with 32085 additions and 20108 deletions

View File

@ -96,7 +96,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
///
/// ```no_run
/// // Each instance will be shifted along the X axis.
/// fn transform(id) {
/// fn transform(@id) {
/// return { translate = [4 * id, 0, 0] }
/// }
///
@ -110,7 +110,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
/// // Each instance will be shifted along the X axis,
/// // with a gap between the original (at x = 0) and the first replica
/// // (at x = 8). This is because `id` starts at 1.
/// fn transform(id) {
/// fn transform(@id) {
/// return { translate = [4 * (1+id), 0, 0] }
/// }
///
@ -140,7 +140,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
/// }
///
/// width = 20
/// fn transform(i) {
/// fn transform(@i) {
/// return {
/// // Move down each time.
/// translate = [0, 0, -i * width],
@ -155,7 +155,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
/// }
///
/// myCubes =
/// cube(width, [100,0])
/// cube(length = width, center = [100,0])
/// |> patternTransform(instances = 25, transform = transform)
/// ```
///
@ -180,7 +180,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
/// }
///
/// width = 20
/// fn transform(i) {
/// fn transform(@i) {
/// return {
/// translate = [0, 0, -i * width],
/// rotation = {
@ -191,7 +191,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
/// }
/// }
/// myCubes =
/// cube(width, [100,100])
/// cube(length = width, center = [100,100])
/// |> patternTransform(instances = 4, transform = transform)
/// ```
/// ```no_run
@ -201,7 +201,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
/// t = 0.005 // taper factor [0-1)
/// // Defines how to modify each layer of the vase.
/// // Each replica is shifted up the Z axis, and has a smoothly-varying radius
/// fn transform(replicaId) {
/// fn transform(@replicaId) {
/// scale = r * abs(1 - (t * replicaId)) * (5 + cos((replicaId / 8): number(rad)))
/// return {
/// translate = [0, 0, replicaId * 10],
@ -219,7 +219,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
/// vase = layer() |> patternTransform(instances = 100, transform = transform)
/// ```
/// ```
/// fn transform(i) {
/// fn transform(@i) {
/// // Transform functions can return multiple transforms. They'll be applied in order.
/// return [
/// { translate = [30 * i, 0, 0] },
@ -282,7 +282,7 @@ async fn inner_pattern_transform<'a>(
/// Just like patternTransform, but works on 2D sketches not 3D solids.
/// ```no_run
/// // Each instance will be shifted along the X axis.
/// fn transform(id) {
/// fn transform(@id) {
/// return { translate = [4 * id, 0] }
/// }
///