Esempio n. 1
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)
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 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)
Esempio n. 4
0
 def execute(self, fp):
     fp.rack.m = fp.module.Value
     fp.rack.z = fp.teeth
     fp.rack.pressure_angle = fp.pressure_angle.Value * np.pi / 180.
     fp.rack.thickness = fp.thickness.Value
     fp.rack.beta = fp.beta.Value * np.pi / 180.
     fp.rack.head = fp.head
     fp.rack._update()
     pts = fp.rack.points()
     pol = Wire(makePolygon(list(map(fcvec, pts))))
     if fp.beta.Value == 0:
         face = Face(Wire(pol))
         fp.Shape = face.extrude(fcvec([0., 0., fp.height.Value]))
     elif fp.double_helix:
         beta = fp.beta.Value * np.pi / 180.
         pol2 = Part.Wire(pol)
         pol2.translate(fcvec([0., np.tan(beta) * fp.height.Value / 2, fp.height.Value / 2]))
         pol3 = Part.Wire(pol)
         pol3.translate(fcvec([0., 0., fp.height.Value]))
         fp.Shape = makeLoft([pol, pol2, pol3], True, True)
     else:
         beta = fp.beta.Value * np.pi / 180.
         pol2 = Part.Wire(pol)
         pol2.translate(fcvec([0., np.tan(beta) * fp.height.Value, fp.height.Value]))
         fp.Shape = makeLoft([pol, pol2], True)
Esempio n. 5
0
def helicalextrusion(wire, height, angle):
    face_a = Face(wire)
    face_b = face_a.copy()
    face_transform = App.Matrix()
    face_transform.rotateZ(angle)
    face_transform.move(App.Vector(0, 0, height))
    face_b.transformShape(face_transform)
    spine = Wire(Line(fcvec([0., 0, 0]), fcvec([0, 0, height])).toShape())
    auxspine = makeHelix(height * 2 * pi / abs(angle), height, 10., 0,
                         bool(angle < 0))
    faces = [face_a, face_b]
    pipeshell = BRepOffsetAPI.MakePipeShell(spine)
    pipeshell.setSpineSupport(spine)
    pipeshell.add(wire)
    pipeshell.setAuxiliarySpine(auxspine, True, False)
    assert (pipeshell.isReady())
    pipeshell.build()
    faces.extend(pipeshell.shape().Faces)

    fullshell = Shell(faces)
    solid = Solid(fullshell)
    if solid.Volume < 0:
        solid.reverse()
    assert (solid.Volume >= 0)
    return (solid)
Esempio n. 6
0
def helicalextrusion(wire, height, angle):
    face_a = Face(wire)
    face_b = face_a.copy()
    face_transform = App.Matrix()
    face_transform.rotateZ(angle)
    face_transform.move(App.Vector(0,0,height))
    face_b . transformShape(face_transform)
    step = 2 + int(angle / pi * 4 )
    angleinc = angle / (step - 1)
    zinc = height / (step-1)
    spine = makePolygon([(0, 0, i * zinc) for i in range(step)])
    auxspine = makePolygon(
        [
            (cos(i * angleinc),
            sin(i * angleinc),
            i * height/(step-1))for i in range(step)
        ])
    faces=[face_a,face_b ] 
    pipeshell = BRepOffsetAPI.MakePipeShell(spine)
    pipeshell.setSpineSupport(spine)
    pipeshell.add(wire)
    pipeshell.setAuxiliarySpine(auxspine,True,False)
    assert(pipeshell.isReady())
    pipeshell.build()
    faces.extend(pipeshell.shape().Faces)

    fullshell = Shell(faces)
    solid = Solid(fullshell)
    if solid.Volume < 0:
        solid.reverse()
    assert(solid.Volume >= 0)
    return(solid)
