Skip to content

Commit

Permalink
Added axle hole and offset hole possiblities to involute gears,
Browse files Browse the repository at this point in the history
features added  Axle_hole Y/N, Axle size diam, offset hole Y/N offset
amount, and offset size. This allows a crank type system as well.
  • Loading branch information
iplayfast authored and looooo committed Dec 1, 2024
1 parent 09b8d76 commit b5121b1
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 10 deletions.
89 changes: 79 additions & 10 deletions freecad/gears/involutegear.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self, obj):
self.add_computed_properties(obj)
self.add_tolerance_properties(obj)
self.add_accuracy_properties(obj)

self.add_hole_properties(obj)
obj.gear = self.involute_tooth
obj.simple = False
obj.undercut = False
Expand All @@ -74,10 +74,48 @@ def __init__(self, obj):
obj.properties_from_tool = False
obj.head_fillet = 0
obj.root_fillet = 0
obj.axle_hole = False
obj.axle_holesize = "10.mm"
obj.offset_hole = False
obj.offset_holesize = "10.mm"
obj.offset_holeoffset = "10.mm"
self.obj = obj
obj.Proxy = self
self.compute_traverse_properties(obj)

def add_hole_properties(self, obj):
"""Add properties for the central hole"""
obj.addProperty(
"App::PropertyBool",
"axle_hole",
"base",
QT_TRANSLATE_NOOP("App::Property", "enable central hole for axle"),
)
obj.addProperty(
"App::PropertyLength",
"axle_holesize",
"base",
QT_TRANSLATE_NOOP("App::Property", "diameter of central hole for axle"),
)
obj.addProperty(
"App::PropertyBool",
"offset_hole",
"base",
QT_TRANSLATE_NOOP("App::Property", "enable offset hole"),
)
obj.addProperty(
"App::PropertyLength",
"offset_holesize",
"base",
QT_TRANSLATE_NOOP("App::Property", "diameter of offset hole"),
)
obj.addProperty(
"App::PropertyLength",
"offset_holeoffset",
"base",
QT_TRANSLATE_NOOP("App::Property", "offset of offset hole"),
)

def add_gear_properties(self, obj):
obj.addProperty(
"App::PropertyIntegerConstraint",
Expand Down Expand Up @@ -288,6 +326,12 @@ def generate_gear_shape(self, obj):
obj.gear.head = obj.head
obj.gear.properties_from_tool = obj.properties_from_tool
obj.gear.num_teeth = obj.num_teeth
obj.gear.axle_hole = obj.axle_hole
obj.gear.axle_holesize = obj.axle_holesize.Value

obj.gear.offset_hole = obj.offset_hole
obj.gear.offset_holesize = obj.offset_holesize.Value
obj.gear.offset_holeoffset= obj.offset_holeoffset.Value

obj.gear._update()
self.compute_traverse_properties(obj)
Expand Down Expand Up @@ -339,15 +383,40 @@ def generate_gear_shape(self, obj):
profile = rotate_tooth(tooth, obj.num_teeth)

if obj.height.Value == 0:
return profile
base = part.Face(profile)
if obj.beta.Value == 0:
return base.extrude(app.Vector(0, 0, obj.height.Value))
gear_shape = profile
else:
twist_angle = obj.height.Value * np.tan(obj.gear.beta) * 2 / obj.gear.d
return helical_extrusion(
base, obj.height.Value, twist_angle, obj.double_helix
)
base = part.Face(profile)
if obj.beta.Value == 0:
gear_shape = base.extrude(app.Vector(0, 0, obj.height.Value))
else:
twist_angle = obj.height.Value * np.tan(obj.gear.beta) * 2 / obj.gear.d
gear_shape = helical_extrusion(
base, obj.height.Value, twist_angle, obj.double_helix
)

if obj.axle_hole and obj.axle_holesize.Value > 0:
axle_hole = part.makeCylinder(obj.axle_holesize.Value/2, obj.height.Value)
gear_shape = gear_shape.cut(axle_hole)

if obj.offset_hole and obj.offset_holesize.Value > 0:
hole = part.makeCylinder(obj.offset_holesize.Value/2, obj.height.Value)
hole.Placement.Base = app.Vector(-obj.offset_holeoffset.Value, 0,0) #-obj.offset_holeoffset.Value/2, 0)
gear_shape = gear_shape.cut(hole)
return gear_shape
else:
rw = obj.gear.dw / 2
return part.makeCylinder(rw, obj.height.Value)
gear_shape = part.makeCylinder(rw, obj.height.Value)

if obj.axle_hole and obj.axle_holesize.Value > 0:
axle_hole = part.makeCylinder(obj.axle_holesize.Value/2, obj.height.Value)
#hole.Placement.Base = app.Vector(-obj.holesize.Value/2, -obj.holesize.Value/2, 0)
gear_shape = gear_shape.cut(axle_hole)

if obj.hole and obj.holesize.Value > 0:
hole = part.makeCylinder(obj.holesize.Value/2, obj.height.Value)
hole.Placement.Base = app.Vector(-obj.offset_holeoffset.Value, 0,0) #-obj.holeoffset.Value/2, 0)
gear_shape = gear_shape.cut(hole)

return gear_shape


11 changes: 11 additions & 0 deletions pygears/involute_tooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,23 @@ def __init__(
backlash=0.00,
head=0.00,
properties_from_tool=False,
axle_hole=False,
axle_holesize=10,
offset_hole=False,
offset_holesize=10,
offset_holeoffset = 5,
):
self.pressure_angle = pressure_angle
self.beta = beta
self.m_n = m
self.num_teeth = num_teeth
self.undercut = undercut
self.axle_hole = axle_hole
self.axle_holesize = axle_holesize
self.offset_hole = offset_hole
self.offset_holesize = offset_holesize
self.offset_holeoffset = offset_holeoffset
self.undercut = undercut
self.shift = shift
self.clearance = clearance
self.backlash = backlash
Expand Down

0 comments on commit b5121b1

Please sign in to comment.