Compare commits

..

4 Commits

Author SHA1 Message Date
df8ef799cb dont need to flush fillets on transform
Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-05-23 18:23:21 -07:00
678433d2b3 Bubble up the actual error message in the Text-to-CAD toast message (#7201)
So that users can see if they're blocked, for example.
2025-05-24 00:00:42 +00:00
30bd307931 [Fix]: Corrected camera's projection when engine idle reconnects (#7173)
* fix: implemented a fix to read from settings before restoring camera view and log if it desyncs

* fix: reverting testing code

* fix: always enable ortho scale enabled mode

* fix: fixed the ortho_scale_enabled boolean, do not touch it. Set it to true and never touch it again
2025-05-23 17:30:05 -04:00
08dfaba7f7 Updating the rail to modern practice (#7180)
* Updating the rail to modern practice

* rename 8020 to generic T-slot
2025-05-23 20:59:44 +00:00
31 changed files with 5798 additions and 13444 deletions

View File

@ -1,142 +0,0 @@
// 80/20 Rail
// An 80/20 extruded aluminum linear rail. T-slot profile adjustable by profile height, rail length, and origin position
// Set units
@settings(defaultLengthUnit = in, kclVersion = 1.0)
// Create a function to make the 80-20 rail
fn rail8020(originStart, railHeight, railLength) {
// Sketch side 1 of profile
sketch001 = startSketchOn(-XZ)
|> startProfile(at = [
originStart[0],
0.1 * railHeight + originStart[1]
])
|> arc(angleStart = 180, angleEnd = 270, radius = 0.1 * railHeight)
|> arc(angleStart = 180, angleEnd = 0, radius = 0.072 / 4 * railHeight)
|> xLine(length = 0.1 * railHeight)
|> arc(angleStart = 180, angleEnd = 0, radius = 0.072 / 4 * railHeight)
|> xLine(length = 0.06 * railHeight, tag = $edge1)
|> yLine(length = 0.087 * railHeight, tag = $edge2)
|> xLine(length = -0.183 * railHeight, tag = $edge3)
|> angledLine(angle = 45, endAbsoluteY = (1 - 0.356) / 2 * railHeight + originStart[1], tag = $edge4)
|> xLine(length = 0.232 * railHeight, tag = $edge5)
|> angledLine(angle = -45, endAbsoluteY = 0.087 * railHeight + originStart[1], tag = $edge6)
|> xLine(length = -0.183 * railHeight, tag = $edge7)
|> yLine(length = -0.087 * railHeight, tag = $edge8)
|> xLine(length = 0.06 * railHeight)
|> arc(angleStart = 180, angleEnd = 0, radius = 0.072 / 4 * railHeight)
|> xLine(length = 0.1 * railHeight)
|> arc(angleStart = 180, angleEnd = 0, radius = 0.072 / 4 * railHeight)
|> arc(angleStart = -90, angleEnd = 0, radius = 0.1 * railHeight)
// Sketch side 2 of profile
|> arc(angleStart = 270, angleEnd = 90, radius = 0.072 / 4 * railHeight)
|> yLine(length = 0.1 * railHeight)
|> arc(angleStart = 270, angleEnd = 90, radius = 0.072 / 4 * railHeight)
|> yLine(length = 0.06 * railHeight, tag = $edge9)
|> xLine(length = -0.087 * railHeight, tag = $edge10)
|> yLine(length = -0.183 * railHeight, tag = $edge11) // edge11
|> angledLine(angle = 135, endAbsoluteX = ((1 - 0.356) / 2 + 0.356) * railHeight + originStart[0], tag = $edge12) // edge12
|> yLine(length = 0.232 * railHeight, tag = $edge13) // 13
|> angledLine(angle = 45, endAbsoluteX = (1 - 0.087) * railHeight + originStart[0], tag = $edge14) // 14
|> yLine(length = -0.183 * railHeight, tag = $edge15) // 15
|> xLine(length = 0.087 * railHeight, tag = $edge16)
|> yLine(length = 0.06 * railHeight)
|> arc(angleStart = 270, angleEnd = 90, radius = 0.072 / 4 * railHeight)
|> yLine(length = 0.1 * railHeight)
|> arc(angleStart = 270, angleEnd = 90, radius = 0.072 / 4 * railHeight)
// Sketch side 3 of profile
|> arc(angleStart = 0, angleEnd = 90, radius = 0.1 * railHeight)
|> arc(angleStart = 0, angleEnd = -180, radius = 0.072 / 4 * railHeight)
|> xLine(length = -0.1 * railHeight)
|> arc(angleStart = 0, angleEnd = -180, radius = 0.072 / 4 * railHeight)
|> xLine(length = -0.06 * railHeight, tag = $edge17)
|> yLine(length = -0.087 * railHeight, tag = $edge18)
|> xLine(length = 0.183 * railHeight, tag = $edge19)
|> angledLine(angle = 45, endAbsoluteY = ((1 - 0.356) / 2 + 0.356) * railHeight + originStart[1], tag = $edge20)
|> xLine(length = -0.232 * railHeight, tag = $edge21)
|> angledLine(angle = 135, endAbsoluteY = (1 - 0.087) * railHeight + originStart[1], tag = $edge22)
|> xLine(length = 0.183 * railHeight, tag = $edge23)
|> yLine(length = 0.087 * railHeight, tag = $edge24)
|> xLine(length = -0.06 * railHeight)
|> arc(angleStart = 0, angleEnd = -180, radius = 0.072 / 4 * railHeight)
|> xLine(length = -0.1 * railHeight)
|> arc(angleStart = 0, angleEnd = -180, radius = 0.072 / 4 * railHeight)
|> arc(angleStart = 90, angleEnd = 180, radius = 0.1 * railHeight)
// Sketch side 4 of profile
|> arc(angleStart = 90, angleEnd = -90, radius = 0.072 / 4 * railHeight)
|> yLine(length = -0.1 * railHeight)
|> arc(angleStart = 90, angleEnd = -90, radius = 0.072 / 4 * railHeight)
|> yLine(length = -0.06 * railHeight, tag = $edge25)
|> xLine(length = 0.087 * railHeight, tag = $edge26)
|> yLine(length = 0.183 * railHeight, tag = $edge27)
|> angledLine(angle = 135, endAbsoluteX = (1 - 0.356) / 2 * railHeight + originStart[0], tag = $edge28)
|> yLine(length = -0.232 * railHeight, tag = $edge29)
|> angledLine(angle = 45, endAbsoluteX = 0.087 * railHeight + originStart[0], tag = $edge30)
|> yLine(length = 0.183 * railHeight, tag = $edge31)
|> xLine(length = -0.087 * railHeight, tag = $edge32)
|> yLine(length = -0.06 * railHeight)
|> arc(angleStart = 90, angleEnd = -90, radius = 0.072 / 4 * railHeight)
|> yLine(length = -0.1 * railHeight)
|> arc(angleStart = 90, angleEnd = -90, radius = 0.072 / 4 * railHeight)
|> close()
// Sketch center hole of profile
|> subtract2d(tool = circle(
center = [
.5 * railHeight + originStart[0],
.5 * railHeight + originStart[1]
],
radius = .205 * railHeight / 2,
))
|> extrude(length = railLength)
|> fillet(
radius = 0.06,
tags = [
getNextAdjacentEdge(edge3),
getNextAdjacentEdge(edge4),
getNextAdjacentEdge(edge5),
getNextAdjacentEdge(edge6),
getNextAdjacentEdge(edge11),
getNextAdjacentEdge(edge12),
getNextAdjacentEdge(edge13),
getNextAdjacentEdge(edge14),
getNextAdjacentEdge(edge19),
getNextAdjacentEdge(edge20),
getNextAdjacentEdge(edge21),
getNextAdjacentEdge(edge22),
getNextAdjacentEdge(edge27),
getNextAdjacentEdge(edge28),
getNextAdjacentEdge(edge29),
getNextAdjacentEdge(edge30)
],
)
|> fillet(
radius = 0.03,
tags = [
getNextAdjacentEdge(edge1),
getNextAdjacentEdge(edge2),
getNextAdjacentEdge(edge7),
getNextAdjacentEdge(edge8),
getNextAdjacentEdge(edge9),
getNextAdjacentEdge(edge10),
getNextAdjacentEdge(edge15),
getNextAdjacentEdge(edge16),
getNextAdjacentEdge(edge17),
getNextAdjacentEdge(edge18),
getNextAdjacentEdge(edge23),
getNextAdjacentEdge(edge24),
getNextAdjacentEdge(edge25),
getNextAdjacentEdge(edge26),
getNextAdjacentEdge(edge31),
getNextAdjacentEdge(edge32)
],
)
return sketch001
}
// Generate one adjustable rail of 80/20
rail8020(originStart = [0, 0], railHeight = 1.5, railLength = 48)

View File

@ -23,8 +23,6 @@ KCL samples conform to a set of style guidelines to ensure consistency and reada
When you submit a PR to add or modify KCL samples, images will be generated and added to the repository automatically.
---
#### [80-20-rail](80-20-rail/main.kcl) ([screenshot](screenshots/80-20-rail.png))
[![80-20-rail](screenshots/80-20-rail.png)](80-20-rail/main.kcl)
#### [axial-fan](axial-fan/main.kcl) ([screenshot](screenshots/axial-fan.png))
[![axial-fan](screenshots/axial-fan.png)](axial-fan/main.kcl)
#### [ball-bearing](ball-bearing/main.kcl) ([screenshot](screenshots/ball-bearing.png))
@ -143,6 +141,8 @@ When you submit a PR to add or modify KCL samples, images will be generated and
[![spur-reduction-gearset](screenshots/spur-reduction-gearset.png)](spur-reduction-gearset/main.kcl)
#### [surgical-drill-guide](surgical-drill-guide/main.kcl) ([screenshot](screenshots/surgical-drill-guide.png))
[![surgical-drill-guide](screenshots/surgical-drill-guide.png)](surgical-drill-guide/main.kcl)
#### [t-slot-rail](t-slot-rail/main.kcl) ([screenshot](screenshots/t-slot-rail.png))
[![t-slot-rail](screenshots/t-slot-rail.png)](t-slot-rail/main.kcl)
#### [telemetry-antenna](telemetry-antenna/main.kcl) ([screenshot](screenshots/telemetry-antenna.png))
[![telemetry-antenna](screenshots/telemetry-antenna.png)](telemetry-antenna/main.kcl)
#### [thermal-block-insert](thermal-block-insert/main.kcl) ([screenshot](screenshots/thermal-block-insert.png))

View File

@ -1,14 +1,4 @@
[
{
"file": "main.kcl",
"pathFromProjectDirectoryToFirstFile": "80-20-rail/main.kcl",
"multipleFiles": false,
"title": "80/20 Rail",
"description": "An 80/20 extruded aluminum linear rail. T-slot profile adjustable by profile height, rail length, and origin position",
"files": [
"main.kcl"
]
},
{
"file": "main.kcl",
"pathFromProjectDirectoryToFirstFile": "axial-fan/main.kcl",
@ -632,6 +622,16 @@
"main.kcl"
]
},
{
"file": "main.kcl",
"pathFromProjectDirectoryToFirstFile": "t-slot-rail/main.kcl",
"multipleFiles": false,
"title": "T-Slotted Framing Rail",
"description": "A T-slotted framing rail, or T-slot extrusion, is a rectangular or square aluminum profile with a \"T\" shaped slot along one or more sides. These slots allow for easy attachment of various hardware components like brackets, connectors, and fasteners, making it a versatile and customizable framing system.",
"files": [
"main.kcl"
]
},
{
"file": "main.kcl",
"pathFromProjectDirectoryToFirstFile": "telemetry-antenna/main.kcl",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@ -0,0 +1,58 @@
// T-Slotted Framing Rail
// A T-slotted framing rail, or T-slot extrusion, is a rectangular or square aluminum profile with a "T" shaped slot along one or more sides. These slots allow for easy attachment of various hardware components like brackets, connectors, and fasteners, making it a versatile and customizable framing system.
// Set units
@settings(defaultLengthUnit = in, kclVersion = 1.0)
// Define parameters
interiorRadius = 0.01
scoreDepth = 0.018
arcEnd = 0.0275
holeDiameter = 0.262
fn railTslot(railHeight, railLength) {
// Sketch one inner leg of the extruded rail
railProfile = startSketchOn(XZ)
|> startProfile(at = [0.5, (1 - 0.356) / 2])
|> xLine(length = -0.08)
|> tangentialArc(angle = 45, radius = .09)
|> angledLine(angle = 45, endAbsoluteY = 0.113)
|> tangentialArc(angle = 135, radius = interiorRadius)
|> xLine(endAbsolute = .5 - (.320 / 2) - interiorRadius)
|> tangentialArc(angle = -90, radius = interiorRadius)
|> yLine(endAbsolute = interiorRadius)
|> tangentialArc(angle = -90, radius = interiorRadius)
|> xLine(length = -0.03)
|> arc(angleStart = 0, angleEnd = 180, radius = scoreDepth)
|> xLine(length = -0.1)
|> arc(angleStart = 0, angleEnd = 180, radius = scoreDepth)
|> xLine(length = -0.03)
|> tangentialArc(endAbsolute = [arcEnd, arcEnd])
// Mirror the sketch about the diagonal to complete the leg. Then mirror across the center of the profile in the horizontal and vertical directions. Then close the sketch
|> mirror2d(axis = {
direction = [1.0, 1.0],
origin = [0.0, 0.0]
})
|> mirror2d(axis = {
direction = [1.0, 0.0],
origin = [0.0, 0.5]
})
|> mirror2d(axis = {
direction = [0.0, 1.0],
origin = [0.5, 0.0]
})
|> close()
// Sketch a dimensioned hole in the center of the profile
|> subtract2d(tool = circle(center = [railHeight / 2, railHeight / 2], radius = holeDiameter / 2))
// Scale the entire sketch by a factor of the rail height, then extrude
|> scale(x = railHeight, z = railHeight)
|> extrude(length = -railLength)
return railProfile
}
// Generate one rail using the rail function
railTslot(railHeight = 1.5, railLength = 2ft)

View File

@ -166,12 +166,6 @@ async fn inner_scale(
exec_state: &mut ExecState,
args: Args,
) -> Result<SolidOrSketchOrImportedGeometry, KclError> {
// If we have a solid, flush the fillets and chamfers.
// Only transforms needs this, it is very odd, see: https://github.com/KittyCAD/modeling-app/issues/5880
if let SolidOrSketchOrImportedGeometry::SolidSet(solids) = &objects {
args.flush_batch_for_solids(exec_state, solids).await?;
}
let mut objects = objects.clone();
for object_id in objects.ids(&args.ctx).await? {
let id = exec_state.next_uuid();
@ -396,12 +390,6 @@ async fn inner_translate(
exec_state: &mut ExecState,
args: Args,
) -> Result<SolidOrSketchOrImportedGeometry, KclError> {
// If we have a solid, flush the fillets and chamfers.
// Only transforms needs this, it is very odd, see: https://github.com/KittyCAD/modeling-app/issues/5880
if let SolidOrSketchOrImportedGeometry::SolidSet(solids) = &objects {
args.flush_batch_for_solids(exec_state, solids).await?;
}
let mut objects = objects.clone();
for object_id in objects.ids(&args.ctx).await? {
let id = exec_state.next_uuid();
@ -804,12 +792,6 @@ async fn inner_rotate(
exec_state: &mut ExecState,
args: Args,
) -> Result<SolidOrSketchOrImportedGeometry, KclError> {
// If we have a solid, flush the fillets and chamfers.
// Only transforms needs this, it is very odd, see: https://github.com/KittyCAD/modeling-app/issues/5880
if let SolidOrSketchOrImportedGeometry::SolidSet(solids) = &objects {
args.flush_batch_for_solids(exec_state, solids).await?;
}
let mut objects = objects.clone();
for object_id in objects.ids(&args.ctx).await? {
let id = exec_state.next_uuid();

File diff suppressed because it is too large Load Diff

View File

@ -1,365 +0,0 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Operations executed 80-20-rail.kcl
---
[
{
"type": "StdLibCall",
"name": "startSketchOn",
"unlabeledArg": {
"value": {
"type": "Plane",
"artifact_id": "[uuid]"
},
"sourceRange": []
},
"labeledArgs": {},
"sourceRange": []
},
{
"type": "StdLibCall",
"name": "subtract2d",
"unlabeledArg": {
"value": {
"type": "Sketch",
"value": {
"artifactId": "[uuid]"
}
},
"sourceRange": []
},
"labeledArgs": {
"tool": {
"value": {
"type": "Sketch",
"value": {
"artifactId": "[uuid]"
}
},
"sourceRange": []
}
},
"sourceRange": []
},
{
"type": "StdLibCall",
"name": "extrude",
"unlabeledArg": {
"value": {
"type": "Sketch",
"value": {
"artifactId": "[uuid]"
}
},
"sourceRange": []
},
"labeledArgs": {
"length": {
"value": {
"type": "Number",
"value": 48.0,
"ty": {
"type": "Default",
"len": {
"type": "Inches"
},
"angle": {
"type": "Degrees"
}
}
},
"sourceRange": []
}
},
"sourceRange": []
},
{
"type": "StdLibCall",
"name": "fillet",
"unlabeledArg": {
"value": {
"type": "Solid",
"value": {
"artifactId": "[uuid]"
}
},
"sourceRange": []
},
"labeledArgs": {
"radius": {
"value": {
"type": "Number",
"value": 0.06,
"ty": {
"type": "Default",
"len": {
"type": "Inches"
},
"angle": {
"type": "Degrees"
}
}
},
"sourceRange": []
},
"tags": {
"value": {
"type": "Array",
"value": [
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
}
]
},
"sourceRange": []
}
},
"sourceRange": []
},
{
"type": "StdLibCall",
"name": "fillet",
"unlabeledArg": {
"value": {
"type": "Solid",
"value": {
"artifactId": "[uuid]"
}
},
"sourceRange": []
},
"labeledArgs": {
"radius": {
"value": {
"type": "Number",
"value": 0.03,
"ty": {
"type": "Default",
"len": {
"type": "Inches"
},
"angle": {
"type": "Degrees"
}
}
},
"sourceRange": []
},
"tags": {
"value": {
"type": "Array",
"value": [
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
},
{
"type": "Uuid",
"value": "[uuid]"
}
]
},
"sourceRange": []
}
},
"sourceRange": []
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "rail8020",
"functionSourceRange": [],
"unlabeledArg": null,
"labeledArgs": {
"originStart": {
"value": {
"type": "Array",
"value": [
{
"type": "Number",
"value": 0.0,
"ty": {
"type": "Default",
"len": {
"type": "Inches"
},
"angle": {
"type": "Degrees"
}
}
},
{
"type": "Number",
"value": 0.0,
"ty": {
"type": "Default",
"len": {
"type": "Inches"
},
"angle": {
"type": "Degrees"
}
}
}
]
},
"sourceRange": []
},
"railHeight": {
"value": {
"type": "Number",
"value": 1.5,
"ty": {
"type": "Default",
"len": {
"type": "Inches"
},
"angle": {
"type": "Degrees"
}
}
},
"sourceRange": []
},
"railLength": {
"value": {
"type": "Number",
"value": 48.0,
"ty": {
"type": "Default",
"len": {
"type": "Inches"
},
"angle": {
"type": "Degrees"
}
}
},
"sourceRange": []
}
}
},
"sourceRange": []
},
{
"type": "GroupEnd"
}
]

View File

@ -1,10 +0,0 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Variables in memory after executing 80-20-rail.kcl
---
{
"rail8020": {
"type": "Function",
"value": null
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

View File

@ -366,114 +366,114 @@ flowchart LR
11 ---- 74
26 --- 75
26 x--> 108
26 --- 138
26 --- 170
26 --- 131
26 --- 163
27 --- 76
27 x--> 108
27 --- 124
27 --- 156
27 --- 132
27 --- 164
28 --- 77
28 x--> 108
28 --- 137
28 --- 169
28 --- 116
28 --- 148
29 --- 78
29 x--> 108
29 --- 133
29 --- 165
29 --- 134
29 --- 166
30 --- 79
30 x--> 108
30 --- 116
30 --- 148
30 --- 120
30 --- 152
31 --- 80
31 x--> 108
31 --- 115
31 --- 147
31 --- 136
31 --- 168
32 --- 81
32 x--> 108
32 --- 118
32 --- 150
32 --- 123
32 --- 155
33 --- 82
33 x--> 108
33 --- 134
33 --- 166
33 --- 129
33 --- 161
34 --- 83
34 x--> 108
34 --- 129
34 --- 161
34 --- 114
34 --- 146
35 --- 84
35 x--> 108
35 --- 127
35 --- 159
35 --- 117
35 --- 149
36 --- 85
36 x--> 108
36 --- 132
36 --- 164
36 --- 115
36 --- 147
37 --- 86
37 x--> 108
37 --- 122
37 --- 154
37 --- 126
37 --- 158
38 --- 87
38 x--> 108
38 --- 123
38 --- 155
38 --- 130
38 --- 162
39 --- 88
39 x--> 108
39 --- 131
39 --- 163
39 --- 122
39 --- 154
40 --- 89
40 x--> 108
40 --- 119
40 --- 151
40 --- 127
40 --- 159
41 --- 90
41 x--> 108
41 --- 130
41 --- 162
41 --- 125
41 --- 157
42 --- 91
42 x--> 108
42 --- 114
42 --- 146
42 --- 135
42 --- 167
43 --- 92
43 x--> 108
43 --- 125
43 --- 157
43 --- 119
43 --- 151
44 --- 93
44 x--> 108
44 --- 121
44 --- 153
44 --- 118
44 --- 150
45 --- 94
45 x--> 108
45 --- 135
45 --- 167
45 --- 121
45 --- 153
46 --- 95
46 x--> 108
46 --- 120
46 --- 152
46 --- 138
46 --- 170
47 --- 96
47 x--> 108
47 --- 126
47 --- 158
47 --- 128
47 --- 160
48 --- 97
48 x--> 108
48 --- 117
48 --- 149
48 --- 133
48 --- 165
49 --- 98
49 x--> 108
49 --- 113
49 --- 145
49 --- 137
49 --- 169
50 --- 99
50 x--> 108
50 --- 136
50 --- 168
50 --- 139
50 --- 171
51 --- 100
51 x--> 108
51 --- 128
51 --- 160
51 --- 124
51 --- 156
52 --- 101
52 x--> 108
52 --- 139
52 --- 171
52 --- 113
52 --- 145
61 --- 102
61 x--> 109
61 x--> 110
61 --- 140
61 --- 172
63 --- 103
@ -594,87 +594,87 @@ flowchart LR
74 --- 174
74 --- 175
74 --- 176
75 --- 138
75 --- 170
171 <--x 75
76 --- 124
76 --- 156
157 <--x 76
77 --- 137
77 --- 169
170 <--x 77
78 --- 133
78 --- 165
166 <--x 78
79 --- 116
79 --- 148
149 <--x 79
80 --- 115
80 --- 147
148 <--x 80
81 --- 118
81 --- 150
151 <--x 81
82 --- 134
82 --- 166
167 <--x 82
83 --- 129
83 --- 161
162 <--x 83
84 --- 127
84 --- 159
160 <--x 84
85 --- 132
85 --- 164
165 <--x 85
86 --- 122
86 --- 154
155 <--x 86
87 --- 123
87 --- 155
156 <--x 87
88 --- 131
88 --- 163
164 <--x 88
89 --- 119
89 --- 151
152 <--x 89
90 --- 130
90 --- 162
163 <--x 90
91 --- 114
91 --- 146
147 <--x 91
92 --- 125
92 --- 157
158 <--x 92
93 --- 121
93 --- 153
154 <--x 93
94 --- 135
94 --- 167
168 <--x 94
95 --- 120
95 --- 152
153 <--x 95
96 --- 126
96 --- 158
159 <--x 96
97 --- 117
97 --- 149
150 <--x 97
98 --- 113
98 --- 145
146 <--x 98
99 --- 136
99 --- 168
169 <--x 99
100 --- 128
100 --- 160
161 <--x 100
101 --- 139
145 <--x 101
101 --- 171
75 --- 131
75 --- 163
164 <--x 75
76 --- 132
76 --- 164
165 <--x 76
77 --- 116
77 --- 148
149 <--x 77
78 --- 134
78 --- 166
167 <--x 78
79 --- 120
79 --- 152
153 <--x 79
80 --- 136
80 --- 168
169 <--x 80
81 --- 123
81 --- 155
156 <--x 81
82 --- 129
82 --- 161
162 <--x 82
83 --- 114
83 --- 146
147 <--x 83
84 --- 117
84 --- 149
150 <--x 84
85 --- 115
85 --- 147
148 <--x 85
86 --- 126
86 --- 158
159 <--x 86
87 --- 130
87 --- 162
163 <--x 87
88 --- 122
88 --- 154
155 <--x 88
89 --- 127
89 --- 159
160 <--x 89
90 --- 125
90 --- 157
158 <--x 90
91 --- 135
91 --- 167
168 <--x 91
92 --- 119
92 --- 151
152 <--x 92
93 --- 118
93 --- 150
151 <--x 93
94 --- 121
94 --- 153
154 <--x 94
95 --- 138
95 --- 170
171 <--x 95
96 --- 128
96 --- 160
161 <--x 96
97 --- 133
97 --- 165
166 <--x 97
98 --- 137
98 --- 169
170 <--x 98
99 --- 139
145 <--x 99
99 --- 171
100 --- 124
100 --- 156
157 <--x 100
101 --- 113
101 --- 145
146 <--x 101
102 --- 140
102 --- 172
103 --- 144
@ -689,7 +689,7 @@ flowchart LR
106 --- 141
106 --- 173
174 <--x 106
140 <--x 110
140 <--x 109
141 <--x 111
142 <--x 111
143 <--x 111

View File

@ -111,9 +111,9 @@ flowchart LR
8 --- 19
8 --- 20
8 ---- 25
12 --- 32
12 <--x 32
12 <--x 33
12 <--x 34
12 --- 34
13 --- 31
13 x--> 35
13 --- 39

View File

@ -0,0 +1,620 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Artifact commands t-slot-rail.kcl
---
[
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "edge_lines_visible",
"hidden": false
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "object_visible",
"object_id": "[uuid]",
"hidden": true
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "object_visible",
"object_id": "[uuid]",
"hidden": true
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "make_plane",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"x_axis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"y_axis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"size": 60.0,
"clobber": false,
"hide": true
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "enable_sketch_mode",
"entity_id": "[uuid]",
"ortho": false,
"animated": false,
"adjust_camera": false,
"planar_normal": {
"x": 0.0,
"y": -1.0,
"z": 0.0
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "move_path_pen",
"path": "[uuid]",
"to": {
"x": 12.7,
"y": 8.1788,
"z": 0.0
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "sketch_mode_disable"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "start_path"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "line",
"end": {
"x": -2.032,
"y": 0.0,
"z": 0.0
},
"relative": true
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "tangential_arc",
"radius": 2.2859999999999996,
"offset": {
"unit": "degrees",
"value": 45.0
}
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "line",
"end": {
"x": 4.4125,
"y": 2.8702,
"z": 0.0
},
"relative": false
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "tangential_arc",
"radius": 0.254,
"offset": {
"unit": "degrees",
"value": 135.0
}
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "line",
"end": {
"x": 8.382,
"y": 2.4366,
"z": 0.0
},
"relative": false
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "tangential_arc",
"radius": 0.254,
"offset": {
"unit": "degrees",
"value": -90.0
}
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "line",
"end": {
"x": 8.636,
"y": 0.254,
"z": 0.0
},
"relative": false
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "tangential_arc",
"radius": 0.254,
"offset": {
"unit": "degrees",
"value": -90.0
}
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "line",
"end": {
"x": -0.762,
"y": 0.0,
"z": 0.0
},
"relative": true
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "arc",
"center": {
"x": 7.1628,
"y": -0.0
},
"radius": 0.45719999999999994,
"start": {
"unit": "degrees",
"value": 0.0
},
"end": {
"unit": "degrees",
"value": 180.0
},
"relative": false
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "line",
"end": {
"x": -2.54,
"y": 0.0,
"z": 0.0
},
"relative": true
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "arc",
"center": {
"x": 3.7084,
"y": 0.0
},
"radius": 0.45719999999999994,
"start": {
"unit": "degrees",
"value": 0.0
},
"end": {
"unit": "degrees",
"value": 180.0
},
"relative": false
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "line",
"end": {
"x": -0.762,
"y": 0.0,
"z": 0.0
},
"relative": true
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "tangential_arc_to",
"to": {
"x": -1.7907,
"y": 0.6985,
"z": 0.0
},
"angle_snap_increment": null
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "entity_get_all_child_uuids",
"entity_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "entity_mirror",
"ids": [
"[uuid]"
],
"axis": {
"x": 25.4,
"y": 25.4,
"z": 0.0
},
"point": {
"x": 0.0,
"y": 0.0,
"z": 0.0
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "entity_get_all_child_uuids",
"entity_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "entity_mirror",
"ids": [
"[uuid]"
],
"axis": {
"x": 25.4,
"y": 0.0,
"z": 0.0
},
"point": {
"x": 0.0,
"y": 12.7,
"z": 0.0
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "entity_get_all_child_uuids",
"entity_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "entity_mirror",
"ids": [
"[uuid]"
],
"axis": {
"x": 0.0,
"y": 25.4,
"z": 0.0
},
"point": {
"x": 12.7,
"y": 0.0,
"z": 0.0
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "close_path",
"path_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "object_visible",
"object_id": "[uuid]",
"hidden": true
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "solid2d_add_hole",
"object_id": "[uuid]",
"hole_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "close_path",
"path_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "enable_sketch_mode",
"entity_id": "[uuid]",
"ortho": false,
"animated": false,
"adjust_camera": false,
"planar_normal": {
"x": 0.0,
"y": -1.0,
"z": 0.0
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "arc",
"center": {
"x": 19.05,
"y": 19.05
},
"radius": 3.3274,
"start": {
"unit": "degrees",
"value": 0.0
},
"end": {
"unit": "degrees",
"value": 360.0
},
"relative": false
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "move_path_pen",
"path": "[uuid]",
"to": {
"x": 22.3774,
"y": 19.05,
"z": 0.0
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "sketch_mode_disable"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "start_path"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "set_object_transform",
"object_id": "[uuid]",
"transforms": [
{
"translate": null,
"rotate_rpy": null,
"rotate_angle_axis": null,
"scale": {
"property": {
"x": 1.5,
"y": 1.0,
"z": 1.5
},
"set": false,
"is_local": true
}
}
]
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "enable_sketch_mode",
"entity_id": "[uuid]",
"ortho": false,
"animated": false,
"adjust_camera": false,
"planar_normal": {
"x": 0.0,
"y": -1.0,
"z": 0.0
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "extrude",
"target": "[uuid]",
"distance": -609.5999999999999,
"faces": null,
"opposite": "None"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "object_bring_to_front",
"object_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "sketch_mode_disable"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "solid3d_get_adjacency_info",
"object_id": "[uuid]",
"edge_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "solid3d_get_extrusion_face_info",
"object_id": "[uuid]",
"edge_id": "[uuid]"
}
}
]

View File

@ -1,6 +1,6 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Artifact graph flowchart 80-20-rail.kcl
description: Artifact graph flowchart t-slot-rail.kcl
extension: md
snapshot_kind: binary
---

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,115 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Operations executed t-slot-rail.kcl
---
[
{
"type": "StdLibCall",
"name": "startSketchOn",
"unlabeledArg": {
"value": {
"type": "Plane",
"artifact_id": "[uuid]"
},
"sourceRange": []
},
"labeledArgs": {},
"sourceRange": []
},
{
"type": "StdLibCall",
"name": "subtract2d",
"unlabeledArg": {
"value": {
"type": "Sketch",
"value": {
"artifactId": "[uuid]"
}
},
"sourceRange": []
},
"labeledArgs": {
"tool": {
"value": {
"type": "Sketch",
"value": {
"artifactId": "[uuid]"
}
},
"sourceRange": []
}
},
"sourceRange": []
},
{
"type": "StdLibCall",
"name": "extrude",
"unlabeledArg": {
"value": {
"type": "Sketch",
"value": {
"artifactId": "[uuid]"
}
},
"sourceRange": []
},
"labeledArgs": {
"length": {
"value": {
"type": "Number",
"value": -2.0,
"ty": {
"type": "Known",
"type": "Length",
"type": "Feet"
}
},
"sourceRange": []
}
},
"sourceRange": []
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "railTslot",
"functionSourceRange": [],
"unlabeledArg": null,
"labeledArgs": {
"railHeight": {
"value": {
"type": "Number",
"value": 1.5,
"ty": {
"type": "Default",
"len": {
"type": "Inches"
},
"angle": {
"type": "Degrees"
}
}
},
"sourceRange": []
},
"railLength": {
"value": {
"type": "Number",
"value": 2.0,
"ty": {
"type": "Known",
"type": "Length",
"type": "Feet"
}
},
"sourceRange": []
}
}
},
"sourceRange": []
},
{
"type": "GroupEnd"
}
]

View File

@ -0,0 +1,62 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Variables in memory after executing t-slot-rail.kcl
---
{
"arcEnd": {
"type": "Number",
"value": 0.0275,
"ty": {
"type": "Default",
"len": {
"type": "Inches"
},
"angle": {
"type": "Degrees"
}
}
},
"holeDiameter": {
"type": "Number",
"value": 0.262,
"ty": {
"type": "Default",
"len": {
"type": "Inches"
},
"angle": {
"type": "Degrees"
}
}
},
"interiorRadius": {
"type": "Number",
"value": 0.01,
"ty": {
"type": "Default",
"len": {
"type": "Inches"
},
"angle": {
"type": "Degrees"
}
}
},
"railTslot": {
"type": "Function",
"value": null
},
"scoreDepth": {
"type": "Number",
"value": 0.018,
"ty": {
"type": "Default",
"len": {
"type": "Inches"
},
"angle": {
"type": "Degrees"
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@ -139,7 +139,7 @@ flowchart LR
15 --- 42
15 --- 49
18 --- 32
18 x--> 35
18 x--> 36
18 --- 43
18 --- 50
23 --- 26
@ -194,5 +194,5 @@ flowchart LR
40 <--x 34
41 <--x 34
42 <--x 34
43 <--x 36
43 <--x 35
```

View File

@ -87,11 +87,11 @@ flowchart LR
8 ---- 20
8 --- 21
12 <--x 22
12 --- 23
12 <--x 24
12 <--x 23
12 --- 24
16 <--x 25
16 --- 26
16 <--x 27
16 <--x 26
16 --- 27
19 --- 22
19 --- 23
19 --- 24

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 60 KiB

View File

@ -43,6 +43,7 @@ import {
uuidv4,
} from '@src/lib/utils'
import { deg2Rad } from '@src/lib/utils2d'
import type { SettingsType } from '@src/lib/settings/initialSettings'
const ORTHOGRAPHIC_CAMERA_SIZE = 20
const FRAMES_TO_ANIMATE_IN = 30
@ -124,6 +125,8 @@ export class CameraControls {
interactionGuards: MouseGuard = cameraMouseDragGuards.Zoo
isFovAnimationInProgress = false
perspectiveFovBeforeOrtho = 45
// TODO: proper dependency injection
getSettings: (() => SettingsType) | null = null
// NOTE: Duplicated state across Provider and singleton. Mapped from settingsMachine
_setting_allowOrbitInSketchMode = false
@ -964,8 +967,50 @@ export class CameraControls {
})
}
/**
* A helper function that will override this.oldCameraState
* with the current setting's camera projection. If these are desynced
* that is okay but when the camera restores we want the user to be in the correct
* camera projection which is the settings value. Not this old state.
*
* Gotcha: This is not to be confused with Named Views, those have correct state.
*/
overrideOldCameraStateToPreventDesync() {
if (!this.getSettings) {
return
}
// Engine idle disconnection happened, we saved off the camera state
// If the settings camera projection is different from the saved camera state we need to override it.
const settings = this.getSettings()
const cameraProjection = settings.modeling.cameraProjection.current
const isOrtho = cameraProjection === 'orthographic' ? true : false
if (this.oldCameraState) {
// Leave a log to know when this desyncs
console.log(`restoring camera projection setting:${cameraProjection}`)
console.log(
`oldCameraState projection:${isOrtho ? 'orthographic' : 'perspective'}, ortho_scaled_enabled:${this.oldCameraState.ortho_scale_enabled}`
)
if (this.oldCameraState.is_ortho !== isOrtho) {
console.log(
'oldCameraState is_ortho desynced',
this.oldCameraState.is_ortho,
isOrtho
)
}
this.oldCameraState.is_ortho = isOrtho
// Always keep this enabled!
this.oldCameraState.ortho_scale_enabled = true
}
}
async restoreRemoteCameraStateAndTriggerSync() {
if (this.oldCameraState) {
// Always write settings.modeling.cameraProjection to the restored camera view
this.overrideOldCameraStateToPreventDesync()
await this.engineCommandManager.sendSceneCommand({
type: 'modeling_cmd_req',
cmd_id: uuidv4(),

View File

@ -1,5 +1,5 @@
[
"80-20-rail",
"t-slot-rail",
"parametric-bearing-pillow-block",
"ball-bearing",
"bracket",

View File

@ -206,6 +206,11 @@ export const getSettings = () => {
const { currentProject: _, ...settings } = settingsActor.getSnapshot().context
return settings
}
// These are all late binding because of their circular dependency.
// TODO: proper dependency injection.
sceneInfra.camControls.getSettings = getSettings
export const useSettings = () =>
useSelector(settingsActor, (state) => {
// We have to peel everything that isn't settings off

View File

@ -15,7 +15,7 @@ import {
SystemIOMachineEvents,
waitForIdleState,
} from '@src/machines/systemIO/utils'
import { reportRejection } from '@src/lib/trap'
import { err, reportRejection } from '@src/lib/trap'
import { toSync } from '@src/lib/utils'
import { getAllSubDirectoriesAtProjectRoot } from '@src/machines/systemIO/snapshotContext'
import { joinOSPaths } from '@src/lib/paths'
@ -120,12 +120,15 @@ export async function submitAndAwaitTextToKclSystemIO({
return value
})
.catch((error) => {
showFailureToast('Failed to submit to Text-to-CAD API')
const message = err(error)
? error.message
: 'Failed to submit to Text-to-CAD API'
showFailureToast(message)
return error
})
if (textToCadQueued instanceof Error) {
showFailureToast('Failed to submit to Text-to-CAD API')
if (err(textToCadQueued)) {
showFailureToast(textToCadQueued.message)
return
}

View File

@ -29,7 +29,7 @@ export function isErr<T>(value: ExcludeErr<T> | Error): value is Error {
return value instanceof Error
}
// Used to bubble errors up
/** Used to bubble errors up */
export function err<T>(value: ExcludeErr<T> | Error): value is Error {
if (!isErr(value)) {
return false

View File

@ -648,7 +648,8 @@ export async function engineViewIsometricWithoutGeometryPresent({
fov_y: 45,
ortho_scale_factor: 1.4063792,
is_ortho: cameraProjection !== 'perspective',
ortho_scale_enabled: cameraProjection !== 'perspective',
// always keep this enabled
ortho_scale_enabled: true,
world_coord_system: 'right_handed_up_z',
}
await engineCommandManager.sendSceneCommand({