Esempio n. 7
0
 def execute1(self, fp):
     fp.gear.z = fp.teeth
     fp.gear.alpha = fp.alpha.Value * pi / 180.
     fp.gear.gamma = fp.gamma.Value * pi / 180
     fp.gear.backlash = fp.backlash
     fp.gear._update()
     pts = fp.gear.points(num=fp.numpoints)
     tooth = self.create_tooth()
     teeth = [tooth]
     rot = App.Matrix()
     rot.rotateZ(2  * pi / fp.teeth)
     top_cap = [i.Edges[0] for i in tooth.Faces]
     bottom_cap = [i.Edges[3] for i in tooth.Faces]
     for i in range(fp.teeth - 1): 
         new_tooth = teeth[-1].transformGeometry(rot)
         edge1 = new_tooth.Faces[0].Edges[2]
         edge2 = teeth[-1].Faces[-1].Edges[1]
         face1 = make_face(edge1, edge2)
         teeth.append(face1)
         teeth.append(new_tooth)
         top_cap.append(face1.Edges[3])
         bottom_cap.append(face1.Edges[1])
         top_cap += [i.Edges[0] for i in new_tooth.Faces]
         bottom_cap += [i.Edges[3] for i in new_tooth.Faces]
     edge1 = teeth[0].Faces[0].Edges[2]
     edge2 = teeth[-1].Faces[-1].Edges[1]
     face1 = make_face(edge1, edge2)
     teeth.append(face1)
     top_cap.append(face1.Edges[3])
     bottom_cap.append(face1.Edges[1])
     top_cap = Face(Wire(top_cap))
     bottom_cap = Face(Wire(bottom_cap))
     fcs = Compound(teeth).Faces
     top_cap.reverse()
     fp.Shape = Solid(Shell(fcs + [top_cap, bottom_cap]))
Esempio n. 8
0
 def execute1(self, fp):
     fp.gear.z = fp.teeth
     fp.gear.pressure_angle = fp.pressure_angle.Value * pi / 180.
     fp.gear.pitch_angle = fp.pitch_angle.Value * pi / 180
     fp.gear.backlash = fp.backlash
     fp.gear._update()
     pts = fp.gear.points(num=fp.numpoints)
     tooth = self.create_tooth()
     teeth = [tooth]
     rot = App.Matrix()
     rot.rotateZ(2 * pi / fp.teeth)
     top_cap = [i.Edges[0] for i in tooth.Faces]
     bottom_cap = [i.Edges[3] for i in tooth.Faces]
     for i in range(fp.teeth - 1):
         new_tooth = teeth[-1].transformGeometry(rot)
         edge1 = new_tooth.Faces[0].Edges[2]
         edge2 = teeth[-1].Faces[-1].Edges[1]
         face1 = make_face(edge1, edge2)
         teeth.append(face1)
         teeth.append(new_tooth)
         top_cap.append(face1.Edges[3])
         bottom_cap.append(face1.Edges[1])
         top_cap += [i.Edges[0] for i in new_tooth.Faces]
         bottom_cap += [i.Edges[3] for i in new_tooth.Faces]
     edge1 = teeth[0].Faces[0].Edges[2]
     edge2 = teeth[-1].Faces[-1].Edges[1]
     face1 = make_face(edge1, edge2)
     teeth.append(face1)
     top_cap.append(face1.Edges[3])
     bottom_cap.append(face1.Edges[1])
     top_cap = Face(Wire(top_cap))
     bottom_cap = Face(Wire(bottom_cap))
     fcs = Compound(teeth).Faces
     top_cap.reverse()
     fp.Shape = Solid(Shell(fcs + [top_cap, bottom_cap]))
Esempio n. 9
0
 def execute(self, fp):
     fp.rack.m = fp.module.Value
     fp.rack.z = fp.teeth
     fp.rack.pressure_angle = fp.pressure_angle.Value * pi / 180.
     fp.rack.thickness = fp.thickness.Value
     fp.rack.beta = fp.beta.Value * pi / 180.
     fp.rack.head = fp.head
     fp.rack._update()
     pts = fp.rack.points()
     pol = Wire(makePolygon(list(map(fcvec, pts))))
     if fp.beta.Value == 0:
         face = Face(Wire(pol))
         fp.Shape = face.extrude(fcvec([0., 0., fp.height.Value]))
     elif fp.double_helix:
         beta = fp.beta.Value * pi / 180.
         pol2 = Part.Wire(pol)
         pol2.translate(
             fcvec(
                 [0.,
                  tan(beta) * fp.height.Value / 2, fp.height.Value / 2]))
         pol3 = Part.Wire(pol)
         pol3.translate(fcvec([0., 0., fp.height.Value]))
         fp.Shape = makeLoft([pol, pol2, pol3], True, True)
     else:
         beta = fp.beta.Value * pi / 180.
         pol2 = Part.Wire(pol)
         pol2.translate(
             fcvec([0., tan(beta) * fp.height.Value, fp.height.Value]))
         fp.Shape = makeLoft([pol, pol2], True)
