2024-03-15 23:10:34 -07:00
export const bracket = ` // Shelf Bracket
// This is a shelf bracket made out of 6061-T6 aluminum sheet metal. The required thickness is calculated based on a point load of 300 lbs applied to the end of the shelf. There are two brackets holding up the shelf, so the moment experienced is divided by 2. The shelf is 1 foot long from the wall.
2023-09-15 22:37:40 -04:00
2024-04-29 10:44:00 -07:00
// Define our bracket feet lengths
const shelfMountL = 8 // The length of the bracket holding up the shelf is 6 inches
const wallMountL = 6 // the length of the bracket
// Define constants required to calculate the thickness needed to support 300 lbs
2024-03-15 23:10:34 -07:00
const sigmaAllow = 35000 // psi
const width = 6 // inch
const p = 300 // Force on shelf - lbs
2024-04-29 10:44:00 -07:00
const L = 12 // inches
const M = L * p / 2 // Moment experienced at fixed end of bracket
const FOS = 2 // Factor of safety of 2 to be conservative
2024-03-15 16:05:26 -07:00
2024-04-29 10:44:00 -07:00
// Calculate the thickness off the bending stress and factor of safety
2024-03-15 23:10:34 -07:00
const thickness = sqrt ( 6 * M * FOS / ( width * sigmaAllow ) )
// 0.25 inch fillet radius
const filletR = 0.25
// Sketch the bracket and extrude with fillets
const bracket = startSketchOn ( 'XY' )
| > startProfileAt ( [ 0 , 0 ] , % )
2024-06-24 22:39:04 -07:00
| > line ( [ 0 , wallMountL ] , % , $outerEdge )
2024-03-15 23:10:34 -07:00
| > line ( [ - shelfMountL , 0 ] , % )
| > line ( [ 0 , - thickness ] , % )
2024-06-24 22:39:04 -07:00
| > line ( [ shelfMountL - thickness , 0 ] , % , $innerEdge )
2024-03-15 23:10:34 -07:00
| > line ( [ 0 , - wallMountL + thickness ] , % )
| > close ( % )
| > extrude ( width , % )
2024-03-15 16:05:26 -07:00
| > fillet ( {
2024-03-15 23:10:34 -07:00
radius : filletR ,
2024-06-24 22:39:04 -07:00
tags : [ getPreviousAdjacentEdge ( innerEdge , % ) ]
2024-03-15 23:10:34 -07:00
} , % )
| > fillet ( {
radius : filletR + thickness ,
2024-06-24 22:39:04 -07:00
tags : [ getPreviousAdjacentEdge ( outerEdge , % ) ]
2024-03-29 12:56:32 -04:00
} , % ) `
function findLineInExampleCode ( {
searchText ,
example = bracket ,
} : {
searchText : string
example? : string
} ) {
const lines = example . split ( '\n' )
const lineNumber = lines . findIndex ( ( l ) = > l . includes ( searchText ) ) + 1
if ( lineNumber === 0 ) {
throw new Error (
` Could not find the line with search text " ${ searchText } " in the example code. Was it removed? `
)
}
return lineNumber
}
export const bracketWidthConstantLine = findLineInExampleCode ( {
searchText : 'const width' ,
} )
export const bracketThicknessCalculationLine = findLineInExampleCode ( {
searchText : 'const thickness' ,
} )