Skip to content

Commit 5c9cc21

Browse files
committed
Update KCL examples
1 parent d68e32a commit 5c9cc21

File tree

14 files changed

+51
-70
lines changed

14 files changed

+51
-70
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/gear.kcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ teeth = reduce([0..100], start, leftInvolute)
7474
|> reduce([1..101], %, rightInvolute)
7575
|> close()
7676
|> extrude(length = gearHeight)
77-
|> patternCircular3d({
77+
|> patternCircular3d(
7878
axis = [0, 0, 1],
7979
center = [0, 0, 0],
8080
instances = nTeeth,
8181
arcDegrees = 360,
8282
rotateDuplicates = true
83-
}, %)
83+
)
8484

8585
// Define the constants of the keyway and the bore hole
8686
keywayWidth = 0.250

tests/gear.png

-35 Bytes
Loading

tests/nested-settings/subdir/gear.kcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ teeth = reduce([0..100], start, leftInvolute)
7474
|> reduce([1..101], %, rightInvolute)
7575
|> close()
7676
|> extrude(length = gearHeight)
77-
|> patternCircular3d({
77+
|> patternCircular3d(
7878
axis = [0, 0, 1],
7979
center = [0, 0, 0],
8080
instances = nTeeth,
8181
arcDegrees = 360,
8282
rotateDuplicates = true
83-
}, %)
83+
)
8484

8585
// Define the constants of the keyway and the bore hole
8686
keywayWidth = 0.250
159 Bytes
Loading

tests/walkie-talkie/antenna.kcl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// Antenna
22

3+
34
// Set units
45
@settings(defaultLengthUnit = in)
56

6-
// import constants
7-
import height, width, antennaBaseWidth, antennaBaseHeight, antennaTopWidth, antennaTopHeight from 'globals.kcl'
87

8+
// import constants
9+
import height, width, antennaBaseWidth, antennaBaseHeight, antennaTopWidth, antennaTopHeight from "globals.kcl"
910

1011
// Calculate the origin
1112
origin = [-width / 2 + .45, -0.10]
@@ -16,11 +17,7 @@ antennaY = origin[1]
1617

1718
antennaPlane = {
1819
plane = {
19-
origin = {
20-
x = 0,
21-
y = 0,
22-
z = height/2
23-
},
20+
origin = { x = 0, y = 0, z = height / 2 },
2421
xAxis = { x = 1, y = 0, z = 0 },
2522
yAxis = { x = 0, y = 1, z = 0 },
2623
zAxis = { x = 0, y = 0, z = 1 }
@@ -35,15 +32,19 @@ sketch001 = startSketchOn(antennaPlane)
3532
|> line(end = [-antennaBaseWidth, 0])
3633
|> close()
3734

38-
// Create the antenna top sketch
39-
loftPlane = offsetPlane('XY', height/2 + 3)
35+
// Create the antenna top sketch
36+
loftPlane = offsetPlane('XY', offset = height / 2 + 3)
4037

4138
sketch002 = startSketchOn(loftPlane)
42-
|> startProfileAt([origin[0] + (antennaBaseWidth - antennaTopWidth)/2, origin[1] - (antennaBaseHeight - antennaTopHeight)/2], %)
39+
|> startProfileAt([
40+
origin[0] + (antennaBaseWidth - antennaTopWidth) / 2,
41+
origin[1] - ((antennaBaseHeight - antennaTopHeight) / 2)
42+
], %)
4343
|> xLine(antennaTopWidth, %)
4444
|> yLine(-antennaTopHeight, %)
4545
|> xLine(-antennaTopWidth, %)
4646
|> close()
4747

4848
// Create the antenna using a loft
49-
export antenna = loft([sketch001, sketch002])
49+
export antenna = loft([sketch001, sketch002])
50+
|> appearance(color = "#000000")

tests/walkie-talkie/body.kcl

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// Walkie talkie body
22

3+
34
// Set units
45
@settings(defaultLengthUnit = in)
56

7+
68
// Import constants
79
import height, width, thickness, chamferLength, offset, screenWidth, screenHeight, screenYPosition, screenDepth, speakerBoxWidth, speakerBoxHeight from "globals.kcl"
810

@@ -22,11 +24,6 @@ bodyExtrude = extrude(bodySketch, length = thickness)
2224
getNextAdjacentEdge(chamfer4)
2325
]
2426
}, %)
25-
// |> appearance({
26-
// color = '#707980',
27-
// metalness = 90,
28-
// roughness = 90
29-
// }, %)
3027

3128
// Define the offset for the indentation
3229
sketch002 = startSketchOn(bodyExtrude, 'END')
@@ -58,12 +55,6 @@ sketch002 = startSketchOn(bodyExtrude, 'END')
5855
}, %)
5956
|> close()
6057
extrude002 = extrude(sketch002, length = -0.0625)
61-
// |> appearance({
62-
// color = '#707980',
63-
// metalness = 90,
64-
// roughness = 90
65-
// }, %)
66-
6758

