No longer needs to be a function

This commit is contained in:
Adam Chalmers
2025-06-18 09:21:19 -05:00
parent a76e18dd2c
commit e982eb36dd

View File

@ -34,36 +34,32 @@ fn helicalGear(nTeeth, module, pressureAngle, helixAngle, gearHeight) {
|> close() |> close()
|> extrude(length = gearHeight) |> extrude(length = gearHeight)
// Define a function to create a rotated gear sketch on an offset plane // Using the gear parameters, sketch an involute tooth spanning from the base diameter to the tip diameter
fn helicalGearSketch() { helicalGearSketch = startSketchOn(XY)
// Using the gear parameters, sketch an involute tooth spanning from the base diameter to the tip diameter |> startProfile(at = polar(angle = 0, length = baseDiameter / 2))
helicalGearSketch = startSketchOn(XY) |> involuteCircular(
|> startProfile(at = polar(angle = 0, length = baseDiameter / 2)) startRadius = baseDiameter / 2,
|> involuteCircular( endRadius = tipDiameter / 2,
startRadius = baseDiameter / 2, angle = 0,
endRadius = tipDiameter / 2, tag = $seg01,
angle = 0, )
tag = $seg01, |> line(endAbsolute = polar(angle = 160 / nTeeth, length = tipDiameter / 2))
) |> involuteCircular(
|> line(endAbsolute = polar(angle = 160 / nTeeth, length = tipDiameter / 2)) startRadius = baseDiameter / 2,
|> involuteCircular( endRadius = tipDiameter / 2,
startRadius = baseDiameter / 2, angle = -(4 * atan(segEndY(seg01) / segEndX(seg01))),
endRadius = tipDiameter / 2, reverse = true,
angle = -(4 * atan(segEndY(seg01) / segEndX(seg01))), )
reverse = true,
)
// Position the end line of the sketch at the start of the next tooth // Position the end line of the sketch at the start of the next tooth
|> line(endAbsolute = polar(angle = 360 / nTeeth, length = baseDiameter / 2)) |> line(endAbsolute = polar(angle = 360 / nTeeth, length = baseDiameter / 2))
// Pattern the sketch about the center by the specified number of teeth, then close the sketch // Pattern the sketch about the center by the specified number of teeth, then close the sketch
|> patternCircular2d(%, instances = nTeeth, center = [0, 0]) |> patternCircular2d(%, instances = nTeeth, center = [0, 0])
|> close() |> close()
return helicalGearSketch
}
// Draw a gear sketch on the base plane // Draw a gear sketch on the base plane
return helicalGearSketch() return helicalGearSketch
|> extrude(length = gearHeight, twistAngle = helixAngle) |> extrude(length = gearHeight, twistAngle = helixAngle)
|> subtract([%], tools = [holeWithKeyway]) |> subtract([%], tools = [holeWithKeyway])
} }
@ -76,3 +72,4 @@ helicalGear(
helixAngle = 35, helixAngle = 35,
gearHeight, gearHeight,
) )