Circle function and UI tool (#3860)
* circle * fix another example * fix bad comment * toPoint fix * cargo fmt * resolve most of the tests * fix last test * missed circle in bracket * remove console error * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * trigger ci * remove three dot menu for circle * make sure circle can be extruded * fix up after merge * add extrude test for circle * clean up * typo * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest)" This reverts commit03f8eeb542
. * update docs again * cmd bar test serialisation improvements * tiny clean up * fix after: Replace kittycad crate with kittycad-modeling-cmds * fmt * rename fix * Update src/lib/toolbar.ts Co-authored-by: Frank Noirot <frank@zoo.dev> * add another error to list * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * image updates * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)" This reverts commit505bb20bea
. * update markdown * skip un reproducable windows test failure * rust review * leave issue todo comment --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Frank Noirot <frank@zoo.dev>
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
export const bracket = `// Shelf Bracket
|
||||
// This is a bracket that holds a shelf. It is made of aluminum and is designed to hold a force of 300 lbs. The bracket is 6 inches wide and the force is applied at the end of the shelf, 12 inches from the wall. The bracket has a factor of safety of 1.2. The legs of the bracket are 5 inches and 2 inches long. The thickness of the bracket is calculated from the constraints provided.
|
||||
|
||||
|
||||
// Define constants
|
||||
const sigmaAllow = 35000 // psi (6061-T6 aluminum)
|
||||
const width = 6 // inch
|
||||
@ -11,50 +12,65 @@ const wallMountL = 2 // inches
|
||||
const shelfDepth = 12 // Shelf is 12 inches in depth from the wall
|
||||
const moment = shelfDepth * p // assume the force is applied at the end of the shelf to be conservative (lb-in)
|
||||
|
||||
|
||||
const filletRadius = .375 // inches
|
||||
const extFilletRadius = .25 // inches
|
||||
const mountingHoleDiameter = 0.5 // inches
|
||||
|
||||
|
||||
// Calculate required thickness of bracket
|
||||
const thickness = sqrt(moment * factorOfSafety * 6 / (sigmaAllow * width)) // this is the calculation of two brackets holding up the shelf (inches)
|
||||
|
||||
|
||||
// Sketch the bracket body and fillet the inner and outer edges of the bend
|
||||
const bracketLeg1Sketch = startSketchOn('XY')
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line([shelfMountL-filletRadius, 0], %, $fillet1)
|
||||
|> line([shelfMountL - filletRadius, 0], %, $fillet1)
|
||||
|> line([0, width], %, $fillet2)
|
||||
|> line([-shelfMountL + filletRadius, 0], %)
|
||||
|> close(%)
|
||||
|> hole(circle([1, 1], mountingHoleDiameter/2, %), %)
|
||||
|> hole(circle([shelfMountL-1.5, width-1], mountingHoleDiameter/2, %), %)
|
||||
|> hole(circle([1, width-1], mountingHoleDiameter/2, %), %)
|
||||
|> hole(circle([shelfMountL-1.5, 1], mountingHoleDiameter/2, %), %)
|
||||
|> hole(circle({
|
||||
center: [1, 1],
|
||||
radius: mountingHoleDiameter / 2
|
||||
}, %), %)
|
||||
|> hole(circle({
|
||||
center: [shelfMountL - 1.5, width - 1],
|
||||
radius: mountingHoleDiameter / 2
|
||||
}, %), %)
|
||||
|> hole(circle({
|
||||
center: [1, width - 1],
|
||||
radius: mountingHoleDiameter / 2
|
||||
}, %), %)
|
||||
|> hole(circle({
|
||||
center: [shelfMountL - 1.5, 1],
|
||||
radius: mountingHoleDiameter / 2
|
||||
}, %), %)
|
||||
|
||||
// Extrude the leg 2 bracket sketch
|
||||
const bracketLeg1Extrude = extrude(thickness, bracketLeg1Sketch)
|
||||
|> fillet({
|
||||
radius: extFilletRadius,
|
||||
tags: [
|
||||
getNextAdjacentEdge(fillet1),
|
||||
getNextAdjacentEdge(fillet2)
|
||||
],
|
||||
}, %)
|
||||
radius: extFilletRadius,
|
||||
tags: [
|
||||
getNextAdjacentEdge(fillet1),
|
||||
getNextAdjacentEdge(fillet2)
|
||||
]
|
||||
}, %)
|
||||
|
||||
// Sketch the fillet arc
|
||||
const filletSketch = startSketchOn('XZ')
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line([0, thickness], %)
|
||||
|> arc({
|
||||
angleEnd: 180,
|
||||
angleStart: 90,
|
||||
radius: filletRadius + thickness,
|
||||
}, %)
|
||||
angleEnd: 180,
|
||||
angleStart: 90,
|
||||
radius: filletRadius + thickness
|
||||
}, %)
|
||||
|> line([thickness, 0], %)
|
||||
|> arc({
|
||||
angleEnd: 90,
|
||||
angleStart: 180,
|
||||
radius: filletRadius,
|
||||
}, %)
|
||||
angleEnd: 90,
|
||||
angleStart: 180,
|
||||
radius: filletRadius
|
||||
}, %)
|
||||
|
||||
// Sketch the bend
|
||||
const filletExtrude = extrude(-width, filletSketch)
|
||||
@ -76,18 +92,25 @@ const bracketLeg2Sketch = startSketchOn(customPlane)
|
||||
|> line([0, -wallMountL], %, $fillet3)
|
||||
|> line([-width, 0], %, $fillet4)
|
||||
|> close(%)
|
||||
|> hole(circle([1, -1.5], mountingHoleDiameter / 2, %), %)
|
||||
|> hole(circle([5, -1.5], mountingHoleDiameter / 2, %), %)
|
||||
|> hole(circle({
|
||||
center: [1, -1.5],
|
||||
radius: mountingHoleDiameter / 2
|
||||
}, %), %)
|
||||
|> hole(circle({
|
||||
center: [5, -1.5],
|
||||
radius: mountingHoleDiameter / 2
|
||||
}, %), %)
|
||||
|
||||
// Extrude the second leg
|
||||
const bracketLeg2Extrude = extrude(-thickness, bracketLeg2Sketch)
|
||||
|> fillet({
|
||||
radius: extFilletRadius,
|
||||
tags: [
|
||||
getNextAdjacentEdge(fillet3),
|
||||
getNextAdjacentEdge(fillet4)
|
||||
],
|
||||
}, %)`
|
||||
radius: extFilletRadius,
|
||||
tags: [
|
||||
getNextAdjacentEdge(fillet3),
|
||||
getNextAdjacentEdge(fillet4)
|
||||
]
|
||||
}, %)
|
||||
`
|
||||
|
||||
/**
|
||||
* @throws Error if the search text is not found in the example code.
|
||||
|
Reference in New Issue
Block a user