Update KCL tests and samples

This commit is contained in:
Adam Chalmers
2025-04-09 16:46:12 -05:00
parent 5cfeca0f69
commit 5e226b5573
8 changed files with 104 additions and 132 deletions

View File

@ -157,11 +157,11 @@ fn z(origin, scale, depth) {
|> yLine(length = segLen(seg3)) |> yLine(length = segLen(seg3))
|> xLine(endAbsolute = 0 + origin[0]) |> xLine(endAbsolute = 0 + origin[0])
|> yLine(length = -0.225 * scale) |> yLine(length = -0.225 * scale)
|> angledLineThatIntersects({ |> angledLineThatIntersects(
angle = 0, angle = 0,
intersectTag = seg2, intersectTag = seg2,
offset = 0 offset = 0,
}, %) )
|> close() |> close()
|> extrude(length = -depth) |> extrude(length = -depth)
|> appearance(color = baseColor) |> appearance(color = baseColor)

View File

@ -21,11 +21,11 @@ export fn zLogo(surface, origin, scale) {
|> yLine(length = segLen(seg3)) |> yLine(length = segLen(seg3))
|> xLine(endAbsolute = 0 + origin[0]) |> xLine(endAbsolute = 0 + origin[0])
|> yLine(length = -0.225 * scale) |> yLine(length = -0.225 * scale)
|> angledLineThatIntersects({ |> angledLineThatIntersects(
angle = 0, angle = 0,
intersectTag = seg2, intersectTag = seg2,
offset = 0 offset = 0,
}, %) )
|> close() |> close()
return zSketch return zSketch
} }

View File

@ -158,11 +158,11 @@ const extrude005l = extrude(sketch005l, length = 1)
const sketch006l = startSketchOn(plane001) const sketch006l = startSketchOn(plane001)
|> startProfileAt([1, 1], %) |> startProfileAt([1, 1], %)
|> angledLineThatIntersects({ |> angledLineThatIntersects(
angle: 70, angle = 70,
intersectTag: lineToIntersect4, intersectTag = lineToIntersect4,
offset: 0 offset = 0,
}, %) )
|> angledLine(angle = -70, length = 1.414 ) |> angledLine(angle = -70, length = 1.414 )
|> angledLine(angle = 70 + 180, endAbsoluteY = 2 - 1) |> angledLine(angle = 70 + 180, endAbsoluteY = 2 - 1)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
@ -174,11 +174,11 @@ const sketch007l = startSketchOn(plane001)
serverDepth - 1.2, serverDepth - 1.2,
railHeight * 1.75 + 1 railHeight * 1.75 + 1
], %) ], %)
|> angledLineThatIntersects({ |> angledLineThatIntersects(
angle: 70, angle = 70,
intersectTag: lineToIntersect5, intersectTag = lineToIntersect5,
offset: 0 offset = 0,
}, %) )
|> angledLine(angle = -70, length = 1.414 ) |> angledLine(angle = -70, length = 1.414 )
|> angledLine(angle = 70 + 180, endAbsoluteY = railHeight * 1.75 + 1) |> angledLine(angle = 70 + 180, endAbsoluteY = railHeight * 1.75 + 1)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
@ -251,11 +251,12 @@ const sketch006w = startSketchOn(plane002)
], %) ], %)
|> angledLine(angle = -23 + 90, endAbsoluteX = depth - 1) |> angledLine(angle = -23 + 90, endAbsoluteX = depth - 1)
|> yLine(length = 2.56) |> yLine(length = 2.56)
|> angledLineThatIntersects({ |> angledLineThatIntersects(
angle: -23 + 90 + 180, angle = -23 + 90 + 180,
intersectTag: lineToIntersect, intersectTag = lineToIntersect,
offset: 0 offset = 0,
}, %, $lineToIntersect2) tag = $lineToIntersect2,
)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
const extrude006w = extrude(sketch006w, length = 1) const extrude006w = extrude(sketch006w, length = 1)
@ -264,28 +265,28 @@ const sketch007w = startSketchOn(plane002)
|> startProfileAt([depth - 1, 60.65 + 1.75 / 2], %) |> startProfileAt([depth - 1, 60.65 + 1.75 / 2], %)
|> angledLine(angle = -23 + 180, length = 34.93 , tag = $lineToIntersect3) |> angledLine(angle = -23 + 180, length = 34.93 , tag = $lineToIntersect3)
|> angledLine(angle = 23 - 90, length = 1.414 ) |> angledLine(angle = 23 - 90, length = 1.414 )
|> angledLineThatIntersects({ |> angledLineThatIntersects(
angle: -23 + 180, angle = -23 + 180,
intersectTag: lineToIntersect2, intersectTag = lineToIntersect2,
offset: 0 offset = 0,
}, %) )
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
const extrude007w = extrude(sketch007w, length = 1) const extrude007w = extrude(sketch007w, length = 1)
const sketch008w = startSketchOn(plane002) const sketch008w = startSketchOn(plane002)
|> startProfileAt([1, 41.7 + 1.75 / 2], %) |> startProfileAt([1, 41.7 + 1.75 / 2], %)
|> angledLineThatIntersects({ |> angledLineThatIntersects(
angle: -23 + 90, angle = -23 + 90,
intersectTag: lineToIntersect3, intersectTag = lineToIntersect3,
offset: 0 offset = 0,
}, %) )
|> angledLine(angle = -23 - 45, length = 1.414 ) |> angledLine(angle = -23 - 45, length = 1.414 )
|> angledLineThatIntersects({ |> angledLineThatIntersects(
angle: -23 - 90, angle = -23 - 90,
intersectTag: lineToIntersect, intersectTag = lineToIntersect,
offset: 0 offset = 0,
}, %) )
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
const extrude008w = extrude(sketch008w, length = 1) const extrude008w = extrude(sketch008w, length = 1)

