Esempio n. 1
0
    def execute(self, fp):
        super(LanternGear, self).execute(fp)
        m = fp.module.Value
        teeth = fp.teeth
        r_r = fp.bolt_radius.Value
        r_0 = m * teeth / 2
        r_max = r_0 + r_r + fp.head * m

        phi_max = (r_r + np.sqrt(r_max**2 - r_0**2)) / r_0

        def find_phi_min(phi_min):
            return r_0*(phi_min**2*r_0 - 2*phi_min*r_0*np.sin(phi_min) - \
                   2*phi_min*r_r - 2*r_0*np.cos(phi_min) + 2*r_0 + 2*r_r*np.sin(phi_min))
        try:
            import scipy.optimize
            phi_min = scipy.optimize.root(find_phi_min, (phi_max + r_r / r_0 * 4) / 5).x[0] # , r_r / r_0, phi_max)
        except ImportError:
            App.Console.PrintWarning("scipy not available. Can't compute numerical root. Leads to a wrong bolt-radius")
            phi_min = r_r / r_0

        # phi_min = 0 # r_r / r_0
        phi = np.linspace(phi_min, phi_max, fp.num_profiles)
        x = r_0 * (np.cos(phi) + phi * np.sin(phi)) - r_r * np.sin(phi)
        y = r_0 * (np.sin(phi) - phi * np.cos(phi)) + r_r * np.cos(phi)
        xy1 = np.array([x, y]).T
        p_1 = xy1[0]
        p_1_end = xy1[-1]
        bsp_1 = BSplineCurve()
        bsp_1.interpolate(list(map(fcvec, xy1)))
        w_1 = bsp_1.toShape()

        xy2 = xy1 * np.array([1., -1.])
        p_2 = xy2[0]
        p_2_end = xy2[-1]
        bsp_2 = BSplineCurve()
        bsp_2.interpolate(list(map(fcvec, xy2)))
        w_2 = bsp_2.toShape()

        p_12 = np.array([r_0 - r_r, 0.])

        arc = Part.Arc(App.Vector(*p_1, 0.), App.Vector(*p_12, 0.), App.Vector(*p_2, 0.)).toShape()

        rot = rotation(-np.pi * 2 / teeth)
        p_3 = rot(np.array([p_2_end]))[0]
        # l = Part.LineSegment(fcvec(p_1_end), fcvec(p_3)).toShape()
        l = part_arc_from_points_and_center(p_1_end, p_3, np.array([0., 0.])).toShape()
        w = Part.Wire([w_2, arc, w_1, l])
        wires = [w]

        rot = App.Matrix()
        for _ in range(teeth - 1):
            rot.rotateZ(np.pi * 2 / teeth)
            wires.append(w.transformGeometry(rot))

        wi = Part.Wire(wires)
        if fp.height.Value == 0:
            fp.Shape = wi
        else:
            fp.Shape = Part.Face(wi).extrude(App.Vector(0, 0, fp.height))
Esempio n. 2
0
 def execute(self, fp):
     fp.gear.m = fp.module.Value
     fp.gear.z = fp.teeth
     fp.gear.z1 = fp.inner_diameter.Value
     fp.gear.z2 = fp.outer_diameter.Value
     fp.gear.clearance = fp.clearance
     fp.gear.backlash = fp.backlash.Value
     fp.gear._update()
     pts = fp.gear.points(num=fp.numpoints)
     rotated_pts = pts
     rot = rotation(-fp.gear.phipart)
     for i in range(fp.gear.z - 1):
         rotated_pts = list(map(rot, rotated_pts))
         pts.append(np.array([pts[-1][-1], rotated_pts[0][0]]))
         pts += rotated_pts
     pts.append(np.array([pts[-1][-1], pts[0][0]]))
     wi = []
     for i in pts:
         out = BSplineCurve()
         out.interpolate(list(map(fcvec, i)))
         wi.append(out.toShape())
     wi = Wire(wi)
     if fp.height.Value == 0:
         fp.Shape = wi
     elif fp.beta.Value == 0:
         sh = Face(wi)
         fp.Shape = sh.extrude(App.Vector(0, 0, fp.height.Value))
     else:
         fp.Shape = helicalextrusion(
             wi, fp.height.Value, fp.height.Value * np.tan(fp.beta.Value * np.pi / 180) * 2 / fp.gear.d, fp.double_helix)