Esempio n. 10
0
def split_face_with_scales(
    face: Part.Face,
    scales: list = [.75, .5],
) -> list:
    from BOPTools.GeneralFuseResult import GeneralFuseResult
    s1 = face.copy().scale(scales[0])
    s2 = face.copy().scale(scales[1])
    center_of_mass = face.CenterOfMass
    tr1 = center_of_mass.sub(s1.CenterOfMass)
    s1.Placement.Base = tr1
    tr2 = center_of_mass.sub(s2.CenterOfMass)
    s2.Placement.Base = tr2
    area1 = face.cut(s1)
    area2 = s1.cut(s2)
    e1, e2 = sorted(face.Edges, key=lambda x: x.Length, reverse=True)[0:2]
    v1 = e1.CenterOfMass
    v2 = e2.CenterOfMass
    poly = Part.makePolygon([v1, center_of_mass, v2])
    faces = []
    for area in (area1, area2):
        pieces, map_ = area.generalFuse([poly])
        gr = GeneralFuseResult([area, poly], (pieces, map_))
        gr.splitAggregates()
        comp = Part.Compound(gr.pieces)
        faces.extend(comp.Faces)
    faces.append(Part.Face(s2))
    return faces
Esempio n. 11
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. 12
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. 13
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))
Esempio n. 14
0
 def execute(self, fp):
     fp.rack.m = fp.module.Value
     fp.rack.z = fp.teeth
     fp.rack.pressure_angle = fp.pressure_angle.Value * np.pi / 180.
     fp.rack.thickness = fp.thickness.Value
     fp.rack.beta = fp.beta.Value * np.pi / 180.
     fp.rack.head = fp.head
     # checksbackwardcompatibility:
     if "clearance" in fp.PropertiesList:
         fp.rack.clearance = fp.clearance
     if "properties_from_tool" in fp.PropertiesList:
         fp.rack.properties_from_tool = fp.properties_from_tool
     if "add_endings" in fp.PropertiesList:
         fp.rack.add_endings = fp.add_endings
     if "simplified" in fp.PropertiesList:
         fp.rack.simplified = fp.simplified
     fp.rack._update()
     pts = fp.rack.points()
     pol = Wire(makePolygon(list(map(fcvec, pts))))
     if fp.height.Value == 0:
         fp.Shape = pol
     elif fp.beta.Value == 0:
         face = Face(Wire(pol))
         fp.Shape = face.extrude(fcvec([0., 0., fp.height.Value]))
     elif fp.double_helix:
         beta = fp.beta.Value * np.pi / 180.
         pol2 = Part.Wire(pol)
         pol2.translate(
             fcvec([
                 0.,
                 np.tan(beta) * fp.height.Value / 2, fp.height.Value / 2
             ]))
         pol3 = Part.Wire(pol)
         pol3.translate(fcvec([0., 0., fp.height.Value]))
         fp.Shape = makeLoft([pol, pol2, pol3], True, True)
     else:
         beta = fp.beta.Value * np.pi / 180.
         pol2 = Part.Wire(pol)
         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])
Esempio n. 15
0
def make_face(edge1, edge2):
    v1, v2 = edge1.Vertexes
    v3, v4 = edge2.Vertexes
    e1 = Wire(edge1)
    e2 = Line(v1.Point, v3.Point).toShape().Edges[0]
    e3 = edge2
    e4 = Line(v4.Point, v2.Point).toShape().Edges[0]
    w = Wire([e3, e4, e1, e2])
    return(Face(w))
Esempio n. 16
0
 def execute(self, fp):
     fp.rack.m = fp.module.Value
     fp.rack.z = fp.teeth
     fp.rack.pressure_angle = fp.pressure_angle.Value * pi / 180.
     fp.rack.thickness = fp.thickness.Value
     fp.rack._update()
     pts = fp.rack.points()
     pol = Wire(makePolygon(list(map(fcvec, pts))))
     fp.Shape = Face(Wire(pol)).extrude(fcvec([0., 0., fp.height]))
Esempio n. 17
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. 18
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)
Esempio n. 19
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)
Esempio n. 20
0
def helicalextrusion(wire, height, angle):
    face_a = Face(wire)
    face_b = face_a.copy()
    face_transform = App.Matrix()
    face_transform.rotateZ(angle)
    face_transform.move(App.Vector(0, 0, height))
    face_b . transformShape(face_transform)
    spine = Wire(Line(fcvec([0., 0, 0]), fcvec([0, 0, height])).toShape())
    auxspine = makeHelix(height * 2 * pi / angle, height, 1.)
    faces = [face_a, face_b]
    pipeshell = BRepOffsetAPI.MakePipeShell(spine)
    pipeshell.setSpineSupport(spine)
    pipeshell.add(wire)
    pipeshell.setAuxiliarySpine(auxspine, True, False)
    assert(pipeshell.isReady())
    pipeshell.build()
    faces.extend(pipeshell.shape().Faces)

    fullshell = Shell(faces)
    solid = Solid(fullshell)
    if solid.Volume < 0:
        solid.reverse()
    assert(solid.Volume >= 0)
    return(solid)
