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)
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)
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)
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 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))
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]))
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)
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))
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)
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)
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))
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])
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)
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))
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)
def create_teeth(self, pts, pos, teeth): w1 = [] pts = [pt * pos for pt in pts] rotated_pts = scaled_points rot = rotation3D(- 2 * i * np.pi / teeth) for i in range(teeth - 1): rotated_pts = map(rot, rotated_pts) pts.append(np.array([pts[-1][-1], rotated_pts[0][0]])) pts += rotated_pts s = Wire(Shape(w1).Edges) wi = [] for i in range(teeth): rot = App.Matrix() rot.rotateZ(2 * i * np.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))
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))
def execute(self, fp): super(CrownGear, self).execute(fp) inner_diameter = fp.module.Value * fp.teeth outer_diameter = inner_diameter + fp.height.Value * 2 inner_circle = Part.Wire(Part.makeCircle(inner_diameter / 2.)) outer_circle = Part.Wire(Part.makeCircle(outer_diameter / 2.)) inner_circle.reverse() face = Part.Face([outer_circle, inner_circle]) solid = face.extrude(App.Vector([0., 0., -fp.thickness.Value])) # cutting obj alpha_w = np.deg2rad(fp.pressure_angle.Value) m = fp.module.Value t = fp.teeth t_c = t t_i = fp.other_teeth rm = inner_diameter / 2 y0 = m * 0.5 y1 = m + y0 y2 = m r0 = inner_diameter / 2 - fp.height.Value * 0.1 r1 = outer_diameter / 2 + fp.height.Value * 0.3 polies = [] for r_i in np.linspace(r0, r1, fp.num_profiles): pts = self.profile(m, r_i, rm, t_c, t_i, alpha_w, y0, y1, y2) poly = Wire(makePolygon(list(map(fcvec, pts)))) polies.append(poly) loft = makeLoft(polies, True) rot = App.Matrix() rot.rotateZ(2 * np.pi / t) if fp.preview_mode: cut_shapes = [solid] for _ in range(t): loft = loft.transformGeometry(rot) cut_shapes.append(loft) fp.Shape = Part.Compound(cut_shapes) else: for i in range(t): loft = loft.transformGeometry(rot) solid = solid.cut(loft) fp.Shape = solid
def execute(self, fp): xtotal = fp.xsize.Value * fp.xoccurrences ytotal = fp.ysize.Value * fp.yoccurrences #App.Console.PrintMessage("xtotal,ytotal:" + str(xtotal) + "," + str(ytotal) + "\n") e1 = LineSegment(App.Vector(0, 0, 0), App.Vector(xtotal, 0, 0)).toShape().Edges[0] e2 = LineSegment(App.Vector(xtotal, 0, 0), App.Vector(xtotal, ytotal, 0)).toShape().Edges[0] e3 = LineSegment(App.Vector(xtotal, ytotal, 0), App.Vector(0, ytotal, 0)).toShape().Edges[0] e4 = LineSegment(App.Vector(0, ytotal, 0), App.Vector(0, 0, 0)).toShape().Edges[0] w = Wire([e1, e2, e3, e4]) #hole holes = [] for i in range(fp.xoccurrences): for j in range(fp.yoccurrences): holes.append( Part.Wire( Part.makeCircle( fp.holesize.Value / 2, App.Vector(fp.xsize.Value / 2 + i * fp.xsize.Value, fp.ysize.Value / 2 + j * fp.ysize.Value, 0), App.Vector(0, 0, -1)))) face = Part.Face([w] + holes) baseshape = face.extrude(App.Vector(0, 0, fp.height.Value)) if fp.fillet.Value > 0: borders = [] for i in range(12): borders.append(baseshape.Edges[i]) fp.Shape = baseshape.makeFillet(fp.fillet.Value, borders) else: fp.Shape = face.extrude(App.Vector(0, 0, fp.height.Value))
def create_teeth(self, pts, pos, teeth): w1 = [] pts = [pt * pos for pt in pts] rotated_pts = scaled_points rot = rotation3D(-2 * i * pi / teeth) for i in range(teeth - 1): rotated_pts = map(rot, rotated_pts) pts.append(numpy.array([pts[-1][-1], rotated_pts[0][0]])) pts += rotated_pts 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))
def helicalextrusion(wire, height, angle): 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)) solid = auxspine.makePipeShell([wire], True, True) return solid
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)