Esempio n. 3
0
def make_bspline_wire(pts):
    wi = []
    for i in pts:
        out = BSplineCurve()
        out.interpolate(list(map(fcvec, i)))
        wi.append(out.toShape())
    return Wire(wi)
Esempio n. 4
0
def makeBSplineWire(pts):
    wi = []
    for i in pts:
        out = BSplineCurve()
        out.interpolate(list(map(fcvec, i)))
        wi.append(out.toShape())
    return Wire(wi)
Esempio n. 5
0
 def execute(self, fp):
     fp.gear.m = fp.module.Value
     fp.gear.z = fp.teeth
     fp.gear.z1 = fp.inner_diameter.Value
     fp.gear.z2 = fp.outer_diameter.Value
     fp.gear.clearance = fp.clearance
     fp.gear.backlash = fp.backlash.Value
     fp.gear._update()
     pts = fp.gear.points(num=fp.numpoints)
     rotated_pts = pts
     rot = rotation(-fp.gear.phipart)
     for i in range(fp.gear.z - 1):
         rotated_pts = list(map(rot, rotated_pts))
         pts.append(np.array([pts[-1][-1], rotated_pts[0][0]]))
         pts += rotated_pts
     pts.append(np.array([pts[-1][-1], pts[0][0]]))
     wi = []
     for i in pts:
         out = BSplineCurve()
         out.interpolate(list(map(fcvec, i)))
         wi.append(out.toShape())
     wi = Wire(wi)
     if fp.beta.Value == 0:
         sh = Face(wi)
         fp.Shape = sh.extrude(App.Vector(0, 0, fp.height.Value))
     else:
         fp.Shape = helicalextrusion(
             wi, fp.height.Value, fp.height.Value * np.tan(fp.beta.Value * np.pi / 180) * 2 / fp.gear.d, fp.double_helix)
Esempio n. 6
0
    def execute(self, fp):
        super(InvoluteGear, self).execute(fp)
        fp.gear.double_helix = fp.double_helix
        fp.gear.m_n = fp.module.Value
        fp.gear.z = fp.teeth
        fp.gear.undercut = fp.undercut
        fp.gear.shift = fp.shift
        fp.gear.pressure_angle = fp.pressure_angle.Value * np.pi / 180.
        fp.gear.beta = fp.beta.Value * np.pi / 180
        fp.gear.clearance = fp.clearance
        fp.gear.backlash = fp.backlash.Value * \
            (-fp.reversed_backlash + 0.5) * 2.
        fp.gear.head = fp.head
        # checksbackwardcompatibility:
        if "properties_from_tool" in fp.PropertiesList:
            fp.gear.properties_from_tool = fp.properties_from_tool
        fp.gear._update()
        pts = fp.gear.points(num=fp.numpoints)
        rotated_pts = pts
        rot = rotation(-fp.gear.phipart)
        for i in range(fp.gear.z - 1):
            rotated_pts = list(map(rot, rotated_pts))
            pts.append(np.array([pts[-1][-1], rotated_pts[0][0]]))
            pts += rotated_pts
        pts.append(np.array([pts[-1][-1], pts[0][0]]))
        if not fp.simple:
            wi = []
            for i in pts:
                out = BSplineCurve()
                out.interpolate(list(map(fcvec, i)))
                wi.append(out.toShape())
            wi = Wire(wi)
            if fp.height.Value == 0:
                fp.Shape = wi
            elif fp.beta.Value == 0:
                sh = Face(wi)
                fp.Shape = sh.extrude(App.Vector(0, 0, fp.height.Value))
            else:
                fp.Shape = helicalextrusion(
                    wi, fp.height.Value, fp.height.Value * np.tan(fp.gear.beta) * 2 / fp.gear.d, fp.double_helix)
        else:
            rw = fp.gear.dw / 2
            fp.Shape = Part.makeCylinder(rw, fp.height.Value)

        # computed properties
        fp.dw = "{}mm".format(fp.gear.dw)
        fp.transverse_pitch = "{}mm".format(fp.gear.pitch)
        # checksbackwardcompatibility:
        if not "da" in fp.PropertiesList:
            self.add_limiting_diameter_properties(fp)
        fp.da = "{}mm".format(fp.gear.da)
        fp.df = "{}mm".format(fp.gear.df)
