KCL: Convert x/y lines to use keyword arguments (#5615)

Previously, `xLine`, `xLineTo`, `yLine` and `yLineTo` used positional arguments. Now:

- `xLineTo` and `yLineTo` have been removed
- `xLine` and `yLine` both use keyword arguments:
  - `length`, optional (i.e. a relative distance along the X or Y axis)
  - `endAbsolute` optional (i.e. an absolute point along the X or Y axis)
  - `tag` optional
- Exactly one of `length` or `endAbsolute` must be given. Not both, not neither.

For example:

```
// Old way
|> xLine(6.04, %)
|> yLineTo(20, %, $base)

// New way
|> xLine(length = 6.04)
|> yLine(endAbsolute = 20, tag = $base)
```

This also improves some of the general-purpose keyword arguments code in modeling app's TS codebase.
This commit is contained in:
Adam Chalmers
2025-03-07 22:07:16 -06:00
committed by GitHub
parent bc3a0e3896
commit aea82e004a
289 changed files with 65906 additions and 67955 deletions

View File

@ -6,9 +6,9 @@ const box_height = 50
const box_sketch = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> xLine(box_width, %, $line1)
|> yLine(box_depth, %, $line2)
|> xLineTo(profileStartX(%), %, $line3)
|> xLine(length = box_width, tag = $line1)
|> yLine(length = box_depth, tag = $line2)
|> xLine(endAbsolute = profileStartX(%), tag = $line3)
|> close(%, $line4)
const box3D = extrude(box_sketch, length = box_height)

View File

@ -40,9 +40,9 @@ sketch002 = startSketchOn(loftPlane)
origin[0] + (antennaBaseWidth - antennaTopWidth) / 2,
origin[1] - ((antennaBaseHeight - antennaTopHeight) / 2)
], %)
|> xLine(antennaTopWidth, %)
|> yLine(-antennaTopHeight, %)
|> xLine(-antennaTopWidth, %)
|> xLine(length = antennaTopWidth)
|> yLine(length = -antennaTopHeight)
|> xLine(length = -antennaTopWidth)
|> close()
// Create the antenna using a loft

View File

@ -10,9 +10,9 @@ import height, width, thickness, chamferLength, offset, screenWidth, screenHeigh
bodySketch = startSketchOn('XZ')
|> startProfileAt([-width / 2, height / 2], %)
|> xLine(width, %, $chamfer1)
|> yLine(-height, %, $chamfer2)
|> xLine(-width, %, $chamfer3)
|> xLine(length = width, tag = $chamfer1)
|> yLine(length = -height, tag = $chamfer2)
|> xLine(length = -width, tag = $chamfer3)
|> close(tag = $chamfer4)
bodyExtrude = extrude(bodySketch, length = thickness)
|> chamfer(
@ -59,9 +59,9 @@ extrude002 = extrude(sketch002, length = -0.0625)
// Create the pocket for the screen
sketch003 = startSketchOn(extrude002, 'start')
|> startProfileAt([-screenWidth / 2, screenYPosition], %)
|> xLine(screenWidth, %, $seg01)
|> yLine(-screenHeight, %)
|> xLine(-segLen(seg01), %)
|> xLine(length = screenWidth, tag = $seg01)
|> yLine(length = -screenHeight)
|> xLine(length = -segLen(seg01))
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
extrude003 = extrude(sketch003, length = screenDepth)
@ -69,9 +69,9 @@ extrude003 = extrude(sketch003, length = screenDepth)
// Create the speaker box
sketch004 = startSketchOn(extrude002, 'start')
|> startProfileAt([-1.25 / 2, -.125], %)
|> xLine(speakerBoxWidth, %)
|> yLine(-speakerBoxHeight, %)
|> xLine(-speakerBoxWidth, %)
|> xLine(length = speakerBoxWidth)
|> yLine(length = -speakerBoxHeight)
|> xLine(length = -speakerBoxWidth)
|> close()
extrude(sketch004, length = -.5)
|> appearance(

View File

@ -14,9 +14,9 @@ plane = offsetPlane("XZ", offset = 1)
fn screenHole(sketchStart) {
sketch006 = startSketchOn(sketchStart)
|> startProfileAt([-screenWidth / 2, screenYPosition], %)
|> xLine(screenWidth, %)
|> yLine(-screenHeight, %)
|> xLine(-screenWidth, %)
|> xLine(length = screenWidth)
|> yLine(length = -screenHeight)
|> xLine(length = -screenWidth)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
return sketch006

View File

@ -25,14 +25,14 @@ knobPlane = {
// Create the knob sketch and revolve
startSketchOn(knobPlane)
|> startProfileAt([0.0001, 0], %)
|> xLine(knobDiameter / 2, %)
|> yLine(knobHeight - 0.05, %)
|> xLine(length = knobDiameter / 2)
|> yLine(length = knobHeight - 0.05)
|> arc({
angleStart = 0,
angleEnd = 90,
radius = .05
}, %)
|> xLineTo(0.0001, %)
|> xLine(endAbsolute = 0.0001)
|> close()
|> revolve({ axis = "Y" }, %)
|> appearance(color = '#D0FF01', metalness = 90, roughness = 50)

View File

@ -27,9 +27,9 @@ talkButtonSketch = startSketchOn(talkButtonPlane)
-talkButtonSideLength / 2,
talkButtonSideLength / 2
], %)
|> xLine(talkButtonSideLength, %, $tag1)
|> yLine(-talkButtonSideLength, %, $tag2)
|> xLine(-talkButtonSideLength, %, $tag3)
|> xLine(length = talkButtonSideLength, tag = $tag1)
|> yLine(length = -talkButtonSideLength, tag = $tag2)
|> xLine(length = -talkButtonSideLength, tag = $tag3)
|> close(tag = $tag4)
// Create the talk button and apply fillets

View File

@ -7,29 +7,29 @@ export fn zLogo(surface, origin, scale) {
0 + origin[0],
0.15 * scale + origin[1]
], %)
|> yLine(-0.15 * scale, %)
|> xLine(0.15 * scale, %)
|> yLine(length = -0.15 * scale)
|> xLine(length = 0.15 * scale)
|> angledLineToX({
angle = 47.15,
to = 0.3 * scale + origin[0]
}, %, $seg1)
|> yLineTo(0 + origin[1], %, $seg3)
|> xLine(0.63 * scale, %)
|> yLine(0.225 * scale, %)
|> xLine(-0.57 * scale, %)
|> yLine(endAbsolute = 0 + origin[1], tag = $seg3)
|> xLine(length = 0.63 * scale)
|> yLine(length = 0.225 * scale)
|> xLine(length = -0.57 * scale)
|> angledLineToX({
angle = 47.15,
to = 0.93 * scale + origin[0]
}, %)
|> yLine(0.15 * scale, %)
|> xLine(-0.15 * scale, %)
|> yLine(length = 0.15 * scale)
|> xLine(length = -0.15 * scale)
|> angledLine({
angle = 47.15,
length = -segLen(seg1)
}, %, $seg2)
|> yLine(segLen(seg3), %)
|> xLineTo(0 + origin[0], %)
|> yLine(-0.225 * scale, %)
|> yLine(length = segLen(seg3))
|> xLine(endAbsolute = 0 + origin[0])
|> yLine(length = -0.225 * scale)
|> angledLineThatIntersects({
angle = 0,
intersectTag = seg2,