Previously, `xLine`, `xLineTo`, `yLine` and `yLineTo` used positional arguments. Now: - `xLineTo` and `yLineTo` have been removed - `xLine` and `yLine` both use keyword arguments: - `length`, optional (i.e. a relative distance along the X or Y axis) - `endAbsolute` optional (i.e. an absolute point along the X or Y axis) - `tag` optional - Exactly one of `length` or `endAbsolute` must be given. Not both, not neither. For example: ``` // Old way |> xLine(6.04, %) |> yLineTo(20, %, $base) // New way |> xLine(length = 6.04) |> yLine(endAbsolute = 20, tag = $base) ``` This also improves some of the general-purpose keyword arguments code in modeling app's TS codebase.
69 lines
2.3 KiB
Plaintext
69 lines
2.3 KiB
Plaintext
// Socket Head Cap Screw
|
|
// This is for a #10-24 screw that is 1.00 inches long. A socket head cap screw is a type of fastener that is widely used in a variety of applications requiring a high strength fastening solution. It is characterized by its cylindrical head and internal hexagonal drive, which allows for tightening with an Allen wrench or hex key.
|
|
|
|
// Set units
|
|
@settings(defaultLengthUnit = in)
|
|
|
|
// Define constants
|
|
screwLength = 1.0
|
|
screwDiameter = .190
|
|
headDiameter = .313
|
|
headLength = screwDiameter
|
|
hexWallToWall = 5 / 32
|
|
capRatio = screwDiameter / headDiameter
|
|
hexRatio = hexWallToWall / headDiameter
|
|
hexWallLength = hexWallToWall / 2 * 1 / cos(toRadians(30))
|
|
hexStartingAngle = 210 // first angle of hex pattern
|
|
hexInteriorAngle = 120
|
|
hexChangeAngle = 180 - hexInteriorAngle
|
|
|
|
// Write a function that defines the Socket Head Cap Screw
|
|
fn capScrew(start, length, dia, capHeadLength) {
|
|
// Create the head of the cap screw
|
|
screwHeadSketch = startSketchOn('XZ')
|
|
|> circle(
|
|
center = [start[0], start[1]],
|
|
radius = dia / capRatio / 2
|
|
)
|
|
|
|
// Extrude the screw head sketch
|
|
screwHead = extrude(screwHeadSketch, length = capHeadLength)
|
|
|
|
// Define the sketch of the hex pattern on the screw head
|
|
hexPatternSketch = startSketchOn(screwHead, 'end')
|
|
|> startProfileAt([hexWallToWall / 2, 0], %)
|
|
|> yLine(length = -hexWallLength / 2)
|
|
|> angledLine({
|
|
angle = hexStartingAngle,
|
|
length = hexWallLength
|
|
}, %)
|
|
|> angledLine({
|
|
angle = hexStartingAngle - hexChangeAngle,
|
|
length = hexWallLength
|
|
}, %)
|
|
|> angledLine({
|
|
angle = hexStartingAngle - (2 * hexChangeAngle),
|
|
length = hexWallLength
|
|
}, %)
|
|
|> angledLine({
|
|
angle = hexStartingAngle - (3 * hexChangeAngle),
|
|
length = hexWallLength
|
|
}, %)
|
|
|> angledLine({
|
|
angle = hexStartingAngle - (4 * hexChangeAngle),
|
|
length = hexWallLength
|
|
}, %)
|
|
|> close()
|
|
hexPattern = extrude(hexPatternSketch, length = -headLength * 0.75)
|
|
|
|
screwBodySketch = startSketchOn(screwHead, "start")
|
|
|> circle(
|
|
center = [start[0], start[1]],
|
|
radius = dia / 2
|
|
)
|
|
screwBody = extrude(screwBodySketch, length = length)
|
|
return screwBody
|
|
}
|
|
|
|
capScrew([0, 0], screwLength, screwDiameter, screwDiameter)
|