Scoped tags (#2941)

* start of scoped tags

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* add the tags to the sketch group context

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* scoped tags

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* update docs

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix tests

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* scoped

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix;

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2024-07-05 16:53:13 -07:00
committed by GitHub
parent 5701616f3e
commit a85c1a9375
65 changed files with 6343 additions and 110 deletions

View File

@ -1,6 +1,7 @@
// A mounting bracket for the Focusrite Scarlett Solo audio interface
// This is a bracket that holds an audio device underneath a desk or shelf. The audio device has dimensions of 144mm wide, 80mm length and 45mm depth with fillets of 6mm. This mounting bracket is designed to be 3D printed with PLA material
// define constants in mm
const radius = 6.0
const width = 144.0
@ -16,10 +17,10 @@ const tabThk = 4
fn rectShape = (pos, w, l) => {
const rr = startSketchOn('xy')
|> startProfileAt([pos[0] - (w / 2), pos[1] - (l / 2)], %)
|> lineTo([pos[0] + w / 2, pos[1] - (l / 2)], %, "edge01")
|> lineTo([pos[0] + w / 2, pos[1] + l / 2], %, "edge02")
|> lineTo([pos[0] - (w / 2), pos[1] + l / 2], %, "edge03")
|> close(%, "edge04")
|> lineTo([pos[0] + w / 2, pos[1] - (l / 2)], %, $edge01)
|> lineTo([pos[0] + w / 2, pos[1] + l / 2], %, $edge02)
|> lineTo([pos[0] - (w / 2), pos[1] + l / 2], %, $edge03)
|> close(%, $edge04)
return rr
}
@ -37,27 +38,28 @@ const bracketPlane = {
fn bracketSketch = (w, d, t) => {
const s = startSketchOn(bracketPlane)
|> startProfileAt([-w / 2 - t, d + t], %)
|> lineTo([-w / 2 - t, -t], %, "edge1")
|> lineTo([w / 2 + t, -t], %, "edge2")
|> lineTo([w / 2 + t, d + t], %, "edge3")
|> lineTo([w / 2, d + t], %, "edge4")
|> lineTo([w / 2, 0], %, "edge5")
|> lineTo([-w / 2, 0], %, "edge6")
|> lineTo([-w / 2, d + t], %, "edge7")
|> close(%, "edge8")
|> lineTo([-w / 2 - t, -t], %, $edge1)
|> lineTo([w / 2 + t, -t], %, $edge2)
|> lineTo([w / 2 + t, d + t], %, $edge3)
|> lineTo([w / 2, d + t], %, $edge4)
|> lineTo([w / 2, 0], %, $edge5)
|> lineTo([-w / 2, 0], %, $edge6)
|> lineTo([-w / 2, d + t], %, $edge7)
|> close(%, $edge8)
return s
}
// build the body of the bracket
const bracketBody = bracketSketch(width, depth, thk)
const bs = bracketSketch(width, depth, thk)
const bracketBody = bs
|> extrude(length + 2 * thk, %)
|> fillet({
radius: radius,
tags: [
getNextAdjacentEdge("edge7", %),
getNextAdjacentEdge("edge2", %),
getNextAdjacentEdge("edge3", %),
getNextAdjacentEdge("edge6", %)
getNextAdjacentEdge(bs.tags.edge7, %),
getNextAdjacentEdge(bs.tags.edge2, %),
getNextAdjacentEdge(bs.tags.edge3, %),
getNextAdjacentEdge(bs.tags.edge6, %)
]
}, %)
@ -74,10 +76,10 @@ const tabPlane = {
// build the tabs of the mounting bracket (right side)
const tabsR = startSketchOn(tabPlane)
|> startProfileAt([width / 2 + thk, length / 2 + thk], %)
|> line([tabWidth, -tabLength / 3], %, "edge11")
|> line([0, -tabLength / 3 * 2], %, "edge12")
|> line([-tabWidth, -tabLength / 3], %, "edge13")
|> close(%, "edge14")
|> line([tabWidth, -tabLength / 3], %, $edge11)
|> line([0, -tabLength / 3 * 2], %, $edge12)
|> line([-tabWidth, -tabLength / 3], %, $edge13)
|> close(%, $edge14)
|> hole(circle([
width / 2 + thk + tabWidth / 2,
length / 2 + thk - (tabLength / (3 / 2))
@ -86,8 +88,8 @@ const tabsR = startSketchOn(tabPlane)
|> fillet({
radius: holeDiam / 2,
tags: [
getNextAdjacentEdge("edge12", %),
getNextAdjacentEdge("edge13", %)
getNextAdjacentEdge(edge12, %),
getNextAdjacentEdge(edge13, %)
]
}, %)
|> patternLinear3d({
@ -99,10 +101,10 @@ const tabsR = startSketchOn(tabPlane)
// build the tabs of the mounting bracket (left side)
const tabsL = startSketchOn(tabPlane)
|> startProfileAt([-width / 2 - thk, length / 2 + thk], %)
|> line([-tabWidth, -tabLength / 3], %, "edge21")
|> line([0, -tabLength / 3 * 2], %, "edge22")
|> line([tabWidth, -tabLength / 3], %, "edge23")
|> close(%, "edge24")
|> line([-tabWidth, -tabLength / 3], %, $edge21)
|> line([0, -tabLength / 3 * 2], %, $edge22)
|> line([tabWidth, -tabLength / 3], %, $edge23)
|> close(%, $edge24)
|> hole(circle([
-width / 2 - thk - (tabWidth / 2),
length / 2 + thk - (tabLength / (3 / 2))
@ -111,8 +113,8 @@ const tabsL = startSketchOn(tabPlane)
|> fillet({
radius: holeDiam / 2,
tags: [
getNextAdjacentEdge("edge21", %),
getNextAdjacentEdge("edge22", %)
getNextAdjacentEdge(edge21, %),
getNextAdjacentEdge(edge22, %)
]
}, %)
|> patternLinear3d({

View File

@ -0,0 +1,18 @@
fn rect = (origin) => {
return startSketchOn('XZ')
|> startProfileAt(origin, %)
|> angledLine([0, 191.26], %, $rectangleSegmentA001)
|> angledLine([
segAng(rectangleSegmentA001, %) - 90,
196.99
], %, $rectangleSegmentB001)
|> angledLine([
segAng(rectangleSegmentA001, %),
-segLen(rectangleSegmentA001, %)
], %, $rectangleSegmentC001)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
}
rect([0, 0])
rect([20, 0])

View File

@ -2473,6 +2473,13 @@ async fn serial_test_pattern_vase() {
twenty_twenty::assert_image("tests/executor/outputs/pattern_vase.png", &result, 0.999);
}
#[tokio::test(flavor = "multi_thread")]
async fn serial_test_scoped_tags() {
let code = include_str!("inputs/scoped-tags.kcl");
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
twenty_twenty::assert_image("tests/executor/outputs/scoped_tags.png", &result, 0.999);
}
#[tokio::test(flavor = "multi_thread")]
async fn serial_test_order_sketch_extrude_in_order() {
let code = include_str!("inputs/order-sketch-extrude-in-order.kcl");

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB