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)
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): fp.gear.z = fp.teeth fp.gear.module = fp.m.Value fp.gear.pressure_angle = (90 - fp.pressure_angle.Value) * pi / 180. fp.gear.pitch_angle = fp.pitch_angle.Value * pi / 180 fp.gear.backlash = fp.backlash.Value scale = fp.m.Value * fp.gear.z / 2 / tan( fp.pitch_angle.Value * pi / 180) fp.gear.clearance = fp.clearance / scale fp.gear._update() pts = list(fp.gear.points(num=fp.numpoints)) rot = rotation3D(2 * pi / fp.teeth) if fp.beta != 0: pts = [ np.array([ self.spherical_rot(j, fp.beta.Value * pi / 180.) for j in i ]) for i in pts ] rotated_pts = pts 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]])) wires = [] for scale_i in np.linspace(scale - fp.height.Value / 2, scale + fp.height.Value / 2, 10): print(scale_i) beta_i = (scale_i / scale / np.cos(fp.gear.pitch_angle) - 1) * fp.beta.Value * pi / 180 rot = rotation3D(beta_i) wires.append(makeBSplineWire([rot(pt) * scale_i for pt in pts])) fp.Shape = makeLoft(wires, True)
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): self.bevelgear.z = fp.teeth self.bevelgear.alpha = fp.alpha * pi / 180. self.bevelgear.gamma = fp.gamma * pi / 180 self.bevelgear.backslash = fp.backslash self.bevelgear._update() pts = self.bevelgear.points(num = fp.numpoints) w1 = self.createteeths(pts, fp.m * fp.teeth / 2 / tan(fp.gamma * pi / 180) + fp.height / 2) w2 = self.createteeths(pts, fp.m * fp.teeth / 2 / tan(fp.gamma * pi / 180) - fp.height / 2) fp.Shape = makeLoft([w1,w2],True)
def execute(self, fp): fp.gear.z = fp.teeth fp.gear.module = fp.module.Value fp.gear.pressure_angle = (90 - fp.pressure_angle.Value) * np.pi / 180. fp.gear.pitch_angle = fp.pitch_angle.Value * np.pi / 180 fp.gear.backlash = fp.backlash.Value scale = fp.module.Value * fp.gear.z / 2 / \ np.tan(fp.pitch_angle.Value * np.pi / 180) fp.gear.clearance = fp.clearance / scale fp.gear._update() pts = list(fp.gear.points(num=fp.numpoints)) rot = rotation3D(2 * np.pi / fp.teeth) # if fp.beta.Value != 0: # pts = [np.array([self.spherical_rot(j, fp.beta.Value * np.pi / 180.) for j in i]) for i in pts] rotated_pts = pts 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]])) wires = [] if not "version" in fp.PropertiesList: scale_0 = scale - fp.height.Value / 2 scale_1 = scale + fp.height.Value / 2 else: # starting with version 0.0.2 scale_0 = scale - fp.height.Value scale_1 = scale if fp.beta.Value == 0: wires.append(make_bspline_wire([scale_0 * p for p in pts])) wires.append(make_bspline_wire([scale_1 * p for p in pts])) else: for scale_i in np.linspace(scale_0, scale_1, 20): # beta_i = (scale_i - scale_0) * fp.beta.Value * np.pi / 180 # rot = rotation3D(beta_i) # points = [rot(pt) * scale_i for pt in pts] angle = fp.beta.Value * np.pi / 180. * \ np.sin(np.pi / 4) / \ np.sin(fp.pitch_angle.Value * np.pi / 180.) points = [ np.array( [self.spherical_rot(p, angle) for p in scale_i * pt]) for pt in pts ] wires.append(make_bspline_wire(points)) shape = makeLoft(wires, True) if fp.reset_origin: mat = App.Matrix() mat.A33 = -1 mat.move(fcvec([0, 0, scale_1])) shape = shape.transformGeometry(mat) fp.Shape = shape
def execute(self, fp): fp.gear.z = fp.teeth fp.gear.module = fp.m.Value fp.gear.alpha = fp.alpha.Value * pi / 180. fp.gear.gamma = fp.gamma.Value * pi / 180 fp.gear.backlash = fp.backlash.Value fp.gear.clearence = fp.clearence fp.gear._update() pts = fp.gear.points(num=fp.numpoints) scal1 = fp.m.Value * fp.gear.z / 2 / tan( fp.gamma.Value * pi / 180) - fp.height.Value / 2 scal2 = fp.m.Value * fp.gear.z / 2 / tan( fp.gamma.Value * pi / 180) + fp.height.Value / 2 fp.Shape = makeLoft([self.createteeths(pts, scal1, fp.teeth), self.createteeths(pts, scal2, fp.teeth)], True)
def execute(self, fp): fp.gear.z = fp.teeth fp.gear.module = fp.m.Value fp.gear.pressure_angle = (90 - fp.pressure_angle.Value) * pi / 180. fp.gear.pitch_angle = fp.pitch_angle.Value * pi / 180 fp.gear.backlash = fp.backlash.Value scale = fp.m.Value * fp.gear.z / 2 / tan(fp.pitch_angle.Value * pi / 180) fp.gear.clearance = fp.clearance / scale fp.gear._update() pts = fp.gear.points(num=fp.numpoints) scale1 = scale - fp.height.Value / 2 scale2 = scale + fp.height.Value / 2 fp.Shape = makeLoft([self.create_teeth(pts, scale1, fp.teeth), self.create_teeth(pts, scale2, fp.teeth)], True)
def execute(self, fp): fp.gear.z = fp.teeth fp.gear.module = fp.m.Value fp.gear.pressure_angle = (90 - fp.pressure_angle.Value) * np.pi / 180. fp.gear.pitch_angle = fp.pitch_angle.Value * np.pi / 180 fp.gear.backlash = fp.backlash.Value scale = fp.m.Value * fp.gear.z / 2 / np.tan(fp.pitch_angle.Value * np.pi / 180) fp.gear.clearance = fp.clearance / scale fp.gear._update() pts = list(fp.gear.points(num=fp.numpoints)) rot = rotation3D(2 * np.pi / fp.teeth) # if fp.beta.Value != 0: # pts = [np.array([self.spherical_rot(j, fp.beta.Value * np.pi / 180.) for j in i]) for i in pts] rotated_pts = pts 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]])) wires = [] scale_0 = scale - fp.height.Value / 2 scale_1 = scale + fp.height.Value / 2 if fp.beta.Value == 0: wires.append(makeBSplineWire([scale_0 * p for p in pts])) wires.append(makeBSplineWire([scale_1 * p for p in pts])) else: for scale_i in np.linspace(scale_0, scale_1, 20): # beta_i = (scale_i - scale_0) * fp.beta.Value * np.pi / 180 # rot = rotation3D(beta_i) # points = [rot(pt) * scale_i for pt in pts] angle = fp.beta.Value * np.pi / 180. * np.sin(np.pi / 4) / np.sin(fp.pitch_angle.Value * np.pi / 180.) points = [np.array([self.spherical_rot(p, angle) for p in scale_i * pt]) for pt in pts] wires.append(makeBSplineWire(points)) shape = makeLoft(wires, True) if fp.reset_origin: mat = App.Matrix() mat.A33 = -1 mat.move(fcvec([0, 0, scale_1])) shape = shape.transformGeometry(mat) fp.Shape = shape
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): 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.construct: 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): fp.gear.z = fp.teeth fp.gear.module = fp.m.Value fp.gear.pressure_angle = (90 - fp.pressure_angle.Value) * pi / 180. fp.gear.pitch_angle = fp.pitch_angle.Value * pi / 180 fp.gear.backlash = fp.backlash.Value scale = fp.m.Value * fp.gear.z / 2 / tan( fp.pitch_angle.Value * pi / 180) fp.gear.clearance = fp.clearance / scale fp.gear._update() pts = list(fp.gear.points(num=fp.numpoints)) rotated_pts = pts rot = rotation3D(2 * pi / fp.teeth) 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]])) scale1 = scale - fp.height.Value / 2 scale2 = scale + fp.height.Value / 2 fp.Shape = makeLoft([ makeBSplineWire([pt * scale1 for pt in pts]), makeBSplineWire([pt * scale2 for pt in pts]) ], True)