ruff formating
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
@@ -26,6 +25,7 @@ from pygears._functions import rotation3D
|
||||
|
||||
from .features import BaseGear, fcvec, make_bspline_wire
|
||||
|
||||
|
||||
class BevelGear(BaseGear):
|
||||
|
||||
"""parameters:
|
||||
@@ -204,4 +204,3 @@ class BevelGear(BaseGear):
|
||||
def spherical_rot(self, point, phi):
|
||||
new_phi = np.sqrt(np.linalg.norm(point)) * phi
|
||||
return rotation3D(new_phi)(point)
|
||||
|
||||
|
||||
@@ -42,14 +42,16 @@ class ViewProviderGearConnector(object):
|
||||
|
||||
def getIcon(self):
|
||||
return self.icon_fn
|
||||
|
||||
|
||||
if sys.version_info[0] == 3 and sys.version_info[1] >= 11:
|
||||
|
||||
def dumps(self):
|
||||
return {"icon_fn": self.icon_fn}
|
||||
|
||||
def loads(self, state):
|
||||
self.icon_fn = state["icon_fn"]
|
||||
else:
|
||||
|
||||
def __getstate__(self):
|
||||
return {"icon_fn": self.icon_fn}
|
||||
|
||||
@@ -57,7 +59,6 @@ class ViewProviderGearConnector(object):
|
||||
self.icon_fn = state["icon_fn"]
|
||||
|
||||
|
||||
|
||||
class GearConnector(object):
|
||||
def __init__(self, obj, master_gear, slave_gear):
|
||||
obj.addProperty(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
@@ -25,11 +24,12 @@ from pygears.cycloid_tooth import CycloidTooth
|
||||
from pygears._functions import rotation
|
||||
|
||||
from .features import (
|
||||
BaseGear,
|
||||
points_to_wire,
|
||||
insert_fillet,
|
||||
helicalextrusion,
|
||||
rotate_tooth)
|
||||
BaseGear,
|
||||
points_to_wire,
|
||||
insert_fillet,
|
||||
helicalextrusion,
|
||||
rotate_tooth,
|
||||
)
|
||||
|
||||
|
||||
class CycloidGear(BaseGear):
|
||||
@@ -191,4 +191,3 @@ class CycloidGear(BaseGear):
|
||||
fp.height.Value * np.tan(fp.beta.Value * np.pi / 180) * 2 / fp.gear.d
|
||||
)
|
||||
return helicalextrusion(base, fp.height.Value, twist_angle, fp.double_helix)
|
||||
|
||||
|
||||
@@ -25,12 +25,7 @@ import Part
|
||||
import numpy as np
|
||||
|
||||
from pygears._functions import reflection
|
||||
from .features import (
|
||||
BaseGear,
|
||||
fcvec,
|
||||
points_to_wire,
|
||||
insert_fillet
|
||||
)
|
||||
from .features import BaseGear, fcvec, points_to_wire, insert_fillet
|
||||
|
||||
|
||||
class CycloidGearRack(BaseGear):
|
||||
|
||||
@@ -36,7 +36,6 @@ from pygears._functions import (
|
||||
)
|
||||
|
||||
|
||||
|
||||
def fcvec(x):
|
||||
if len(x) == 2:
|
||||
return App.Vector(x[0], x[1], 0)
|
||||
@@ -69,6 +68,7 @@ class ViewProviderGear(object):
|
||||
return self.icon_fn
|
||||
|
||||
if sys.version_info[0] == 3 and sys.version_info[1] >= 11:
|
||||
|
||||
def dumps(self):
|
||||
self._check_attr()
|
||||
return {"icon_fn": self.icon_fn}
|
||||
@@ -77,6 +77,7 @@ class ViewProviderGear(object):
|
||||
if state and "icon_fn" in state:
|
||||
self.icon_fn = state["icon_fn"]
|
||||
else:
|
||||
|
||||
def __getstate__(self):
|
||||
self._check_attr()
|
||||
return {"icon_fn": self.icon_fn}
|
||||
@@ -131,12 +132,14 @@ class BaseGear(object):
|
||||
raise NotImplementedError("generate_gear_shape not implemented")
|
||||
|
||||
if sys.version_info[0] == 3 and sys.version_info[1] >= 11:
|
||||
|
||||
def loads(self, state):
|
||||
pass
|
||||
|
||||
def dumps(self):
|
||||
pass
|
||||
else:
|
||||
|
||||
def __setstate__(self, state):
|
||||
pass
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
@@ -30,6 +29,7 @@ from pygears._functions import rotation
|
||||
|
||||
from .features import BaseGear, make_bspline_wire
|
||||
|
||||
|
||||
class HypoCycloidGear(BaseGear):
|
||||
|
||||
"""parameters:
|
||||
@@ -281,4 +281,3 @@ class HypoCycloidGear(BaseGear):
|
||||
|
||||
if to_be_fused:
|
||||
return Part.makeCompound(to_be_fused)
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ if sys.version_info[0] == 3 and sys.version_info[1] >= 11:
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class GearWorkbench(Workbench):
|
||||
"""A freecad workbench aiming at gear design"""
|
||||
|
||||
@@ -129,7 +130,7 @@ class GearWorkbench(Workbench):
|
||||
CreateLanternGear,
|
||||
CreateHypoCycloidGear,
|
||||
CreateCycloidRack,
|
||||
CreateGearConnector
|
||||
CreateGearConnector,
|
||||
)
|
||||
|
||||
self.appendToolbar("Gear", self.commands)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
@@ -25,11 +24,12 @@ from pygears.involute_tooth import InvoluteTooth
|
||||
from pygears._functions import rotation
|
||||
|
||||
from .features import (
|
||||
BaseGear,
|
||||
points_to_wire,
|
||||
insert_fillet,
|
||||
helicalextrusion,
|
||||
rotate_tooth)
|
||||
BaseGear,
|
||||
points_to_wire,
|
||||
insert_fillet,
|
||||
helicalextrusion,
|
||||
rotate_tooth,
|
||||
)
|
||||
|
||||
|
||||
class InternalInvoluteGear(BaseGear):
|
||||
@@ -246,4 +246,3 @@ class InternalInvoluteGear(BaseGear):
|
||||
inner_circle.reverse()
|
||||
base = Part.Face([outer_circle, inner_circle])
|
||||
return base.extrude(App.Vector(0, 0, fp.height.Value))
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
@@ -25,11 +24,12 @@ from pygears.involute_tooth import InvoluteTooth
|
||||
from pygears._functions import rotation
|
||||
|
||||
from .features import (
|
||||
BaseGear,
|
||||
points_to_wire,
|
||||
insert_fillet,
|
||||
helicalextrusion,
|
||||
rotate_tooth)
|
||||
BaseGear,
|
||||
points_to_wire,
|
||||
insert_fillet,
|
||||
helicalextrusion,
|
||||
rotate_tooth,
|
||||
)
|
||||
|
||||
|
||||
class InvoluteGear(BaseGear):
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
@@ -24,12 +23,8 @@ import Part
|
||||
import numpy as np
|
||||
from pygears.involute_tooth import InvoluteRack
|
||||
|
||||
from .features import (
|
||||
BaseGear,
|
||||
fcvec,
|
||||
points_to_wire,
|
||||
insert_fillet
|
||||
)
|
||||
from .features import BaseGear, fcvec, points_to_wire, insert_fillet
|
||||
|
||||
|
||||
class InvoluteGearRack(BaseGear):
|
||||
|
||||
@@ -242,4 +237,3 @@ class InvoluteGearRack(BaseGear):
|
||||
fcvec([0.0, np.tan(beta) * obj.height.Value, obj.height.Value])
|
||||
)
|
||||
return Part.makeLoft([pol, pol2], True)
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
@@ -85,8 +84,9 @@ class LanternGear(BaseGear):
|
||||
+ 2 * r_r * np.sin(phi_min)
|
||||
)
|
||||
|
||||
phi_min = sp.optimize.root(
|
||||
find_phi_min, (phi_max + r_r / r_0 * 4) / 5).x[0] # , r_r / r_0, phi_max)
|
||||
phi_min = sp.optimize.root(find_phi_min, (phi_max + r_r / r_0 * 4) / 5).x[
|
||||
0
|
||||
] # , r_r / r_0, phi_max)
|
||||
|
||||
# phi_min = 0 # r_r / r_0
|
||||
phi = np.linspace(phi_min, phi_max, fp.num_profiles)
|
||||
@@ -131,4 +131,3 @@ class LanternGear(BaseGear):
|
||||
return wi
|
||||
else:
|
||||
return Part.Face(wi).extrude(App.Vector(0, 0, fp.height))
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
@@ -23,10 +22,7 @@ import Part
|
||||
import numpy as np
|
||||
|
||||
from pygears._functions import reflection
|
||||
from .features import (
|
||||
BaseGear,
|
||||
part_arc_from_points_and_center
|
||||
)
|
||||
from .features import BaseGear, part_arc_from_points_and_center
|
||||
|
||||
|
||||
class TimingGear(BaseGear):
|
||||
@@ -287,4 +283,3 @@ class TimingGear(BaseGear):
|
||||
return wi
|
||||
else:
|
||||
return Part.Face(wi).extrude(App.Vector(0, 0, fp.height))
|
||||
|
||||
|
||||
@@ -23,10 +23,7 @@ import scipy as sp
|
||||
import FreeCAD as App
|
||||
import Part
|
||||
|
||||
from pygears._functions import (
|
||||
rotation,
|
||||
reflection
|
||||
)
|
||||
from pygears._functions import rotation, reflection
|
||||
|
||||
from .features import BaseGear, fcvec
|
||||
|
||||
@@ -36,8 +33,15 @@ class TimingGearT(BaseGear):
|
||||
print("hello gear")
|
||||
obj.addProperty("App::PropertyLength", "pitch", "base", "pitch of gear")
|
||||
obj.addProperty("App::PropertyInteger", "teeth", "base", "number of teeth")
|
||||
obj.addProperty("App::PropertyLength", "tooth_height", "base", "radial height of tooth")
|
||||
obj.addProperty("App::PropertyLength", "u", "base", "radial distance from tooth-head to pitch circle")
|
||||
obj.addProperty(
|
||||
"App::PropertyLength", "tooth_height", "base", "radial height of tooth"
|
||||
)
|
||||
obj.addProperty(
|
||||
"App::PropertyLength",
|
||||
"u",
|
||||
"base",
|
||||
"radial distance from tooth-head to pitch circle",
|
||||
)
|
||||
obj.addProperty("App::PropertyAngle", "alpha", "base", "angle of tooth flanks")
|
||||
obj.addProperty("App::PropertyLength", "height", "base", "extrusion height")
|
||||
obj.pitch = "5. mm"
|
||||
@@ -48,30 +52,30 @@ class TimingGearT(BaseGear):
|
||||
obj.height = "5 mm"
|
||||
self.obj = obj
|
||||
obj.Proxy = self
|
||||
|
||||
|
||||
def generate_gear_shape(self, fp):
|
||||
print("generate gear shape")
|
||||
pitch = fp.pitch.Value
|
||||
teeth = fp.teeth
|
||||
u = fp.u.Value
|
||||
tooth_height = fp.tooth_height.Value
|
||||
alpha = fp.alpha.Value / 180. * np.pi # we need radiant
|
||||
alpha = fp.alpha.Value / 180.0 * np.pi # we need radiant
|
||||
height = fp.height.Value
|
||||
|
||||
r_p = pitch * teeth / 2. / np.pi
|
||||
r_p = pitch * teeth / 2.0 / np.pi
|
||||
gamma_0 = pitch / r_p
|
||||
gamma_1 = gamma_0 / 4
|
||||
|
||||
p_A = np.array([
|
||||
np.cos(-gamma_1),
|
||||
np.sin(-gamma_1)
|
||||
]) * (r_p - u - tooth_height / 2)
|
||||
|
||||
p_A = np.array([np.cos(-gamma_1), np.sin(-gamma_1)]) * (
|
||||
r_p - u - tooth_height / 2
|
||||
)
|
||||
|
||||
def line(s):
|
||||
p = p_A + np.array([
|
||||
np.cos(alpha / 2 - gamma_1),
|
||||
np.sin(alpha / 2 - gamma_1)
|
||||
]) * s
|
||||
p = (
|
||||
p_A
|
||||
+ np.array([np.cos(alpha / 2 - gamma_1), np.sin(alpha / 2 - gamma_1)])
|
||||
* s
|
||||
)
|
||||
return p
|
||||
|
||||
def dist_p1(s):
|
||||
@@ -79,14 +83,14 @@ class TimingGearT(BaseGear):
|
||||
|
||||
def dist_p2(s):
|
||||
return (np.linalg.norm(line(s)) - (r_p - u)) ** 2
|
||||
|
||||
s1 = sp.optimize.minimize(dist_p1, 0.).x
|
||||
s2 = sp.optimize.minimize(dist_p2, 0.).x
|
||||
|
||||
s1 = sp.optimize.minimize(dist_p1, 0.0).x
|
||||
s2 = sp.optimize.minimize(dist_p2, 0.0).x
|
||||
|
||||
p_1 = line(s1)
|
||||
p_2 = line(s2)
|
||||
|
||||
mirror = reflection(0.) # reflect the points at the x-axis
|
||||
mirror = reflection(0.0) # reflect the points at the x-axis
|
||||
p_3, p_4 = mirror(np.array([p_2, p_1]))
|
||||
|
||||
rot = rotation(-gamma_0) # why is the rotation in wrong direction ???
|
||||
@@ -97,7 +101,7 @@ class TimingGearT(BaseGear):
|
||||
l3 = Part.LineSegment(fcvec(p_3), fcvec(p_4)).toShape()
|
||||
l4 = Part.LineSegment(fcvec(p_4), fcvec(p_5)).toShape()
|
||||
w = Part.Wire([l1, l2, l3, l4])
|
||||
|
||||
|
||||
# now using a FreeCAD Matrix (this will turn in the right direction)
|
||||
rot = App.Matrix()
|
||||
rot.rotateZ(gamma_0)
|
||||
@@ -110,4 +114,4 @@ class TimingGearT(BaseGear):
|
||||
return contour
|
||||
else:
|
||||
face = Part.Face(Part.Wire(wires))
|
||||
return face.extrude(App.Vector(0., 0., height))
|
||||
return face.extrude(App.Vector(0.0, 0.0, height))
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
|
||||
Reference in New Issue
Block a user