Compare commits
1 Commits
adjust-seg
...
jtran/fix-
Author | SHA1 | Date | |
---|---|---|---|
cbfe3db203 |
@ -2048,3 +2048,24 @@ mod import_file_parse_error {
|
||||
super::execute(TEST_NAME, true).await
|
||||
}
|
||||
}
|
||||
mod assembly_simplified_walkie {
|
||||
const TEST_NAME: &str = "assembly_simplified_walkie";
|
||||
|
||||
/// Test parsing KCL.
|
||||
#[test]
|
||||
fn parse() {
|
||||
super::parse(TEST_NAME)
|
||||
}
|
||||
|
||||
/// Test that parsing and unparsing KCL produces the original KCL input.
|
||||
#[test]
|
||||
fn unparse() {
|
||||
super::unparse(TEST_NAME)
|
||||
}
|
||||
|
||||
/// Test that KCL is executed correctly.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_execute() {
|
||||
super::execute(TEST_NAME, true).await
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,6 @@
|
||||
---
|
||||
source: kcl/src/simulation_tests.rs
|
||||
description: Artifact graph flowchart assembly_simplified_walkie.kcl
|
||||
extension: md
|
||||
snapshot_kind: binary
|
||||
---
|
@ -0,0 +1,219 @@
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph path3 [Path]
|
||||
3["Path<br>[1358, 1517, 3]"]
|
||||
4["Segment<br>[1523, 1618, 3]"]
|
||||
5["Segment<br>[1624, 1785, 3]"]
|
||||
6["Segment<br>[1791, 1886, 3]"]
|
||||
7["Segment<br>[1892, 2056, 3]"]
|
||||
8["Segment<br>[2062, 2158, 3]"]
|
||||
9["Segment<br>[2164, 2327, 3]"]
|
||||
10["Segment<br>[2333, 2428, 3]"]
|
||||
11["Segment<br>[2434, 2441, 3]"]
|
||||
12[Solid2d]
|
||||
end
|
||||
subgraph path41 [Path]
|
||||
41["Path<br>[1119, 1160, 5]"]
|
||||
42["Segment<br>[1168, 1263, 5]"]
|
||||
43["Segment<br>[1271, 1367, 5]"]
|
||||
44["Segment<br>[1375, 1461, 5]"]
|
||||
45["Segment<br>[1469, 1476, 5]"]
|
||||
46[Solid2d]
|
||||
end
|
||||
subgraph path63 [Path]
|
||||
63["Path<br>[503, 596, 4]"]
|
||||
64["Segment<br>[602, 639, 4]"]
|
||||
65["Segment<br>[645, 683, 4]"]
|
||||
66["Segment<br>[689, 727, 4]"]
|
||||
67["Segment<br>[733, 751, 4]"]
|
||||
68[Solid2d]
|
||||
end
|
||||
1["Plane<br>[358, 387, 3]"]
|
||||
2["Plane<br>[1322, 1351, 3]"]
|
||||
13["Sweep Extrusion<br>[2790, 2826, 3]"]
|
||||
14[Wall]
|
||||
15[Wall]
|
||||
16[Wall]
|
||||
17[Wall]
|
||||
18[Wall]
|
||||
19[Wall]
|
||||
20[Wall]
|
||||
21[Wall]
|
||||
22["Cap Start"]
|
||||
23["Cap End"]
|
||||
24["SweepEdge Opposite"]
|
||||
25["SweepEdge Adjacent"]
|
||||
26["SweepEdge Opposite"]
|
||||
27["SweepEdge Adjacent"]
|
||||
28["SweepEdge Opposite"]
|
||||
29["SweepEdge Adjacent"]
|
||||
30["SweepEdge Opposite"]
|
||||
31["SweepEdge Adjacent"]
|
||||
32["SweepEdge Opposite"]
|
||||
33["SweepEdge Adjacent"]
|
||||
34["SweepEdge Opposite"]
|
||||
35["SweepEdge Adjacent"]
|
||||
36["SweepEdge Opposite"]
|
||||
37["SweepEdge Adjacent"]
|
||||
38["SweepEdge Opposite"]
|
||||
39["SweepEdge Adjacent"]
|
||||
40["Plane<br>[405, 442, 0]"]
|
||||
47["Sweep Extrusion<br>[1495, 1542, 5]"]
|
||||
48[Wall]
|
||||
49[Wall]
|
||||
50[Wall]
|
||||
51[Wall]
|
||||
52["Cap Start"]
|
||||
53["Cap End"]
|
||||
54["SweepEdge Opposite"]
|
||||
55["SweepEdge Adjacent"]
|
||||
56["SweepEdge Opposite"]
|
||||
57["SweepEdge Adjacent"]
|
||||
58["SweepEdge Opposite"]
|
||||
59["SweepEdge Adjacent"]
|
||||
60["SweepEdge Opposite"]
|
||||
61["SweepEdge Adjacent"]
|
||||
62["Plane<br>[467, 497, 4]"]
|
||||
69["Sweep Extrusion<br>[797, 849, 4]"]
|
||||
70[Wall]
|
||||
71[Wall]
|
||||
72[Wall]
|
||||
73[Wall]
|
||||
74["Cap Start"]
|
||||
75["Cap End"]
|
||||
76["SweepEdge Opposite"]
|
||||
77["SweepEdge Adjacent"]
|
||||
78["SweepEdge Opposite"]
|
||||
79["SweepEdge Adjacent"]
|
||||
80["SweepEdge Opposite"]
|
||||
81["SweepEdge Adjacent"]
|
||||
82["SweepEdge Opposite"]
|
||||
83["SweepEdge Adjacent"]
|
||||
2 --- 3
|
||||
3 --- 4
|
||||
3 --- 5
|
||||
3 --- 6
|
||||
3 --- 7
|
||||
3 --- 8
|
||||
3 --- 9
|
||||
3 --- 10
|
||||
3 --- 11
|
||||
3 ---- 13
|
||||
3 --- 12
|
||||
4 --- 21
|
||||
4 --- 38
|
||||
4 --- 39
|
||||
5 --- 20
|
||||
5 --- 36
|
||||
5 --- 37
|
||||
6 --- 19
|
||||
6 --- 34
|
||||
6 --- 35
|
||||
7 --- 18
|
||||
7 --- 32
|
||||
7 --- 33
|
||||
8 --- 17
|
||||
8 --- 30
|
||||
8 --- 31
|
||||
9 --- 16
|
||||
9 --- 28
|
||||
9 --- 29
|
||||
10 --- 15
|
||||
10 --- 26
|
||||
10 --- 27
|
||||
11 --- 14
|
||||
11 --- 24
|
||||
11 --- 25
|
||||
13 --- 14
|
||||
13 --- 15
|
||||
13 --- 16
|
||||
13 --- 17
|
||||
13 --- 18
|
||||
13 --- 19
|
||||
13 --- 20
|
||||
13 --- 21
|
||||
13 --- 22
|
||||
13 --- 23
|
||||
13 --- 24
|
||||
13 --- 25
|
||||
13 --- 26
|
||||
13 --- 27
|
||||
13 --- 28
|
||||
13 --- 29
|
||||
13 --- 30
|
||||
13 --- 31
|
||||
13 --- 32
|
||||
13 --- 33
|
||||
13 --- 34
|
||||
13 --- 35
|
||||
13 --- 36
|
||||
13 --- 37
|
||||
13 --- 38
|
||||
13 --- 39
|
||||
40 --- 41
|
||||
41 --- 42
|
||||
41 --- 43
|
||||
41 --- 44
|
||||
41 --- 45
|
||||
41 ---- 47
|
||||
41 --- 46
|
||||
42 --- 48
|
||||
42 --- 54
|
||||
42 --- 55
|
||||
43 --- 49
|
||||
43 --- 56
|
||||
43 --- 57
|
||||
44 --- 50
|
||||
44 --- 58
|
||||
44 --- 59
|
||||
45 --- 51
|
||||
45 --- 60
|
||||
45 --- 61
|
||||
47 --- 48
|
||||
47 --- 49
|
||||
47 --- 50
|
||||
47 --- 51
|
||||
47 --- 52
|
||||
47 --- 53
|
||||
47 --- 54
|
||||
47 --- 55
|
||||
47 --- 56
|
||||
47 --- 57
|
||||
47 --- 58
|
||||
47 --- 59
|
||||
47 --- 60
|
||||
47 --- 61
|
||||
62 --- 63
|
||||
63 --- 64
|
||||
63 --- 65
|
||||
63 --- 66
|
||||
63 --- 67
|
||||
63 ---- 69
|
||||
63 --- 68
|
||||
64 --- 73
|
||||
64 --- 82
|
||||
64 --- 83
|
||||
65 --- 72
|
||||
65 --- 80
|
||||
65 --- 81
|
||||
66 --- 71
|
||||
66 --- 78
|
||||
66 --- 79
|
||||
67 --- 70
|
||||
67 --- 76
|
||||
67 --- 77
|
||||
69 --- 70
|
||||
69 --- 71
|
||||
69 --- 72
|
||||
69 --- 73
|
||||
69 --- 74
|
||||
69 --- 75
|
||||
69 --- 76
|
||||
69 --- 77
|
||||
69 --- 78
|
||||
69 --- 79
|
||||
69 --- 80
|
||||
69 --- 81
|
||||
69 --- 82
|
||||
69 --- 83
|
||||
```
|
428
src/wasm-lib/kcl/tests/assembly_simplified_walkie/ast.snap
Normal file
428
src/wasm-lib/kcl/tests/assembly_simplified_walkie/ast.snap
Normal file
@ -0,0 +1,428 @@
|
||||
---
|
||||
source: kcl/src/simulation_tests.rs
|
||||
description: Result of parsing assembly_simplified_walkie.kcl
|
||||
---
|
||||
{
|
||||
"Ok": {
|
||||
"body": [
|
||||
{
|
||||
"end": 112,
|
||||
"path": {
|
||||
"type": "Kcl",
|
||||
"filename": "case.kcl"
|
||||
},
|
||||
"selector": {
|
||||
"type": "None",
|
||||
"alias": null
|
||||
},
|
||||
"start": 95,
|
||||
"type": "ImportStatement",
|
||||
"type": "ImportStatement"
|
||||
},
|
||||
{
|
||||
"end": 151,
|
||||
"path": {
|
||||
"type": "Kcl",
|
||||
"filename": "talk-button.kcl"
|
||||
},
|
||||
"selector": {
|
||||
"type": "None",
|
||||
"alias": {
|
||||
"end": 151,
|
||||
"name": "talkButton",
|
||||
"start": 141,
|
||||
"type": "Identifier"
|
||||
}
|
||||
},
|
||||
"start": 113,
|
||||
"type": "ImportStatement",
|
||||
"type": "ImportStatement"
|
||||
},
|
||||
{
|
||||
"end": 183,
|
||||
"path": {
|
||||
"type": "Kcl",
|
||||
"filename": "button.kcl"
|
||||
},
|
||||
"selector": {
|
||||
"type": "List",
|
||||
"items": [
|
||||
{
|
||||
"alias": null,
|
||||
"end": 165,
|
||||
"name": {
|
||||
"end": 165,
|
||||
"name": "button",
|
||||
"start": 159,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 159,
|
||||
"type": "ImportItem"
|
||||
}
|
||||
]
|
||||
},
|
||||
"start": 152,
|
||||
"type": "ImportStatement",
|
||||
"type": "ImportStatement"
|
||||
},
|
||||
{
|
||||
"end": 289,
|
||||
"path": {
|
||||
"type": "Kcl",
|
||||
"filename": "globals.kcl"
|
||||
},
|
||||
"selector": {
|
||||
"type": "List",
|
||||
"items": [
|
||||
{
|
||||
"alias": null,
|
||||
"end": 196,
|
||||
"name": {
|
||||
"end": 196,
|
||||
"name": "width",
|
||||
"start": 191,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 191,
|
||||
"type": "ImportItem"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"end": 204,
|
||||
"name": {
|
||||
"end": 204,
|
||||
"name": "height",
|
||||
"start": 198,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 198,
|
||||
"type": "ImportItem"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"end": 215,
|
||||
"name": {
|
||||
"end": 215,
|
||||
"name": "thickness",
|
||||
"start": 206,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 206,
|
||||
"type": "ImportItem"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"end": 228,
|
||||
"name": {
|
||||
"end": 228,
|
||||
"name": "screenWidth",
|
||||
"start": 217,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 217,
|
||||
"type": "ImportItem"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"end": 242,
|
||||
"name": {
|
||||
"end": 242,
|
||||
"name": "screenHeight",
|
||||
"start": 230,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 230,
|
||||
"type": "ImportItem"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"end": 259,
|
||||
"name": {
|
||||
"end": 259,
|
||||
"name": "screenYPosition",
|
||||
"start": 244,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 244,
|
||||
"type": "ImportItem"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"end": 270,
|
||||
"name": {
|
||||
"end": 270,
|
||||
"name": "tolerance",
|
||||
"start": 261,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 261,
|
||||
"type": "ImportItem"
|
||||
}
|
||||
]
|
||||
},
|
||||
"start": 184,
|
||||
"type": "ImportStatement",
|
||||
"type": "ImportStatement"
|
||||
},
|
||||
{
|
||||
"end": 314,
|
||||
"expression": {
|
||||
"end": 314,
|
||||
"name": "case",
|
||||
"start": 310,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 310,
|
||||
"type": "ExpressionStatement",
|
||||
"type": "ExpressionStatement"
|
||||
},
|
||||
{
|
||||
"end": 443,
|
||||
"expression": {
|
||||
"arguments": [
|
||||
{
|
||||
"elements": [
|
||||
{
|
||||
"argument": {
|
||||
"end": 378,
|
||||
"left": {
|
||||
"end": 366,
|
||||
"left": {
|
||||
"end": 362,
|
||||
"name": "screenWidth",
|
||||
"start": 351,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
},
|
||||
"operator": "/",
|
||||
"right": {
|
||||
"end": 366,
|
||||
"raw": "2",
|
||||
"start": 365,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 2.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
"start": 351,
|
||||
"type": "BinaryExpression",
|
||||
"type": "BinaryExpression"
|
||||
},
|
||||
"operator": "+",
|
||||
"right": {
|
||||
"end": 378,
|
||||
"name": "tolerance",
|
||||
"start": 369,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 351,
|
||||
"type": "BinaryExpression",
|
||||
"type": "BinaryExpression"
|
||||
},
|
||||
"end": 378,
|
||||
"operator": "-",
|
||||
"start": 349,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
},
|
||||
{
|
||||
"end": 398,
|
||||
"name": "screenYPosition",
|
||||
"start": 383,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
}
|
||||
],
|
||||
"end": 400,
|
||||
"start": 345,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
},
|
||||
{
|
||||
"end": 403,
|
||||
"raw": "0",
|
||||
"start": 402,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 0.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"type": "Identifier",
|
||||
"name": "offset"
|
||||
},
|
||||
"arg": {
|
||||
"end": 441,
|
||||
"name": "thickness",
|
||||
"start": 432,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"end": 416,
|
||||
"name": "offsetPlane",
|
||||
"start": 405,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"end": 442,
|
||||
"start": 405,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"end": 421,
|
||||
"raw": "\"XZ\"",
|
||||
"start": 417,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": "XZ"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"end": 344,
|
||||
"name": "button",
|
||||
"start": 338,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"end": 443,
|
||||
"start": 338,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
},
|
||||
"start": 338,
|
||||
"type": "ExpressionStatement",
|
||||
"type": "ExpressionStatement"
|
||||
},
|
||||
{
|
||||
"end": 481,
|
||||
"expression": {
|
||||
"end": 481,
|
||||
"name": "talkButton",
|
||||
"start": 471,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 471,
|
||||
"type": "ExpressionStatement",
|
||||
"type": "ExpressionStatement"
|
||||
}
|
||||
],
|
||||
"end": 482,
|
||||
"innerAttrs": [
|
||||
{
|
||||
"end": 33,
|
||||
"name": {
|
||||
"end": 9,
|
||||
"name": "settings",
|
||||
"start": 1,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"end": 32,
|
||||
"key": {
|
||||
"end": 27,
|
||||
"name": "defaultLengthUnit",
|
||||
"start": 10,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 10,
|
||||
"type": "ObjectProperty",
|
||||
"value": {
|
||||
"end": 32,
|
||||
"name": "in",
|
||||
"start": 30,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
}
|
||||
}
|
||||
],
|
||||
"start": 0,
|
||||
"type": "Annotation"
|
||||
}
|
||||
],
|
||||
"nonCodeMeta": {
|
||||
"nonCodeNodes": {
|
||||
"3": [
|
||||
{
|
||||
"end": 309,
|
||||
"start": 289,
|
||||
"type": "NonCodeNode",
|
||||
"value": {
|
||||
"type": "newLineBlockComment",
|
||||
"value": "Import the case",
|
||||
"style": "line"
|
||||
}
|
||||
}
|
||||
],
|
||||
"4": [
|
||||
{
|
||||
"end": 337,
|
||||
"start": 314,
|
||||
"type": "NonCodeNode",
|
||||
"value": {
|
||||
"type": "newLineBlockComment",
|
||||
"value": "Import the buttons",
|
||||
"style": "line"
|
||||
}
|
||||
}
|
||||
],
|
||||
"5": [
|
||||
{
|
||||
"end": 470,
|
||||
"start": 443,
|
||||
"type": "NonCodeNode",
|
||||
"value": {
|
||||
"type": "newLineBlockComment",
|
||||
"value": "Import the talk button",
|
||||
"style": "line"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"startNodes": [
|
||||
{
|
||||
"end": 36,
|
||||
"start": 33,
|
||||
"type": "NonCodeNode",
|
||||
"value": {
|
||||
"type": "newLine"
|
||||
}
|
||||
},
|
||||
{
|
||||
"end": 64,
|
||||
"start": 36,
|
||||
"type": "NonCodeNode",
|
||||
"value": {
|
||||
"type": "blockComment",
|
||||
"value": "Part of the Walkie Talkie",
|
||||
"style": "line"
|
||||
}
|
||||
},
|
||||
{
|
||||
"end": 94,
|
||||
"start": 65,
|
||||
"type": "NonCodeNode",
|
||||
"value": {
|
||||
"type": "blockComment",
|
||||
"value": "Import parts and constants",
|
||||
"style": "line"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"start": 0
|
||||
}
|
||||
}
|
74
src/wasm-lib/kcl/tests/assembly_simplified_walkie/button.kcl
Normal file
74
src/wasm-lib/kcl/tests/assembly_simplified_walkie/button.kcl
Normal file
@ -0,0 +1,74 @@
|
||||
// Walkie Talkie button
|
||||
|
||||
// Set units
|
||||
@settings(defaultLengthUnit = in)
|
||||
|
||||
// Import constants
|
||||
//import screenHeight, buttonWidth, tolerance, buttonHeight, buttonThickness from 'globals.kcl'
|
||||
export height = 4
|
||||
export width = 2.5
|
||||
export thickness = 1
|
||||
export chamferLength = .325
|
||||
export offset = .125
|
||||
export screenWidth = 1.75
|
||||
export screenHeight = 1
|
||||
export screenYPosition = height / 2 - 0.75
|
||||
export screenDepth = -.0625
|
||||
export speakerBoxWidth = 1.25
|
||||
export speakerBoxHeight = 1.25
|
||||
|
||||
// antenna
|
||||
export antennaBaseWidth = .5
|
||||
export antennaBaseHeight = .25
|
||||
export antennaTopWidth = .30
|
||||
export antennaTopHeight = .05
|
||||
|
||||
// button
|
||||
export buttonWidth = .15
|
||||
export tolerance = 0.020
|
||||
export buttonHeight = screenHeight / 2 - tolerance
|
||||
export buttonThickness = .040
|
||||
|
||||
// case
|
||||
export squareHoleSideLength = 0.0625
|
||||
export caseTolerance = 0.010
|
||||
|
||||
// knob
|
||||
export knobDiameter = .5
|
||||
export knobHeight = .25
|
||||
export knobRadius = 0.050
|
||||
|
||||
// talk-button
|
||||
export talkButtonSideLength = 0.5
|
||||
export talkButtonHeight = 0.050
|
||||
|
||||
|
||||
// Create a function for the button
|
||||
export fn button(origin, rotation, plane) {
|
||||
buttonSketch = startSketchOn(plane)
|
||||
|> startProfileAt([origin[0], origin[1]], %)
|
||||
|> angledLine({
|
||||
angle = 180 + rotation,
|
||||
length = buttonWidth
|
||||
}, %, $tag1)
|
||||
|> angledLine({
|
||||
angle = 270 + rotation,
|
||||
length = buttonHeight
|
||||
}, %, $tag2)
|
||||
|> angledLine({
|
||||
angle = 0 + rotation,
|
||||
length = buttonWidth
|
||||
}, %)
|
||||
|> close()
|
||||
buttonExtrude = extrude(buttonSketch, length = buttonThickness)
|
||||
|> chamfer(
|
||||
length = .050,
|
||||
tags = [
|
||||
getNextAdjacentEdge(tag1),
|
||||
getNextAdjacentEdge(tag2)
|
||||
]
|
||||
)
|
||||
|> appearance(color = "#ff0000")
|
||||
|
||||
return buttonExtrude
|
||||
}
|
85
src/wasm-lib/kcl/tests/assembly_simplified_walkie/case.kcl
Normal file
85
src/wasm-lib/kcl/tests/assembly_simplified_walkie/case.kcl
Normal file
@ -0,0 +1,85 @@
|
||||
// Walkie talkie case
|
||||
|
||||
|
||||
// Set units
|
||||
@settings(defaultLengthUnit = in)
|
||||
|
||||
|
||||
// Import constants and Zoo logo
|
||||
import width, height, chamferLength, offset, screenWidth, screenHeight, screenYPosition, screenDepth, speakerBoxWidth, speakerBoxHeight, squareHoleSideLength, caseTolerance from "globals.kcl"
|
||||
// import zLogo, oLogo, oLogo2 from "zoo-logo.kcl"
|
||||
|
||||
plane = offsetPlane("XZ", offset = 1)
|
||||
|
||||
fn screenHole(sketchStart) {
|
||||
sketch006 = startSketchOn(sketchStart)
|
||||
|> startProfileAt([-screenWidth / 2, screenYPosition], %)
|
||||
|> xLine(screenWidth, %)
|
||||
|> yLine(-screenHeight, %)
|
||||
|> xLine(-screenWidth, %)
|
||||
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
|> close()
|
||||
return sketch006
|
||||
}
|
||||
|
||||
fn squareHolePattern(plane, x, y) {
|
||||
fn transformX(i) {
|
||||
return { translate = [.125 * i, 0] }
|
||||
}
|
||||
fn transformY(i) {
|
||||
return { translate = [0, -.125 * i] }
|
||||
}
|
||||
squareHolePatternSketch = startSketchOn(plane)
|
||||
|> startProfileAt([-x, -y], %)
|
||||
|> line(end = [squareHoleSideLength / 2, 0])
|
||||
|> line(end = [0, -squareHoleSideLength / 2])
|
||||
|> line(end = [-squareHoleSideLength / 2, 0])
|
||||
|> close()
|
||||
|> patternTransform2d(instances = 13, transform = transformX)
|
||||
|> patternTransform2d(instances = 11, transform = transformY)
|
||||
return squareHolePatternSketch
|
||||
}
|
||||
sketch005 = startSketchOn(offsetPlane("XZ", offset = 1))
|
||||
|> startProfileAt([
|
||||
-width / 2 + offset + caseTolerance,
|
||||
height / 2 - (chamferLength + (offset + caseTolerance) / 2 * cos(toRadians(45)))
|
||||
], %)
|
||||
|> angledLineToY({
|
||||
angle = 45,
|
||||
to = height / 2 - (offset + caseTolerance)
|
||||
}, %)
|
||||
|> line(endAbsolute = [
|
||||
width / 2 - (chamferLength + (offset + caseTolerance) / 2 * cos(toRadians(45))),
|
||||
height / 2 - (offset + caseTolerance)
|
||||
])
|
||||
|> angledLineToX({
|
||||
angle = -45,
|
||||
to = width / 2 - (offset + caseTolerance)
|
||||
}, %)
|
||||
|> line(endAbsolute = [
|
||||
width / 2 - (offset + caseTolerance),
|
||||
-(height / 2 - (chamferLength + (offset + caseTolerance) / 2 * cos(toRadians(45))))
|
||||
])
|
||||
|> angledLineToY({
|
||||
angle = -135,
|
||||
to = -height / 2 + offset + caseTolerance
|
||||
}, %)
|
||||
|> line(endAbsolute = [
|
||||
-(width / 2 - (chamferLength + (offset + caseTolerance) / 2 * cos(toRadians(45)))),
|
||||
-height / 2 + offset + caseTolerance
|
||||
])
|
||||
|> angledLineToX({
|
||||
angle = -225,
|
||||
to = -width / 2 + offset + caseTolerance
|
||||
}, %)
|
||||
|> close()
|
||||
// |> hole(screenHole(plane), %)
|
||||
// |> hole(squareHolePattern(plane, .75, .125), %)
|
||||
// |> hole(zLogo(plane, [-.30, -1.825], .20), %)
|
||||
// |> hole(oLogo(plane, [-.075, -1.825], .20), %)
|
||||
// |> hole(oLogo2(plane, [-.075, -1.825], .20), %)
|
||||
// |> hole(oLogo(plane, [.175, -1.825], .20), %)
|
||||
// |> hole(oLogo2(plane, [.175, -1.825], .20), %)
|
||||
|
||||
extrude(sketch005, length = -0.0625)
|
||||
|> appearance(color = '#D0FF01', metalness = 0, roughness = 50)
|
@ -0,0 +1,14 @@
|
||||
---
|
||||
source: kcl/src/simulation_tests.rs
|
||||
description: Error from executing assembly_simplified_walkie.kcl
|
||||
---
|
||||
KCL Semantic error
|
||||
|
||||
× semantic: Error loading imported file. Open it to view more details.
|
||||
│ tests/assembly_simplified_walkie/talk-button.kcl: Modeling command failed:
|
||||
│ [ApiError { error_code: BadRequest, message: "Chamfer failed" }]
|
||||
╭─[21:1]
|
||||
20 │ // Import the talk button
|
||||
21 │ talkButton
|
||||
· ──────────
|
||||
╰────
|
@ -0,0 +1,42 @@
|
||||
// Global constants for the walkie talkie
|
||||
|
||||
// Set units
|
||||
@settings(defaultLengthUnit = in)
|
||||
|
||||
// body
|
||||
export height = 4
|
||||
export width = 2.5
|
||||
export thickness = 1
|
||||
export chamferLength = .325
|
||||
export offset = .125
|
||||
export screenWidth = 1.75
|
||||
export screenHeight = 1
|
||||
export screenYPosition = height / 2 - 0.75
|
||||
export screenDepth = -.0625
|
||||
export speakerBoxWidth = 1.25
|
||||
export speakerBoxHeight = 1.25
|
||||
|
||||
// antenna
|
||||
export antennaBaseWidth = .5
|
||||
export antennaBaseHeight = .25
|
||||
export antennaTopWidth = .30
|
||||
export antennaTopHeight = .05
|
||||
|
||||
// button
|
||||
export buttonWidth = .15
|
||||
export tolerance = 0.020
|
||||
export buttonHeight = screenHeight / 2 - tolerance
|
||||
export buttonThickness = .040
|
||||
|
||||
// case
|
||||
export squareHoleSideLength = 0.0625
|
||||
export caseTolerance = 0.010
|
||||
|
||||
// knob
|
||||
export knobDiameter = .5
|
||||
export knobHeight = .25
|
||||
export knobRadius = 0.050
|
||||
|
||||
// talk-button
|
||||
export talkButtonSideLength = 0.5
|
||||
export talkButtonHeight = 0.050
|
21
src/wasm-lib/kcl/tests/assembly_simplified_walkie/input.kcl
Normal file
21
src/wasm-lib/kcl/tests/assembly_simplified_walkie/input.kcl
Normal file
@ -0,0 +1,21 @@
|
||||
@settings(defaultLengthUnit = in)
|
||||
|
||||
|
||||
// Part of the Walkie Talkie
|
||||
// Import parts and constants
|
||||
import "case.kcl"
|
||||
import "talk-button.kcl" as talkButton
|
||||
import button from "button.kcl"
|
||||
import width, height, thickness, screenWidth, screenHeight, screenYPosition, tolerance from "globals.kcl"
|
||||
|
||||
// Import the case
|
||||
case
|
||||
|
||||
// Import the buttons
|
||||
button([
|
||||
-(screenWidth / 2 + tolerance),
|
||||
screenYPosition
|
||||
], 0, offsetPlane("XZ", offset = thickness))
|
||||
|
||||
// Import the talk button
|
||||
talkButton
|
198
src/wasm-lib/kcl/tests/assembly_simplified_walkie/ops.snap
Normal file
198
src/wasm-lib/kcl/tests/assembly_simplified_walkie/ops.snap
Normal file
@ -0,0 +1,198 @@
|
||||
---
|
||||
source: kcl/src/simulation_tests.rs
|
||||
description: Operations executed assembly_simplified_walkie.kcl
|
||||
---
|
||||
[
|
||||
{
|
||||
"labeledArgs": {
|
||||
"offset": {
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 1.0,
|
||||
"ty": {
|
||||
"type": "Default",
|
||||
"len": {
|
||||
"type": "Inches"
|
||||
},
|
||||
"angle": {
|
||||
"type": "Degrees"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sourceRange": [
|
||||
432,
|
||||
441,
|
||||
0
|
||||
]
|
||||
}
|
||||
},
|
||||
"name": "offsetPlane",
|
||||
"sourceRange": [
|
||||
405,
|
||||
442,
|
||||
0
|
||||
],
|
||||
"type": "StdLibCall",
|
||||
"unlabeledArg": {
|
||||
"value": {
|
||||
"type": "String",
|
||||
"value": "XZ"
|
||||
},
|
||||
"sourceRange": [
|
||||
417,
|
||||
421,
|
||||
0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "UserDefinedFunctionCall",
|
||||
"name": "button",
|
||||
"functionSourceRange": [
|
||||
1046,
|
||||
1759,
|
||||
5
|
||||
],
|
||||
"unlabeledArg": null,
|
||||
"labeledArgs": {},
|
||||
"sourceRange": [
|
||||
338,
|
||||
443,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"labeledArgs": {
|
||||
"data": {
|
||||
"value": {
|
||||
"type": "Plane",
|
||||
"artifact_id": "[uuid]"
|
||||
},
|
||||
"sourceRange": [
|
||||
1105,
|
||||
1110,
|
||||
5
|
||||
]
|
||||
}
|
||||
},
|
||||
"name": "startSketchOn",
|
||||
"sourceRange": [
|
||||
1091,
|
||||
1111,
|
||||
5
|
||||
],
|
||||
"type": "StdLibCall",
|
||||
"unlabeledArg": null
|
||||
},
|
||||
{
|
||||
"labeledArgs": {
|
||||
"length": {
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 0.04,
|
||||
"ty": {
|
||||
"type": "Default",
|
||||
"len": {
|
||||
"type": "Inches"
|
||||
},
|
||||
"angle": {
|
||||
"type": "Degrees"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sourceRange": [
|
||||
1526,
|
||||
1541,
|
||||
5
|
||||
]
|
||||
}
|
||||
},
|
||||
"name": "extrude",
|
||||
"sourceRange": [
|
||||
1495,
|
||||
1542,
|
||||
5
|
||||
],
|
||||
"type": "StdLibCall",
|
||||
"unlabeledArg": {
|
||||
"value": {
|
||||
"type": "Sketch",
|
||||
"value": {
|
||||
"artifactId": "[uuid]"
|
||||
}
|
||||
},
|
||||
"sourceRange": [
|
||||
1503,
|
||||
1515,
|
||||
5
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"labeledArgs": {
|
||||
"length": {
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 0.05,
|
||||
"ty": {
|
||||
"type": "Default",
|
||||
"len": {
|
||||
"type": "Inches"
|
||||
},
|
||||
"angle": {
|
||||
"type": "Degrees"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sourceRange": [
|
||||
1577,
|
||||
1581,
|
||||
5
|
||||
]
|
||||
},
|
||||
"tags": {
|
||||
"value": {
|
||||
"type": "Array",
|
||||
"value": [
|
||||
{
|
||||
"type": "Uuid",
|
||||
"value": "[uuid]"
|
||||
},
|
||||
{
|
||||
"type": "Uuid",
|
||||
"value": "[uuid]"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sourceRange": [
|
||||
1599,
|
||||
1686,
|
||||
5
|
||||
]
|
||||
}
|
||||
},
|
||||
"name": "chamfer",
|
||||
"sourceRange": [
|
||||
1550,
|
||||
1695,
|
||||
5
|
||||
],
|
||||
"type": "StdLibCall",
|
||||
"unlabeledArg": {
|
||||
"value": {
|
||||
"type": "Solid",
|
||||
"value": {
|
||||
"artifactId": "[uuid]"
|
||||
}
|
||||
},
|
||||
"sourceRange": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "UserDefinedFunctionReturn"
|
||||
}
|
||||
]
|
@ -0,0 +1,46 @@
|
||||
// Walkie talkie talk button
|
||||
|
||||
|
||||
// Set units
|
||||
@settings(defaultLengthUnit = in)
|
||||
|
||||
|
||||
// Import constants
|
||||
import width, thickness, talkButtonSideLength, talkButtonHeight from "globals.kcl"
|
||||
|
||||
talkButtonPlane = {
|
||||
plane = {
|
||||
origin = {
|
||||
x = width / 2,
|
||||
y = -thickness / 2,
|
||||
z = .5
|
||||
},
|
||||
xAxis = { x = 0, y = 1, z = 0 },
|
||||
yAxis = { x = 0, y = 0, z = 1 },
|
||||
zAxis = { x = 1, y = 0, z = 0 }
|
||||
}
|
||||
}
|
||||
|
||||
// Create the talk button sketch
|
||||
talkButtonSketch = startSketchOn(talkButtonPlane)
|
||||
|> startProfileAt([
|
||||
-talkButtonSideLength / 2,
|
||||
talkButtonSideLength / 2
|
||||
], %)
|
||||
|> xLine(talkButtonSideLength, %, $tag1)
|
||||
|> yLine(-talkButtonSideLength, %, $tag2)
|
||||
|> xLine(-talkButtonSideLength, %, $tag3)
|
||||
|> close(tag = $tag4)
|
||||
|
||||
// Create the talk button and apply fillets
|
||||
extrude(talkButtonSketch, length = talkButtonHeight)
|
||||
|> fillet(
|
||||
radius = 0.050,
|
||||
tags = [
|
||||
getNextAdjacentEdge(tag1),
|
||||
getNextAdjacentEdge(tag2),
|
||||
getNextAdjacentEdge(tag3),
|
||||
getNextAdjacentEdge(tag4)
|
||||
]
|
||||
)
|
||||
|> appearance(color = '#D0FF01', metalness = 90, roughness = 90)
|
Reference in New Issue
Block a user