Esempio n. 21
0
    def execute(self,fp):
        b = fp.pin_circle_radius
        d = fp.roller_diameter
        e = fp.eccentricity
        n = fp.teeth_number
        p = b/n
        s = fp.segment_count
        ang = fp.pressure_angle_lim
        c = fp.pressure_angle_offset

        q = 2*math.pi/float(s)

        # Find the pressure angle limit circles
        minAngle = -1.0
        maxAngle = -1.0
        for i in range(0, 180):
            x = self.calc_pressure_angle(p, d, n, i * math.pi / 180.)
            if ( x < ang) and (minAngle < 0):
                minAngle = float(i)
            if (x < -ang) and (maxAngle < 0):
                maxAngle = float(i-1)

        minRadius = self.calc_pressure_limit(p, d, e, n, minAngle * math.pi / 180.)
        maxRadius = self.calc_pressure_limit(p, d, e, n, maxAngle * math.pi / 180.)
        # unused
        # Wire(Part.makeCircle(minRadius,App.Vector(-e, 0, 0)))
        # Wire(Part.makeCircle(maxRadius,App.Vector(-e, 0, 0)))

        App.Console.PrintMessage("Generating cam disk\r\n")
        #generate the cam profile - note: shifted in -x by eccentricicy amount
        i=0
        x = self.calc_x(p, d, e, n, q*i / float(n))
        y = self.calc_y(p, d, e, n, q*i / n)
        x, y = self.check_limit(x,y,maxRadius,minRadius,c)
        points = [App.Vector(x-e, y, 0)]
        for i in range(0,s):
            x = self.calc_x(p, d, e, n, q*(i+1) / n)
            y = self.calc_y(p, d, e, n, q*(i+1) / n)
            x, y = self.check_limit(x, y, maxRadius, minRadius, c)
            points.append([x-e, y, 0])

        wi = make_bspline_wire([points])
        wires = []
        mat= App.Matrix()
        mat.move(App.Vector(e, 0., 0.))
        mat.rotateZ(2 * np.pi / n)
        mat.move(App.Vector(-e, 0., 0.))
        for _ in range(n):
            wi = wi.transformGeometry(mat)
            wires.append(wi)

        cam = Face(Wire(wires))
        #add a circle in the center of the cam
        if fp.hole_radius.Value:
            centerCircle = Face(Wire(Part.makeCircle(fp.hole_radius.Value, App.Vector(-e, 0, 0))))
            cam = cam.cut(centerCircle)

        to_be_fused = []
        if fp.show_disk0==True:
            if fp.disk_height.Value==0:
                to_be_fused.append(cam)
            else:
                to_be_fused.append(cam.extrude(App.Vector(0, 0, fp.disk_height.Value)))

        #secondary cam disk
        if fp.show_disk1==True:
            App.Console.PrintMessage("Generating secondary cam disk\r\n")
            second_cam = cam.copy()
            mat= App.Matrix()
            mat.rotateZ(np.pi)
            mat.move(App.Vector(-e, 0, 0))
            if n%2 == 0:
                mat.rotateZ(np.pi/n)
            mat.move(App.Vector(e, 0, 0))
            second_cam = second_cam.transformGeometry(mat)
            if fp.disk_height.Value==0:
                to_be_fused.append(second_cam)
            else:
                to_be_fused.append(second_cam.extrude(App.Vector(0, 0, -fp.disk_height.Value)))

        #pins
        if fp.show_pins==True:
            App.Console.PrintMessage("Generating pins\r\n")
            pins = []
            for i in range(0, n + 1):
                x = p * n * math.cos(2 * math.pi / (n + 1) * i)
                y = p * n * math.sin(2 * math.pi / (n + 1) * i)
                pins.append(Wire(Part.makeCircle(d / 2, App.Vector(x, y, 0))))

            pins = Face(pins)

            z_offset = -fp.pin_height.Value / 2;

            if fp.center_pins==True:
                if fp.show_disk0==True and fp.show_disk1==False:
                    z_offset += fp.disk_height.Value / 2;
                elif fp.show_disk0==False and fp.show_disk1==True:
                    z_offset += -fp.disk_height.Value / 2;
            #extrude
            if z_offset!=0:
                pins.translate(App.Vector(0, 0, z_offset))
            if fp.pin_height!=0:
                pins = pins.extrude(App.Vector(0, 0, fp.pin_height.Value))

            to_be_fused.append(pins);

        if to_be_fused:
            fp.Shape = Part.makeCompound(to_be_fused)