6859
// Create the pocket for the screen
6960
sketch003 = startSketchOn(extrude002, 'start')
@@ -74,12 +65,6 @@ sketch003 = startSketchOn(extrude002, 'start')
7465
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
7566
|> close()
7667
extrude003 = extrude(sketch003, length = screenDepth)
77-
// |> appearance({
78-
// color = '#707980',
79-
// metalness = 90,
80-
// roughness = 90
81-
// }, %)
82-
8368

8469
// Create the speaker box
8570
sketch004 = startSketchOn(extrude002, 'start')
@@ -88,5 +73,8 @@ sketch004 = startSketchOn(extrude002, 'start')
8873
|> yLine(-speakerBoxHeight, %)
8974
|> xLine(-speakerBoxWidth, %)
9075
|> close()
91-
92-
export body = extrude(sketch004, length = -.5)
76+
export body = extrude(sketch004, length = -.5)
77+
|> appearance(
78+
color = "#277bb0",
79+
)
80+

tests/walkie-talkie/button.kcl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export fn button(origin, rotation, plane) {
3232
getNextAdjacentEdge(tag2)
3333
]
3434
}, %)
35+
|> appearance(color = "#ff0000")
3536

3637
return buttonExtrude
37-
}
38+
}

tests/walkie-talkie/case.kcl

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// Walkie talkie case
22

3+
34
// Set units
45
@settings(defaultLengthUnit = in)
56

7+
68
// Import constants and Zoo logo
79
import width, height, chamferLength, offset, screenWidth, screenHeight, screenYPosition, screenDepth, speakerBoxWidth, speakerBoxHeight, squareHoleSideLength, caseTolerance from "globals.kcl"
810
import zLogo, oLogo, oLogo2 from "zoo-logo.kcl"
911

10-
plane = offsetPlane("XZ", 1)
12+
plane = offsetPlane("XZ", offset = 1)
1113

1214
fn screenHole(sketchStart) {
1315
sketch006 = startSketchOn(sketchStart)
@@ -33,11 +35,11 @@ fn squareHolePattern(plane, x, y) {
3335
|> line(end = [0, -squareHoleSideLength / 2])
3436
|> line(end = [-squareHoleSideLength / 2, 0])
3537
|> close()
36-
|> patternTransform2d(13, transformX, %)
37-
|> patternTransform2d(11, transformY, %)
38+
|> patternTransform2d(instances = 13, transform = transformX)
39+
|> patternTransform2d(instances = 11, transform = transformY)
3840
return squareHolePatternSketch
3941
}
40-
sketch005 = startSketchOn(offsetPlane("XZ", 1))
42+
sketch005 = startSketchOn(offsetPlane("XZ", offset = 1))
4143
|> startProfileAt([
4244
-width / 2 + offset + caseTolerance,
4345
height / 2 - (chamferLength + (offset + caseTolerance) / 2 * cos(toRadians(45)))
@@ -80,8 +82,4 @@ sketch005 = startSketchOn(offsetPlane("XZ", 1))
8082
|> hole(oLogo2(plane, [.175, -1.825], .20), %)
8183

8284
export case = extrude(sketch005, length = -0.0625)
83-
|> appearance(
84-
color = '#D0FF01',
85-
metalness = 0,
86-
roughness = 50
87-
)
85+
|> appearance(color = '#D0FF01', metalness = 0, roughness = 50)

tests/walkie-talkie/knob.kcl

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
// Walkie talkie knob
22

3+
34
// Set units
45
@settings(defaultLengthUnit = in)
56

7+
68
// Import constants
7-
import width, thickness, height, knobDiameter, knobHeight, knobRadius from "globals.kcl"
9+
import width, thickness, height, knobDiameter, knobHeight, knobRadius from "globals.kcl"
810

911
// Define the plane for the knob
1012
knobPlane = {
1113
plane = {
1214
origin = {
13-
x = width / 2 - 0.70,
15+
x = width / 2 - 0.70,
1416
y = -thickness / 2,
1517
z = height / 2
1618
},
@@ -23,7 +25,7 @@ knobPlane = {
2325
// Create the knob sketch and revolve
2426
export knob = startSketchOn(knobPlane)
2527
|> startProfileAt([0.0001, 0], %)
26-
|> xLine(knobDiameter/2, %)
28+
|> xLine(knobDiameter / 2, %)
2729
|> yLine(knobHeight - 0.05, %)
2830
|> arc({
2931
angleStart = 0,
@@ -32,11 +34,5 @@ export knob = startSketchOn(knobPlane)
3234
}, %)
3335
|> xLineTo(0.0001, %)
3436
|> close()
35-
|> revolve({
36-
axis = "Y",
37-
}, %)
38-
|> appearance(
39-
color = '#D0FF01',
40-
metalness = 90,
41-
roughness = 50
42-
)
37+
|> revolve({ axis = "Y" }, %)
38+
|> appearance(color = '#D0FF01', metalness = 90, roughness = 50)

0 commit comments

Comments
 (0)