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]))
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)