Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gear.kcl #100

Merged
merged 4 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 69 additions & 52 deletions gear/gear.kcl
Original file line number Diff line number Diff line change
@@ -1,65 +1,82 @@
// Gear
// Spur Gear
// A rotating machine part having cut teeth or, in the case of a cogwheel, inserted teeth (called cogs), which mesh with another toothed part to transmit torque. Geared devices can change the speed, torque, and direction of a power source. The two elements that define a gear are its circular shape and the teeth that are integrated into its outer edge, which are designed to fit into the teeth of another gear.


// Define constants
gearRadius = 2
nTeeth = 8
width = 2
nTeeth = 21
module = 0.5
pitchDiameter = module * nTeeth
pressureAngle = 20
addendum = module
deddendum = 1.25 * module
baseDiameter = pitchDiameter * cos(toRadians(pressureAngle))
tipDiameter = pitchDiameter + 2 * module
gearHeight = 3

// Interpolate points along the involute curve
cmo = int(101)
rs = map([0..cmo], (i) => {
return baseDiameter / 2 + i / cmo * (tipDiameter - baseDiameter) / 2
})

// Create a function for sketch of a single tooth
fn tooth = () => {
toothSketch = startSketchOn('XY')
|> startProfileAt([0, gearRadius], %)
|> arc({
angleStart: 90,
angleEnd: 90 - (180 / pi() * asin(0.7376425 / gearRadius)),
radius: gearRadius
}, %, $base)
|> angledLine({
angle: 180 - (180 / pi() * asin(0.7376425 / gearRadius)),
length: 0.0001
}, %)
|> tangentialArc({
offset: -70 + 180 / pi() * asin(0.7376425 / gearRadius),
radius: 0.389854023
}, %, $philly)
|> line([-0.329118, 0.904244], %)
|> tangentialArcTo([
lastSegX(%) - 0.157636,
lastSegY(%) + 0.110378
], %, $corner)
|> xLineTo(0, %)
|> xLineTo(-1 * segEndX(corner), %)
|> tangentialArcTo([
lastSegX(%) - 0.157636,
lastSegY(%) - 0.110378
], %)
|> lineTo([-1 * segEndX(philly), segEndY(philly)], %, $tag2)
|> tangentialArcTo([-1 * segEndX(base), segEndY(base)], %)
|> arc({
angleEnd: 90,
angleStart: 90 + 180 / pi() * asin(0.7376425 / gearRadius),
radius: gearRadius
}, %)
|> close(%)
|> extrude(width, %)
return [toothSketch]
}
// Calculate operating pressure angle
as = map(rs, (r) => {
return toDegrees(acos(baseDiameter / 2 / r))
})

// Calculate the involute function
invas = map(as, (a) => {
return tan(toRadians(a)) - toRadians(a)
})

// Map the involute curve
xs = map([0..cmo], (i) => {
return rs[i] * cos(invas[i])
})

ys = map([0..cmo], (i) => {
return rs[i] * sin(invas[i])
})

// Create the body
// Extrude the gear body
body = startSketchOn('XY')
|> circle({ center: [0, 0], radius: gearRadius }, %)
|> extrude(width, %)
|> circle({
center: [0, 0],
radius: baseDiameter / 2
}, %)
|> extrude(gearHeight, %)

toothAngle = 360 / nTeeth / 1.5

// Plot the involute curve
fn leftInvolute = (i, sg) => {
j = int(100 - i) // iterate backwards
return lineTo([xs[j], ys[j]], sg)
}

// Pattern the teeth around the body
teeth = tooth()
fn rightInvolute = (i, sg) => {
x = rs[i] * cos(toRadians(-toothAngle + toDegrees(atan(ys[i] / xs[i]))))
y = -rs[i] * sin(toRadians(-toothAngle + toDegrees(atan(ys[i] / xs[i]))))
return lineTo([x, y], sg)
}

// Draw gear teeth
start = startSketchOn('XY')
|> startProfileAt([xs[101], ys[101]], %)
teeth = reduce([0..100], start, leftInvolute)
|> arc({
angleStart: 0,
angleEnd: toothAngle,
radius: baseDiameter / 2
}, %)
|> reduce([1..101], %, rightInvolute)
|> close(%)
|> extrude(gearHeight, %)
|> patternCircular3d({
arcDegrees: 360,
axis: [0, 0, 1],
center: [0, 0, 0],
instances: nTeeth,
arcDegrees: 360,
rotateDuplicates: true
}, %)

Expand All @@ -70,8 +87,8 @@ holeDiam = 2
holeRadius = 1
startAngle = asin(keywayWidth / 2 / holeRadius)

// sketch the keyway and center hole and extrude
sketch001 = startSketchOn(body, 'END')
// Sketch the keyway and center hole and extrude
keyWay = startSketchOn(body, 'END')
|> startProfileAt([
holeRadius * cos(startAngle),
holeRadius * sin(startAngle)
Expand All @@ -90,4 +107,4 @@ sketch001 = startSketchOn(body, 'END')
radius: holeRadius
}, %)
|> close(%)
|> extrude(-width, %)
|> extrude(-gearHeight, %)
Binary file modified screenshots/80-20-rail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/a-parametric-bearing-pillow-block.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/ball-bearing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/bracket.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/brake-caliper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/car-wheel-assembly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/car-wheel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/enclosure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/flange-with-patterns.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/flange-xy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/focusrite-scarlett-mounting-bracket.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/food-service-spatula.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/french-press.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/gear-rack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/gear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/hex-nut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/kitt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/lego.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/lug-nut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/mounting-plate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/multi-axis-robot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/pipe-flange-assembly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/pipe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/poopy-shoe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/router-template-slate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/sheet-metal-bracket.png
Binary file modified screenshots/socket-head-cap-screw.png
Binary file modified screenshots/tire.png
Binary file modified screenshots/washer.png
Binary file modified screenshots/wheel-rotor.png
25,233 changes: 22,338 additions & 2,895 deletions step/gear.step

Large diffs are not rendered by default.