Skip to content

Commit

Permalink
rack: add property pitch (read-only), make length of rack match pitch…
Browse files Browse the repository at this point in the history
… x teeth
  • Loading branch information
looooo committed Feb 5, 2020
1 parent d84ead5 commit 95f6de1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
7 changes: 5 additions & 2 deletions freecad/gears/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ def __init__(self, obj):
obj.addProperty(
"App::PropertyBool", "properties_from_tool", "gear_parameter", "if beta is given and properties_from_tool is enabled, \
gear parameters are internally recomputed for the rotated gear")
obj.addProperty("App::PropertyLength", "transverse_pitch",
"computed", "pitch in the transverse plane", 1)
obj.addProperty("App::PropertyPythonObject", "rack", "test", "test")
obj.rack = self.involute_rack
obj.teeth = 15
Expand All @@ -229,10 +231,8 @@ def execute(self, fp):
fp.rack.head = fp.head
# checksbackwardcompatibility:
if "clearence" in fp.PropertiesList:
print(fp.clearence)
fp.rack.clearence = fp.clearence
if "properties_from_tool" in fp.PropertiesList:
print(fp.properties_from_tool)
fp.rack.properties_from_tool = fp.properties_from_tool
fp.rack._update()
pts = fp.rack.points()
Expand All @@ -254,6 +254,9 @@ def execute(self, fp):
pol2.translate(
fcvec([0., np.tan(beta) * fp.height.Value, fp.height.Value]))
fp.Shape = makeLoft([pol, pol2], True)
# computed properties
if "transverse_pitch" in fp.PropertiesList:
fp.transverse_pitch = "{} mm".format(fp.rack.compute_properties()[2])

def __getstate__(self):
return None
Expand Down
37 changes: 24 additions & 13 deletions pygears/involute_tooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,35 +177,46 @@ def _update(self):
properties_from_tool=self.properties_from_tool)

def points(self, num=10):
if self.properties_from_tool:
pressure_angle_t = arctan(tan(self.pressure_angle) / cos(self.beta))
m = self.m / cos(self.beta)
m_n = self.m
else:
pressure_angle_t = self.pressure_angle
m = self.m
m_n = self.m
m, m_n, pitch, pressure_angle_t = self.compute_properties()

a = (2 + self.head + self.clearence) * m_n * tan(pressure_angle_t)
b = (m * pi) / 4 - (1 + self.head) * m_n * tan(pressure_angle_t)
b = pitch / 4 - (1 + self.head) * m_n * tan(pressure_angle_t)
tooth = [
[-m_n * (1 + self.clearence), -a - b],
[m_n * (1 + self.head), -b],
[m_n * (1 + self.head), b],
[-m_n * (1 + self.clearence), a + b]
]
teeth = [tooth]
trans = translation([0., m * pi, 0.])
trans = translation([0., pitch, 0.])
for i in range(self.z - 1):
teeth.append(trans(teeth[-1]))
teeth = list(np.vstack(teeth))
teeth.append(list(teeth[-1]))
teeth[-1][0] -= self.thickness
teeth.append(list(teeth[0]))
ext1 = np.array(teeth[0]) + np.array([0., a + b - pitch / 2])
ext2 = np.array(teeth[-1]) - np.array([0., a + b - pitch / 2])
print(ext1, ext2)
teeth = [ext1.tolist(), ext1.tolist()] + teeth + [ext2.tolist(), ext2.tolist()]
#teeth.append(list(teeth[-1]))
teeth[0][0] -= self.thickness
#teeth.append(list(teeth[0]))
teeth[-1][0] -= self.thickness
teeth.append(teeth[0])
return(teeth)

def compute_properties(self):
if self.properties_from_tool:
pressure_angle_t = arctan(tan(self.pressure_angle) / cos(self.beta))
m = self.m / cos(self.beta)
m_n = self.m
else:
pressure_angle_t = self.pressure_angle
m = self.m
m_n = self.m

pitch = m * np.pi
return m, m_n, pitch, pressure_angle_t



if __name__ == "__main__":
from matplotlib import pyplot
Expand Down

0 comments on commit 95f6de1

Please sign in to comment.