Skip to content

Commit fd3fd1f

Browse files
Update KCL docs (#582)
YOYO NEW KCL DOCS!! Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent c7e63b4 commit fd3fd1f

File tree

8 files changed

+291
-0
lines changed

8 files changed

+291
-0
lines changed

content/pages/docs/kcl-samples/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ When you submit a PR to add or modify KCL samples, images will be generated and
109109
[![makeup-mirror](screenshots/makeup-mirror.png)](makeup-mirror/main.kcl)
110110
#### [mounting-plate](mounting-plate/main.kcl) ([screenshot](screenshots/mounting-plate.png))
111111
[![mounting-plate](screenshots/mounting-plate.png)](mounting-plate/main.kcl)
112+
#### [mug](mug/main.kcl) ([screenshot](screenshots/mug.png))
113+
[![mug](screenshots/mug.png)](mug/main.kcl)
112114
#### [multi-axis-robot](multi-axis-robot/main.kcl) ([screenshot](screenshots/multi-axis-robot.png))
113115
[![multi-axis-robot](screenshots/multi-axis-robot.png)](multi-axis-robot/main.kcl)
114116
#### [pdu-faceplate](pdu-faceplate/main.kcl) ([screenshot](screenshots/pdu-faceplate.png))
@@ -139,6 +141,8 @@ When you submit a PR to add or modify KCL samples, images will be generated and
139141
[![socket-head-cap-screw](screenshots/socket-head-cap-screw.png)](socket-head-cap-screw/main.kcl)
140142
#### [spinning-highrise-tower](spinning-highrise-tower/main.kcl) ([screenshot](screenshots/spinning-highrise-tower.png))
141143
[![spinning-highrise-tower](screenshots/spinning-highrise-tower.png)](spinning-highrise-tower/main.kcl)
144+
#### [spool](spool/main.kcl) ([screenshot](screenshots/spool.png))
145+
[![spool](screenshots/spool.png)](spool/main.kcl)
142146
#### [spur-gear](spur-gear/main.kcl) ([screenshot](screenshots/spur-gear.png))
143147
[![spur-gear](screenshots/spur-gear.png)](spur-gear/main.kcl)
144148
#### [spur-reduction-gearset](spur-reduction-gearset/main.kcl) ([screenshot](screenshots/spur-reduction-gearset.png))
@@ -147,6 +151,8 @@ When you submit a PR to add or modify KCL samples, images will be generated and
147151
[![surgical-drill-guide](screenshots/surgical-drill-guide.png)](surgical-drill-guide/main.kcl)
148152
#### [t-slot-rail](t-slot-rail/main.kcl) ([screenshot](screenshots/t-slot-rail.png))
149153
[![t-slot-rail](screenshots/t-slot-rail.png)](t-slot-rail/main.kcl)
154+
#### [teapot](teapot/main.kcl) ([screenshot](screenshots/teapot.png))
155+
[![teapot](screenshots/teapot.png)](teapot/main.kcl)
150156
#### [telemetry-antenna](telemetry-antenna/main.kcl) ([screenshot](screenshots/telemetry-antenna.png))
151157
[![telemetry-antenna](screenshots/telemetry-antenna.png)](telemetry-antenna/main.kcl)
152158
#### [thermal-block-insert](thermal-block-insert/main.kcl) ([screenshot](screenshots/thermal-block-insert.png))

content/pages/docs/kcl-samples/manifest.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,16 @@
447447
"main.kcl"
448448
]
449449
},
450+
{
451+
"file": "main.kcl",
452+
"pathFromProjectDirectoryToFirstFile": "mug/main.kcl",
453+
"multipleFiles": false,
454+
"title": "Mug",
455+
"description": "A cup with straight sides and a handle, typically used for hot drinks",
456+
"files": [
457+
"main.kcl"
458+
]
459+
},
450460
{
451461
"file": "main.kcl",
452462
"pathFromProjectDirectoryToFirstFile": "multi-axis-robot/main.kcl",
@@ -612,6 +622,16 @@
612622
"main.kcl"
613623
]
614624
},
625+
{
626+
"file": "main.kcl",
627+
"pathFromProjectDirectoryToFirstFile": "spool/main.kcl",
628+
"multipleFiles": false,
629+
"title": "Spool",
630+
"description": "A spool is a winding device for storing large batches of filament, wire, tape, etc",
631+
"files": [
632+
"main.kcl"
633+
]
634+
},
615635
{
616636
"file": "main.kcl",
617637
"pathFromProjectDirectoryToFirstFile": "spur-gear/main.kcl",
@@ -652,6 +672,16 @@
652672
"main.kcl"
653673
]
654674
},
675+
{
676+
"file": "main.kcl",
677+
"pathFromProjectDirectoryToFirstFile": "teapot/main.kcl",
678+
"multipleFiles": false,
679+
"title": "Teapot",
680+
"description": "A vessel with a spout and a handle used for serving tea and boiling water on a stovetop",
681+
"files": [
682+
"main.kcl"
683+
]
684+
},
655685
{
656686
"file": "main.kcl",
657687
"pathFromProjectDirectoryToFirstFile": "telemetry-antenna/main.kcl",
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Mug
2+
// A cup with straight sides and a handle, typically used for hot drinks
3+
4+
// Set units
5+
@settings(defaultLengthUnit = mm)
6+
7+
// Define parameters
8+
mugDiameter = 80
9+
mugHeight = 95
10+
wallThickness = 6
11+
handleWidth = 18
12+
handleThickness = 5
13+
14+
// Revolve the outer perimeter of the mug body. This will be used to subtract material from the handle, so that it fits snug to the body
15+
tools = startSketchOn(XZ)
16+
|> startProfile(at = [0, mugDiameter * 0.04])
17+
|> xLine(length = mugDiameter * 0.1)
18+
|> tangentialArc(endAbsolute = [mugDiameter * 0.3, mugDiameter * 0.01])
19+
|> arc(angleStart = -180, angleEnd = -90, radius = mugDiameter * 0.01)
20+
|> xLine(length = mugDiameter * 0.025)
21+
|> arc(angleStart = -90, angleEnd = 0, radius = mugDiameter * 0.01)
22+
|> xLine(endAbsolute = mugDiameter * 0.35)
23+
|> tangentialArc(angle = 90, radius = mugDiameter * 0.15)
24+
|> yLine(endAbsolute = mugHeight - (wallThickness / 2))
25+
|> tangentialArc(angle = 90, diameter = wallThickness)
26+
|> xLine(endAbsolute = profileStartX())
27+
|> yLine(endAbsolute = profileStartY())
28+
|> close()
29+
|> revolve(axis = Y)
30+
31+
// Draw the path of the mug handle
32+
handlePath = startSketchOn(XZ)
33+
|> startProfile(at = [mugDiameter / 3, mugHeight * 0.25])
34+
|> angledLine(angle = -5, length = mugDiameter / 3)
35+
|> tangentialArc(angle = 90, radius = mugHeight * 0.15)
36+
|> tangentialArc(end = [0, mugHeight * 0.425])
37+
|> tangentialArc(angle = 90, radius = mugHeight * 0.15, tag = $seg02)
38+
|> angledLine(angle = tangentToEnd(seg02), endAbsoluteX = profileStartX())
39+
40+
// Sweep the handle profile along the path
41+
handle = startSketchOn(offsetPlane(YZ, offset = mugDiameter / 3))
42+
|> startProfile(at = [
43+
-handleWidth / 2,
44+
mugHeight * 0.25 + handleThickness / 2
45+
])
46+
|> arc(
47+
interiorAbsolute = [
48+
0,
49+
profileStartY() + handleThickness / 4
50+
],
51+
endAbsolute = [handleWidth / 2, profileStartY()],
52+
)
53+
|> tangentialArc(end = [0, -handleThickness])
54+
|> tangentialArc(end = [-handleWidth, 0])
55+
|> tangentialArc(endAbsolute = profileStart())
56+
|> close()
57+
|> sweep(path = handlePath)
58+
|> subtract(tools)
59+
60+
// Create the body of the mug
61+
mug = startSketchOn(XZ)
62+
|> startProfile(at = [0, mugDiameter * 0.04])
63+
|> xLine(length = mugDiameter * 0.1)
64+
|> tangentialArc(endAbsolute = [mugDiameter * 0.3, mugDiameter * 0.01])
65+
|> arc(angleStart = -180, angleEnd = -90, radius = mugDiameter * 0.01)
66+
|> xLine(length = mugDiameter * 0.025)
67+
|> arc(angleStart = -90, angleEnd = 0, radius = mugDiameter * 0.01)
68+
|> xLine(endAbsolute = mugDiameter * 0.35)
69+
|> tangentialArc(angle = 90, radius = mugDiameter * 0.15)
70+
|> yLine(endAbsolute = mugHeight - (wallThickness / 2))
71+
|> tangentialArc(angle = 180, diameter = wallThickness)
72+
|> yLine(endAbsolute = mugDiameter * 0.15)
73+
|> tangentialArc(angle = -90, radius = lastSegX() * 0.2)
74+
|> xLine(endAbsolute = profileStartX())
75+
|> yLine(endAbsolute = profileStartY())
76+
|> close()
77+
|> revolve(axis = Y)
78+
79+
// Join the mug and handle, then add an appearance
80+
[handle, mug]
81+
|> appearance(color = "#9b1212", metalness = 40, roughness = 30)
114 KB
Loading
155 KB
Loading
128 KB
Loading
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Spool
2+
// A spool is a winding device for storing large batches of filament, wire, tape, etc
3+
4+
// Set units
5+
@settings(defaultLengthUnit = mm)
6+
7+
// Define shaft parameters
8+
hubDiameter = 2in
9+
spoolDiameter = 305
10+
spoolThickness = 267
11+
coreDiameter = 150
12+
webThickness = 10
13+
stockDiameter = 5
14+
15+
// Sketch the revolved profile of one side of the spool
16+
spoolBase = startSketchOn(XY)
17+
|> startProfile(at = [0, coreDiameter / 2])
18+
|> xLine(length = spoolThickness / 2)
19+
|> yLine(endAbsolute = spoolDiameter / 2 - webThickness)
20+
|> tangentialArc(angle = -270, radius = webThickness)
21+
|> yLine(endAbsolute = hubDiameter / 2, tag = $seg01)
22+
|> xLine(endAbsolute = profileStartX())
23+
|> yLine(endAbsolute = profileStartY())
24+
|> close()
25+
|> revolve(axis = X)
26+
|> appearance(color = "#010101", metalness = 10, roughness = 70)
27+
28+
// Create a function that draws an indent on the outer faces of the spool
29+
fn score(radius, length, depth) {
30+
scoreFn = startSketchOn(spoolBase, face = seg01)
31+
|> startProfile(at = [0, radius])
32+
|> arc(angleStart = 90, angleEnd = 55, radius = profileStartY(%))
33+
|> angledLine(angle = 55, length = length)
34+
|> arc(
35+
%,
36+
angleStart = 55,
37+
angleEnd = 90,
38+
radius = profileStartY(%) + length,
39+
)
40+
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
41+
|> close()
42+
|> patternCircular2d(instances = 8, center = [0, 0])
43+
|> extrude(length = -depth)
44+
45+
return scoreFn
46+
}
47+
48+
// Circular pattern indents around each side face of the spool
49+
scoreSketch01 = score(radius = hubDiameter / 2 + webThickness, length = (coreDiameter - hubDiameter) / 2 - (2 * webThickness), depth = spoolThickness / 2)
50+
scoreSketch02 = score(radius = coreDiameter / 2, length = (spoolDiameter - coreDiameter) / 2 - (webThickness * 3), depth = webThickness / 2)
51+
// Mirror the spool base piece across the Y axis
52+
|> patternCircular3d(instances = 2, axis = [0, 1, 0], center = [0, 0, 0])
53+
54+
// Model a wound coil on the spool diameter
55+
hel01 = helix(
56+
revolutions = spoolThickness / stockDiameter / 1.5,
57+
angleStart = 0,
58+
radius = (coreDiameter + stockDiameter) / 2,
59+
axis = X,
60+
length = spoolThickness,
61+
)
62+
63+
// Sweep and color the coil
64+
stock = startSketchOn(XZ)
65+
|> circle(center = [0, -(coreDiameter + stockDiameter) / 2], diameter = stockDiameter)
66+
|> sweep(path = hel01)
67+
|> translate(x = -spoolThickness / 2)
68+
|> appearance(color = "#f2471c", metalness = 70, roughness = 30)
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// Teapot
2+
// A vessel with a spout and a handle used for serving tea and boiling water on a stovetop
3+
4+
// Set units
5+
@settings(defaultLengthUnit = mm)
6+
7+
// Define parameters
8+
teapotHeight = 130
9+
beltlineDiameter = 160
10+
wallThickness = 6
11+
outletHeight = 26
12+
spoutDiameter = 12
13+
14+
// Sketch the path of the teapot spout
15+
spoutPath = startSketchOn(XZ)
16+
|> startProfile(at = [-beltlineDiameter / 2.5, outletHeight])
17+
|> xLine(length = -15.05)
18+
|> tangentialArc(angle = -110, radius = 30, tag = $seg01)
19+
|> angledLine(angle = tangentToEnd(seg01), length = 16.84)
20+
|> tangentialArc(angle = 100, radius = 30)
21+
22+
// Sweep a hollow spout
23+
spout = startSketchOn(offsetPlane(YZ, offset = -beltlineDiameter / 2.5))
24+
|> circle(center = [0, outletHeight], diameter = spoutDiameter)
25+
|> subtract2d(tool = circle(center = [0, outletHeight], diameter = spoutDiameter * 0.8))
26+
|> sweep(path = spoutPath)
27+
28+
// Model the perimeter of the teapot body, to be used to trim the handle so that it fits snug to the body
29+
tools = startSketchOn(YZ)
30+
|> startProfile(at = [0, 0])
31+
|> xLine(length = beltlineDiameter / 5)
32+
|> tangentialArc(endAbsolute = [
33+
beltlineDiameter / 2.1,
34+
teapotHeight / 2.5
35+
])
36+
|> tangentialArc(endAbsolute = [
37+
beltlineDiameter / 3,
38+
teapotHeight / 1.1
39+
])
40+
|> tangentialArc(endAbsolute = [beltlineDiameter / 4, teapotHeight])
41+
|> xLine(endAbsolute = profileStartX(%))
42+
|> line(endAbsolute = profileStart(%))
43+
|> close()
44+
|> revolve(axis = Y)
45+
46+
// Sketch the path of the handle
47+
handlePath = startSketchOn(XZ)
48+
|> startProfile(at = [0, outletHeight])
49+
|> xLine(endAbsolute = 76)
50+
|> tangentialArc(end = [12.98, 6.64])
51+
|> tangentialArc(end = [28.39, 63.11])
52+
|> tangentialArc(end = [-10.27, 14.8])
53+
|> tangentialArc(end = [-48.01, 1.81], tag = $seg02)
54+
|> angledLine(angle = tangentToEnd(seg02), endAbsoluteX = 0)
55+
56+
// Sweep the handle
57+
handle = startSketchOn(YZ)
58+
|> startProfile(at = [-10, outletHeight + 3.5])
59+
|> arc(interiorAbsolute = [0, outletHeight + 5], endAbsolute = [10, profileStartY(%)])
60+
|> tangentialArc(end = [0, -7])
61+
|> tangentialArc(end = [-20, 0])
62+
|> tangentialArc(endAbsolute = profileStart())
63+
|> close()
64+
|> sweep(path = handlePath)
65+
|> subtract(tools)
66+
67+
// Create a cutout in the body for the spout outlet
68+
spoutHole = startSketchOn(YZ)
69+
|> circle(center = [0, outletHeight], diameter = spoutDiameter)
70+
|> extrude(length = -beltlineDiameter / 2)
71+
72+
// Model the body of the teapot
73+
body = startSketchOn(YZ)
74+
|> startProfile(at = [0, 0])
75+
|> xLine(length = beltlineDiameter / 5)
76+
|> tangentialArc(endAbsolute = [
77+
beltlineDiameter / 2.1,
78+
teapotHeight / 2.5
79+
])
80+
|> tangentialArc(endAbsolute = [
81+
beltlineDiameter / 3,
82+
teapotHeight / 1.1
83+
])
84+
|> tangentialArc(endAbsolute = [beltlineDiameter / 4, teapotHeight])
85+
|> tangentialArc(angle = 190, diameter = wallThickness)
86+
|> tangentialArc(endAbsolute = [
87+
beltlineDiameter / 3 - wallThickness,
88+
teapotHeight / 1.1
89+
])
90+
|> tangentialArc(endAbsolute = [
91+
beltlineDiameter / 2.1 - wallThickness,
92+
teapotHeight / 2.5
93+
])
94+
|> tangentialArc(endAbsolute = [
95+
beltlineDiameter / 5,
96+
profileStartY() + wallThickness
97+
])
98+
|> xLine(endAbsolute = profileStartX(%))
99+
|> line(endAbsolute = profileStart(%))
100+
|> close()
101+
|> revolve(axis = Y)
102+
|> subtract(tools = [spoutHole])
103+
104+
// Join each component of the teapot and add an appearance
105+
[body, handle, spout]
106+
|> appearance(color = "#1f9896", metalness = 40, roughness = 30)

0 commit comments

Comments
 (0)