Esempio n. 7
0
 def execute(self, fp):
     fp.gear.double_helix = fp.double_helix
     fp.gear.m_n = fp.module.Value
     fp.gear.z = fp.teeth
     fp.gear.undercut = fp.undercut
     fp.gear.shift = fp.shift
     fp.gear.pressure_angle = fp.pressure_angle.Value * pi / 180.
     fp.gear.beta = fp.beta.Value * pi / 180
     fp.gear.clearance = fp.clearance
     fp.gear.backlash = fp.backlash.Value * (-fp.reversed_backlash +
                                             0.5) * 2.
     fp.gear.head = fp.head
     fp.gear._update()
     pts = fp.gear.points(num=fp.numpoints)
     rotated_pts = pts
     rot = rotation(-fp.gear.phipart)
     for i in range(fp.gear.z - 1):
         rotated_pts = list(map(rot, rotated_pts))
         pts.append(numpy.array([pts[-1][-1], rotated_pts[0][0]]))
         pts += rotated_pts
     pts.append(numpy.array([pts[-1][-1], pts[0][0]]))
     if not fp.simple:
         wi = []
         for i in pts:
             out = BSplineCurve()
             out.interpolate(list(map(fcvec, i)))
             wi.append(out.toShape())
         wi = Wire(wi)
         if fp.beta.Value == 0:
             sh = Face(wi)
             fp.Shape = sh.extrude(App.Vector(0, 0, fp.height.Value))
         else:
             fp.Shape = helicalextrusion(
                 wi, fp.height.Value,
                 fp.height.Value * tan(fp.gear.beta) * 2 / fp.gear.d,
                 fp.double_helix)
     else:
         rw = fp.gear.dw / 2
         circle = Part.Circle(App.Vector(0, 0, 0), App.Vector(0, 0, 1), rw)
         wire = Part.Wire(circle.toShape())
         face = Part.Face(wire)
         fp.Shape = face.extrude(App.Vector(0, 0, fp.height.Value))
Esempio n. 8
0
 def execute(self, fp):
     fp.gear.double_helix = fp.double_helix
     fp.gear.m_n = fp.module.Value
     fp.gear.z = fp.teeth
     fp.gear.undercut = fp.undercut
     fp.gear.shift = fp.shift
     fp.gear.pressure_angle = fp.pressure_angle.Value * np.pi / 180.
     fp.gear.beta = fp.beta.Value * np.pi / 180
     fp.gear.clearance = fp.clearance
     fp.gear.backlash = fp.backlash.Value * (-fp.reversed_backlash + 0.5) * 2.
     fp.gear.head = fp.head
     fp.gear._update()
     pts = fp.gear.points(num=fp.numpoints)
     rotated_pts = pts
     rot = rotation(-fp.gear.phipart)
     for i in range(fp.gear.z - 1):
         rotated_pts = list(map(rot, rotated_pts))
         pts.append(np.array([pts[-1][-1], rotated_pts[0][0]]))
         pts += rotated_pts
     pts.append(np.array([pts[-1][-1], pts[0][0]]))
     if not fp.simple:
         wi = []
         for i in pts:
             out = BSplineCurve()
             out.interpolate(list(map(fcvec, i)))
             wi.append(out.toShape())
         wi = Wire(wi)
         if fp.beta.Value == 0:
             sh = Face(wi)
             fp.Shape = sh.extrude(App.Vector(0, 0, fp.height.Value))
         else:
             fp.Shape = helicalextrusion(
                 wi, fp.height.Value, fp.height.Value * np.tan(fp.gear.beta) * 2 / fp.gear.d, fp.double_helix)
     else:
         rw = fp.gear.dw / 2
         fp.Shape=Part.makeCylinder(rw,fp.height.Value)