View File

@ -1077,35 +1077,6 @@ macro_rules! let_field_of {
}; };
} }
impl<'a> FromKclValue<'a> for crate::std::import::ImportFormat {
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
let obj = arg.as_object()?;
let_field_of!(obj, typ "format");
match typ {
"fbx" => Some(Self::Fbx {}),
"gltf" => Some(Self::Gltf {}),
"sldprt" => Some(Self::Sldprt {}),
"step" => Some(Self::Step {}),
"stl" => {
let_field_of!(obj, coords?);
let_field_of!(obj, units);
Some(Self::Stl { coords, units })
}
"obj" => {
let_field_of!(obj, coords?);
let_field_of!(obj, units);
Some(Self::Obj { coords, units })
}
"ply" => {
let_field_of!(obj, coords?);
let_field_of!(obj, units);
Some(Self::Ply { coords, units })
}
_ => None,
}
}
}
impl<'a> FromKclValue<'a> for super::shapes::PolygonData { impl<'a> FromKclValue<'a> for super::shapes::PolygonData {
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> { fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
let obj = arg.as_object()?; let obj = arg.as_object()?;

View File

@ -318,40 +318,40 @@ flowchart LR
892["Segment<br>[5632, 5660, 0]"] 892["Segment<br>[5632, 5660, 0]"]
893["Segment<br>[5668, 5702, 0]"] 893["Segment<br>[5668, 5702, 0]"]
894["Segment<br>[5710, 5740, 0]"] 894["Segment<br>[5710, 5740, 0]"]
895["Segment<br>[5748, 5857, 0]"] 895["Segment<br>[5748, 5853, 0]"]
896["Segment<br>[5865, 5872, 0]"] 896["Segment<br>[5861, 5868, 0]"]
897[Solid2d] 897[Solid2d]
end end
subgraph path950 [Path] subgraph path950 [Path]
950["Path<br>[6072, 6170, 0]"] 950["Path<br>[6068, 6166, 0]"]
951["Segment<br>[6178, 6297, 0]"] 951["Segment<br>[6174, 6293, 0]"]
952["Segment<br>[6305, 6352, 0]"] 952["Segment<br>[6301, 6348, 0]"]
953["Segment<br>[6360, 6481, 0]"] 953["Segment<br>[6356, 6477, 0]"]
954["Segment<br>[6489, 6496, 0]"] 954["Segment<br>[6485, 6492, 0]"]
955[Solid2d] 955[Solid2d]
end end
subgraph path972 [Path] subgraph path972 [Path]
972["Path<br>[6604, 6701, 0]"] 972["Path<br>[6600, 6697, 0]"]
973["Segment<br>[6709, 6828, 0]"] 973["Segment<br>[6705, 6824, 0]"]
974["Segment<br>[6836, 6884, 0]"] 974["Segment<br>[6832, 6880, 0]"]
975["Segment<br>[6892, 7013, 0]"] 975["Segment<br>[6888, 7009, 0]"]
976["Segment<br>[7021, 7028, 0]"] 976["Segment<br>[7017, 7024, 0]"]
977[Solid2d] 977[Solid2d]
end end
subgraph path994 [Path] subgraph path994 [Path]
994["Path<br>[6072, 6170, 0]"] 994["Path<br>[6068, 6166, 0]"]
995["Segment<br>[6178, 6297, 0]"] 995["Segment<br>[6174, 6293, 0]"]
996["Segment<br>[6305, 6352, 0]"] 996["Segment<br>[6301, 6348, 0]"]
997["Segment<br>[6360, 6481, 0]"] 997["Segment<br>[6356, 6477, 0]"]
998["Segment<br>[6489, 6496, 0]"] 998["Segment<br>[6485, 6492, 0]"]
999[Solid2d] 999[Solid2d]
end end
subgraph path1016 [Path] subgraph path1016 [Path]
1016["Path<br>[6604, 6701, 0]"] 1016["Path<br>[6600, 6697, 0]"]
1017["Segment<br>[6709, 6828, 0]"] 1017["Segment<br>[6705, 6824, 0]"]
1018["Segment<br>[6836, 6884, 0]"] 1018["Segment<br>[6832, 6880, 0]"]
1019["Segment<br>[6892, 7013, 0]"] 1019["Segment<br>[6888, 7009, 0]"]
1020["Segment<br>[7021, 7028, 0]"] 1020["Segment<br>[7017, 7024, 0]"]
1021[Solid2d] 1021[Solid2d]
end end
1["Plane<br>[532, 549, 0]"] 1["Plane<br>[532, 549, 0]"]
@ -983,7 +983,7 @@ flowchart LR
877["SweepEdge Opposite"] 877["SweepEdge Opposite"]
878["SweepEdge Adjacent"] 878["SweepEdge Adjacent"]
879["Plane<br>[4965, 4988, 0]"] 879["Plane<br>[4965, 4988, 0]"]
898["Sweep Extrusion<br>[5880, 5904, 0]"] 898["Sweep Extrusion<br>[5876, 5900, 0]"]
899[Wall] 899[Wall]
900[Wall] 900[Wall]
901[Wall] 901[Wall]
@ -1034,8 +1034,8 @@ flowchart LR
946["SweepEdge Adjacent"] 946["SweepEdge Adjacent"]
947["SweepEdge Opposite"] 947["SweepEdge Opposite"]
948["SweepEdge Adjacent"] 948["SweepEdge Adjacent"]
949["Plane<br>[6041, 6064, 0]"] 949["Plane<br>[6037, 6060, 0]"]
956["Sweep Extrusion<br>[6504, 6528, 0]"] 956["Sweep Extrusion<br>[6500, 6524, 0]"]
957[Wall] 957[Wall]
958[Wall] 958[Wall]
959[Wall] 959[Wall]
@ -1050,8 +1050,8 @@ flowchart LR
968["SweepEdge Adjacent"] 968["SweepEdge Adjacent"]
969["SweepEdge Opposite"] 969["SweepEdge Opposite"]
970["SweepEdge Adjacent"] 970["SweepEdge Adjacent"]
971["Plane<br>[6573, 6596, 0]"] 971["Plane<br>[6569, 6592, 0]"]
978["Sweep Extrusion<br>[7036, 7060, 0]"] 978["Sweep Extrusion<br>[7032, 7056, 0]"]
979[Wall] 979[Wall]
980[Wall] 980[Wall]
981[Wall] 981[Wall]
@ -1066,8 +1066,8 @@ flowchart LR
990["SweepEdge Adjacent"] 990["SweepEdge Adjacent"]
991["SweepEdge Opposite"] 991["SweepEdge Opposite"]
992["SweepEdge Adjacent"] 992["SweepEdge Adjacent"]
993["Plane<br>[6041, 6064, 0]"] 993["Plane<br>[6037, 6060, 0]"]
1000["Sweep Extrusion<br>[6504, 6528, 0]"] 1000["Sweep Extrusion<br>[6500, 6524, 0]"]
1001[Wall] 1001[Wall]
1002[Wall] 1002[Wall]
1003[Wall] 1003[Wall]
@ -1082,8 +1082,8 @@ flowchart LR
1012["SweepEdge Adjacent"] 1012["SweepEdge Adjacent"]
1013["SweepEdge Opposite"] 1013["SweepEdge Opposite"]
1014["SweepEdge Adjacent"] 1014["SweepEdge Adjacent"]
1015["Plane<br>[6573, 6596, 0]"] 1015["Plane<br>[6569, 6592, 0]"]
1022["Sweep Extrusion<br>[7036, 7060, 0]"] 1022["Sweep Extrusion<br>[7032, 7056, 0]"]
1023[Wall] 1023[Wall]
1024[Wall] 1024[Wall]
1025[Wall] 1025[Wall]

View File

@ -7308,7 +7308,7 @@ description: Operations executed keyboard.kcl
"name": "z", "name": "z",
"functionSourceRange": [ "functionSourceRange": [
4934, 4934,
5954, 5950,
0 0
], ],
"unlabeledArg": null, "unlabeledArg": null,
@ -7549,8 +7549,8 @@ description: Operations executed keyboard.kcl
"type": "FunctionCall", "type": "FunctionCall",
"name": "o", "name": "o",
"functionSourceRange": [ "functionSourceRange": [
6001, 5997,
7110, 7106,
0 0
], ],
"unlabeledArg": null, "unlabeledArg": null,
@ -8015,8 +8015,8 @@ description: Operations executed keyboard.kcl
"type": "FunctionCall", "type": "FunctionCall",
"name": "o", "name": "o",
"functionSourceRange": [ "functionSourceRange": [
6001, 5997,
7110, 7106,
0 0
], ],
"unlabeledArg": null, "unlabeledArg": null,

View File

@ -94,40 +94,40 @@ flowchart LR
168["Segment<br>[759, 787, 12]"] 168["Segment<br>[759, 787, 12]"]
169["Segment<br>[795, 829, 12]"] 169["Segment<br>[795, 829, 12]"]
170["Segment<br>[837, 867, 12]"] 170["Segment<br>[837, 867, 12]"]
171["Segment<br>[875, 984, 12]"] 171["Segment<br>[875, 980, 12]"]
172["Segment<br>[992, 999, 12]"] 172["Segment<br>[988, 995, 12]"]
173[Solid2d] 173[Solid2d]
end end
subgraph path175 [Path] subgraph path175 [Path]
175["Path<br>[1133, 1231, 12]"] 175["Path<br>[1129, 1227, 12]"]
176["Segment<br>[1239, 1358, 12]"] 176["Segment<br>[1235, 1354, 12]"]
177["Segment<br>[1366, 1413, 12]"] 177["Segment<br>[1362, 1409, 12]"]
178["Segment<br>[1421, 1542, 12]"] 178["Segment<br>[1417, 1538, 12]"]
179["Segment<br>[1550, 1557, 12]"] 179["Segment<br>[1546, 1553, 12]"]
180[Solid2d] 180[Solid2d]
end end
subgraph path182 [Path] subgraph path182 [Path]
182["Path<br>[1654, 1751, 12]"] 182["Path<br>[1650, 1747, 12]"]
183["Segment<br>[1759, 1878, 12]"] 183["Segment<br>[1755, 1874, 12]"]
184["Segment<br>[1886, 1934, 12]"] 184["Segment<br>[1882, 1930, 12]"]
185["Segment<br>[1942, 2063, 12]"] 185["Segment<br>[1938, 2059, 12]"]
186["Segment<br>[2071, 2078, 12]"] 186["Segment<br>[2067, 2074, 12]"]
187[Solid2d] 187[Solid2d]
end end
subgraph path189 [Path] subgraph path189 [Path]
189["Path<br>[1133, 1231, 12]"] 189["Path<br>[1129, 1227, 12]"]
190["Segment<br>[1239, 1358, 12]"] 190["Segment<br>[1235, 1354, 12]"]
191["Segment<br>[1366, 1413, 12]"] 191["Segment<br>[1362, 1409, 12]"]
192["Segment<br>[1421, 1542, 12]"] 192["Segment<br>[1417, 1538, 12]"]
193["Segment<br>[1550, 1557, 12]"] 193["Segment<br>[1546, 1553, 12]"]
194[Solid2d] 194[Solid2d]
end end
subgraph path196 [Path] subgraph path196 [Path]
196["Path<br>[1654, 1751, 12]"] 196["Path<br>[1650, 1747, 12]"]
197["Segment<br>[1759, 1878, 12]"] 197["Segment<br>[1755, 1874, 12]"]
198["Segment<br>[1886, 1934, 12]"] 198["Segment<br>[1882, 1930, 12]"]
199["Segment<br>[1942, 2063, 12]"] 199["Segment<br>[1938, 2059, 12]"]
200["Segment<br>[2071, 2078, 12]"] 200["Segment<br>[2067, 2074, 12]"]
201[Solid2d] 201[Solid2d]
end end
subgraph path230 [Path] subgraph path230 [Path]

View File

@ -1515,7 +1515,7 @@ description: Operations executed walkie-talkie.kcl
"name": "zLogo", "name": "zLogo",
"functionSourceRange": [ "functionSourceRange": [
69, 69,
1018, 1014,
12 12
], ],
"unlabeledArg": null, "unlabeledArg": null,
@ -1573,8 +1573,8 @@ description: Operations executed walkie-talkie.kcl
"type": "FunctionCall", "type": "FunctionCall",
"name": "oLogo", "name": "oLogo",
"functionSourceRange": [ "functionSourceRange": [
1076, 1072,
1579, 1575,
12 12
], ],
"unlabeledArg": null, "unlabeledArg": null,
@ -1632,8 +1632,8 @@ description: Operations executed walkie-talkie.kcl
"type": "FunctionCall", "type": "FunctionCall",
"name": "oLogo2", "name": "oLogo2",
"functionSourceRange": [ "functionSourceRange": [
1597, 1593,
2100, 2096,
12 12
], ],
"unlabeledArg": null, "unlabeledArg": null,
@ -1691,8 +1691,8 @@ description: Operations executed walkie-talkie.kcl
"type": "FunctionCall", "type": "FunctionCall",
"name": "oLogo", "name": "oLogo",
"functionSourceRange": [ "functionSourceRange": [
1076, 1072,
1579, 1575,
12 12
], ],
"unlabeledArg": null, "unlabeledArg": null,
@ -1750,8 +1750,8 @@ description: Operations executed walkie-talkie.kcl
"type": "FunctionCall", "type": "FunctionCall",
"name": "oLogo2", "name": "oLogo2",
"functionSourceRange": [ "functionSourceRange": [
1597, 1593,
2100, 2096,
12 12
], ],
"unlabeledArg": null, "unlabeledArg": null,