Exemple #1
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)
Exemple #2
0
def makeBSplineWire(pts):
    wi = []
    for i in pts:
        out = BSplineCurve()
        out.interpolate(list(map(fcvec, i)))
        wi.append(out.toShape())
    return Wire(wi)
Exemple #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)
Exemple #4
0
 def execute(self, fp):
     fp.gear.m_n = fp.module
     fp.gear.z = fp.teeth
     fp.gear.undercut = fp.undercut
     fp.gear.shift = fp.shift
     fp.gear.alpha = fp.alpha * pi / 180.
     fp.gear.beta = fp.beta * pi / 180
     fp.gear.clearence = fp.clearence
     fp.gear.backslash = fp.backslash
     fp.gear._update()
     pts = fp.gear.points(num = fp.numpoints)
     w1 = []
     for i in pts:
         out = BSplineCurve()
         out.interpolate(map(fcvec,i))
         w1.append(out)
     s = Shape(w1)
     wi0 = Wire(s.Edges)
     wi=[]
     for i in range(fp.gear.z):
         rot = App.Matrix()
         rot.rotateZ(i*fp.gear.phipart)
         wi.append(wi0.transformGeometry(rot))
     wi = Wire(wi)
     if fp.beta == 0:
         sh = Face(wi)
         fp.Shape = sh.extrude(App.Vector(0,0,fp.height))            
     else:
         fp.Shape = helicalextrusion(wi, fp.height, fp.height * tan(fp.gear.beta) * 2 / fp.gear.d)
Exemple #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)
Exemple #6
0
 def execute(self, fp):
     self.cycloidegear.m = fp.module
     self.cycloidegear.z = fp.teeth
     self.cycloidegear.d1 = fp.inner_diameter
     self.cycloidegear.d2 = fp.outer_diameter
     self.cycloidegear.clearence = fp.clearence
     self.cycloidegear.backslash = fp.backslash
     self.cycloidegear._update()
     pts = self.cycloidegear.points(num = fp.numpoints)
     w1 = []
     for i in pts:
         out = BSplineCurve()
         out.interpolate(map(fcvec,i))
         w1.append(out)
     s = Shape(w1)
     wi0 = Wire(s.Edges)
     wi=[]
     for i in range(self.cycloidegear.z):
         rot = App.Matrix()
         rot.rotateZ(i*self.cycloidegear.phipart)
         wi.append(wi0.transformGeometry(rot))
     wi = Wire(wi)
     if fp.beta == 0:
         sh = Face(wi)
         fp.Shape = sh.extrude(App.Vector(0,0,fp.height))            
     else:
         fp.Shape = helicalextrusion(wi, fp.height, fp.height * tan(fp.beta * pi / 180) * 2 / self.cycloidegear.d)
Exemple #7
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))
Exemple #8
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)
Exemple #9
0
 def createteeths(self, pts, pos):
     w1=[]
     for i in pts:
         scale = lambda x: x*pos
         i_scale = map(scale, i)
         out = BSplineCurve()
         out.interpolate(map(fcvec3,i_scale))
         w1.append(out)
     s = Shape(w1)
     wi0 = Wire(s.Edges)
     wi=[]
     for i in range(self.bevelgear.z):
         rot = App.Matrix()
         rot.rotateZ(-2*i*pi/self.bevelgear.z)
         wi.append(wi0.transformGeometry(rot)) 
     return(Wire(wi))
Exemple #10
0
    def execute(self, fp):
        fp.gear.m_n = fp.module.Value
        fp.gear.z = fp.teeth
        fp.gear.undercut = fp.undercut
        fp.gear.shift = fp.shift
        fp.gear.alpha = fp.alpha.Value * pi / 180.
        fp.gear.beta = fp.beta.Value * pi / 180
        fp.gear.clearence = fp.clearence
        fp.gear.backlash = fp.backlash.Value
        fp.gear._update()
        pts = fp.gear.points(num=fp.numpoints)
        if not fp.simple:
            wi = []
            for i in pts:
                out = BSplineCurve()
                out.interpolate(map(fcvec, i))
                wi.append(out)
            s = Wire(Shape(wi).Edges)
            wi = []
            for i in range(fp.gear.z):
                rot = App.Matrix()
                rot.rotateZ(-i * fp.gear.phipart)
                tooth_rot = s.transformGeometry(rot)
                if i != 0:
                    pt_0 = wi[-1].Edges[-1].Vertexes[0].Point
                    pt_1 = tooth_rot.Edges[0].Vertexes[-1].Point
                    wi.append(Wire([Line(pt_0, pt_1).toShape()]))
                wi.append(tooth_rot)
            pt_0 = wi[-1].Edges[-1].Vertexes[0].Point
            pt_1 = wi[0].Edges[0].Vertexes[-1].Point
            wi.append(Wire([Line(pt_0, pt_1).toShape()]))

            wi = Wire(wi)
            fp.Shape = 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)
        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))
Exemple #11
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))
Exemple #12
0
 def createteeths(self, pts, pos, teeth):
     w1 = []
     for i in pts:
         scale = lambda x: x * pos
         i_scale = map(scale, i)
         out = BSplineCurve()
         out.interpolate(map(fcvec, i_scale))
         w1.append(out)
     s = Wire(Shape(w1).Edges)
     wi = []
     for i in range(teeth):
         rot = App.Matrix()
         rot.rotateZ(2 * i * pi / teeth)
         tooth_rot = s.transformGeometry(rot)
         if i != 0:
             pt_0 = wi[-1].Edges[-1].Vertexes[0].Point
             pt_1 = tooth_rot.Edges[0].Vertexes[-1].Point
             wi.append(Wire([Line(pt_0, pt_1).toShape()]))
         wi.append(tooth_rot)
     pt_0 = wi[-1].Edges[-1].Vertexes[0].Point
     pt_1 = wi[0].Edges[0].Vertexes[-1].Point
     wi.append(Wire([Line(pt_0, pt_1).toShape()]))
     return(Wire(wi))
Exemple #13
0
 def execute(self, fp):
     pass
     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.clearence = fp.clearence
     fp.gear.backlash = fp.backlash.Value
     fp.gear._update()
     pts = fp.gear.points(num=fp.numpoints)
     wi = []
     for i in pts:
         out = BSplineCurve()
         out.interpolate(map(fcvec, i))
         wi.append(out)
     s = Wire(Shape(wi).Edges)
     wi = []
     for i in range(fp.gear.z):
         rot = App.Matrix()
         rot.rotateZ(-i * fp.gear.phipart)
         tooth_rot = s.transformGeometry(rot)
         if i != 0:
             pt_0 = wi[-1].Edges[-1].Vertexes[0].Point
             pt_1 = tooth_rot.Edges[0].Vertexes[-1].Point
             wi.append(Wire([Line(pt_0, pt_1).toShape()]))
         wi.append(tooth_rot)
     pt_0 = wi[-1].Edges[-1].Vertexes[0].Point
     pt_1 = wi[0].Edges[0].Vertexes[-1].Point
     wi.append(Wire([Line(pt_0, pt_1).toShape()]))
     wi = Wire(wi)
     if fp.beta.Value == 0:
         sh = Face(wi)
         fp.Shape = sh.extrude(App.Vector(0, 0, fp.height.Value))
     else:
         pass
         fp.Shape = helicalextrusion(
             wi, fp.height.Value, fp.height.Value * tan(fp.beta.Value * pi / 180) * 2 / fp.gear.d)
Exemple #14
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)