v0.41.0
Changed
- Breaking: KCL now uses keyword arguments for
line
,lineTo
,extrude
, andclose
.
See the instructions below to migrate existing models.
Why are we doing this?
Because it'll let us evolve the KCL standard library, adding new options to functions without breaking existing code. We don't want to have a painful annual release process where you upgrade all your KCL code from 1.1 to 1.2 and a bunch of things break. In the future, if we want to add a new option, it'll be added as a new optional keyword argument. For example, we will probably let you pass adiameter
to build a circle, instead of aradius
. You can then use whichever keyword you want (and it'll give you an error if you use both, or neither).This also helps us integrate a constraint solver in the future -- you'll be able to pass fewer keyword arguments, and the constraint solver will fill in the missing values for you 🙂 Eventually.
What is changing?
The first few functions we're changing areline
,lineTo
,extrude
andclose
. Here's a before-and-after example:
line([3, 4], mySketch, $myTag)
becomes
line(mySketch, end = [3, 4], tag = $myTag)
Note that the first argument doesn't need a label. Keyword functions may declare at most one argument that doesn't need a label. If used, this has to be the first argument.
Also, if you use an unlabeled argument in a
|>
you can omit the argument, and it'll be implicitly set to%
. This means%
isn't needed most of the time anymore.Example
box = startSketchOn("XZ") |> startProfileAt([10, 10], %) |> line([10, 0], %) |> line([0, 10], %) |> line([-10, 0], %, $thirdLineOfBox) |> close(%) |> extrude(5, %)
becomes
box = startSketchOn("XZ") |> startProfileAt([10, 10], %) |> line(end = [10, 0]) |> line(end = [0, 10]) |> line(end = [-10, 0], tag = $thirdLineOfBox) |> close() |> extrude(length = 5)
Migration
Here is a list of regexes you can use to find-and-replace your old KCL code with the new keyword argument code. You can run this in ZMA's find-and-replace (ctrl+F or cmd+F in the KCL code panel), or in VSCode's global find-and-replace (so you can fix up all your files at once). Note this won't trigger for any multi-line function calls (where you separate each argument with a newline). For those you'll have to fix it up manually, sorry!\bline\(([^=]*), %\) line(end = $1) \bline\((.*), %, (.*)\) line(end = $1, tag = $2) \blineTo\((.*), %\) line(endAbsolute = $1) \blineTo\((.*), %, (.*)\) line(endAbsolute = $1, tag = $2) \bextrude\((.*), %\) extrude(length = $1) \bextrude\(([^=]*), ([a-zA-Z0-9]+)\) extrude($2, length = $1) close\(%, (.*)\) close(tag = $1) close\(%\) close()
Added
- Point-and-click Sweep and Revolve
- Project thumbnails on the home page
- Trackball camera setting
- File tree now lets you duplicate files
- Dedicated section for construction commands in the toolbar
Fixed
- Highlighted code in the editor is now easier to read in dark mode
- Artifact graph now survives when there's an execution error
Full Changelog: v0.40.0...v0.41.0