def crest_simulation_A(c): """ define the crest simulation """ # inherit from gear_profile i_gear_profile = gear_profile.gear_profile() i_gear_profile.apply_external_constraint(gear_profile_constraint(c)) i_gear_profile.run_simulation('gear_profile_simulation_A') return(1)
def inherit_gear_profile(): """ generate a small constraint set to be able to create the gear_profile-object for gearbar """ gp_c = {} gp_c['gear_type'] = 'l' gp_c['second_gear_type'] = 'e' gp_c['gearbar_slope'] = 0.3 #hack the default value of gear_profile.gearbar_slope i_gear_profile = gear_profile.gear_profile(gp_c) return(i_gear_profile)
def inherit_gear_profile(): """ generate a small constraint set to be able to create the gear_profile-object for gearbar """ gp_c = {} gp_c['gear_type'] = 'l' gp_c['second_gear_type'] = 'e' gp_c[ 'gearbar_slope'] = 0.3 #hack the default value of gear_profile.gearbar_slope i_gear_profile = gear_profile.gear_profile(gp_c) return (i_gear_profile)
def crest_constraint_constructor(ai_parser, ai_variant=0): """ Add arguments relative to the crest """ r_parser = ai_parser # parameter inheritance from cross_cube_sub r_parser = cross_cube_sub.cross_cube_sub_constraint_constructor(r_parser, 2) # parameter inheritance from gear_profile i_gear_profile = gear_profile.gear_profile() r_parser = i_gear_profile.get_constraint_constructor()(r_parser, 4) ### outline r_parser.add_argument('--gear_module','--gm', action='store', type=float, default=3.0, help="Set the gear-module of the crest. Default: 3.0") r_parser.add_argument('--virtual_tooth_nb','--vtn', action='store', type=int, default=60, help="Set the virtual number of gear-teeth of the crest. Default: 60") r_parser.add_argument('--portion_tooth_nb','--ptn', action='store', type=int, default=30, help="Set the number of teeth of the gear-portion of the crest. Default: 30") r_parser.add_argument('--free_mounting_width','--fmw', action='store', type=float, default=15.0, help="Set the width that must be kept free to mount the crest in a cross_cube (minimum: face_B1_thickness + cnc_router_bit_radius). Default: 15.0") ### crest_hollow r_parser.add_argument('--crest_hollow_leg_nb','--chln', action='store', type=int, default=4, help="Set the number of crest-hollow_legs. Possible values: 1(filled), 2(end-legs only), 3, 4, etc. Default: 4") r_parser.add_argument('--end_leg_width','--elw', action='store', type=float, default=10.0, help="Set the width of the two end-legs of the crest. Default: 10.0") r_parser.add_argument('--middle_leg_width','--mlw', action='store', type=float, default=0.0, help="Set the width of the middle-legs of the crest. If equal to 0.0, set to end_leg_width. Default: 0.0") r_parser.add_argument('--crest_hollow_external_diameter','--ched', action='store', type=float, default=0.0, help="Set the diameter of the crest-hollow-external circle. If equal to 0.0, set to gear_hollow_radius - delta. Default: 0.0") r_parser.add_argument('--crest_hollow_internal_diameter','--chid', action='store', type=float, default=0.0, help="Set the diameter of the crest-hollow-internal circle. If equal to 0.0, set to minimal_crest_hollow_internal_radius. Default: 0.0") r_parser.add_argument('--floor_width','--fw', action='store', type=float, default=0.0, help="Set the width between the cross_cube-top-holes and the crest-gear-hollow. If equal to 0.0, set to end_leg_width. Default: 0.0") r_parser.add_argument('--crest_hollow_smoothing_radius','--chsr', action='store', type=float, default=0.0, help="Set the smoothing radius for the crest-hollow. If equal to 0.0, set to 0.5*maximal_crest_hollow_smoothing_radius. Default: 0.0") ### gear_holes r_parser.add_argument('--fastening_hole_diameter','--fhd', action='store', type=float, default=5.0, help="Set the diameter of the crest-gear-fastening-holes. Default: 5.0") r_parser.add_argument('--fastening_hole_position','--fhp', action='store', type=float, default=0.0, help="Set the position relative to the gear-hollow-external circle of the crest-gear-fastening-holes. Default: 0.0") r_parser.add_argument('--centring_hole_diameter','--chd', action='store', type=float, default=1.0, help="Set the diameter of the crest-gear-centring-holes. Default: 1.0") r_parser.add_argument('--centring_hole_distance','--chdi', action='store', type=float, default=8.0, help="Set the distance between a pair of crest-gear-centring-holes. Default: 8.0") r_parser.add_argument('--centring_hole_position','--chp', action='store', type=float, default=0.0, help="Set the position relative to the gear-hollow-external circle of the crest-gear-centring-holes. Default: 0.0") ## part thickness r_parser.add_argument('--crest_thickness','--ct', action='store', type=float, default=5.0, help="Set the thickness (z-size) of the crest. Default: 5.0") ### manufacturing r_parser.add_argument('--crest_cnc_router_bit_radius','--ccrbr', action='store', type=float, default=0.5, help="Set the minimal router_bit radius for the crest part. Default: 0.5") ### output # return return(r_parser)
def inherit_gear_profile(c={}): """ generate the gear_profile with the construct c """ gp_c = c.copy() gp_c['gear_type'] = 'e' #gp_c['gear_router_bit_radius'] = c['gear_router_bit_radius'] #gp_c['portion_tooth_nb'] = 0 #gp_c['portion_first_end'] = 0 #gp_c['portion_last_end'] = 0 gp_c['cut_portion'] = [0, 0, 0] r_obj = gear_profile.gear_profile() r_obj.apply_external_constraint(gp_c) return(r_obj)
def crest_2d_construction(c): """ construct the 2D-figures with outlines at the A-format for the crest design """ ### precision radian_epsilon = math.pi/1000 ### cx = c['cube_width']/2.0 cy = c['top_thickness']+c['height_margin']+c['axle_diameter']/2.0+c['inter_axle_length'] cube_height = 2*c['top_thickness']+2*c['height_margin']+c['axle_diameter']+c['inter_axle_length'] # inheritance from cross_cube_sub bottom_outline_A = cnc25d_api.rotate_and_translate_figure(cross_cube_sub.cross_cube_face_top_outline(c, c['face_B1_thickness'], c['face_B2_thickness']), c['cube_width']/2.0, cube_height/2.0, math.pi, 0.0, 0.0) cross_cube_hole_figure_A = cnc25d_api.rotate_and_translate_figure(cross_cube_sub.cross_cube_face_holes(c, c['face_B1_thickness'], c['face_B2_thickness']), c['cube_width']/2.0, cube_height/2.0, math.pi, 0.0, 0.0) # inheritance from gear_profile i_gear_profile = gear_profile.gear_profile() gp_c = gear_profile_constraint(c) gp_c['center_position_x'] = cx gp_c['center_position_y'] = cy i_gear_profile.apply_external_constraint(gp_c) gear_profile_B = i_gear_profile.get_A_figure('first_gear')[0] # gear_profile check if(abs(gear_profile_B[0][1]-gear_profile_B[-1][-1])>radian_epsilon): print("ERR335: Error, extremities of the gear_profile_B have different y-coordiante {:0.3f} {:0.3f}".format(gear_profile_B[0][1], gear_profile_B[-1][-1])) sys.exit(2) # gear_profile extremity angle crest_gear_angle = math.atan2(gear_profile_B[0][1]-cy, gear_profile_B[0][0]-cx) ## crest outline crest_long_nshort = True free_mounting_width = c['free_mounting_width'] if(gear_profile_B[0][1]>3*cube_height/4.0+radian_epsilon): crest_long_nshort = False free_mounting_width = c['crest_cnc_router_bit_radius'] crest_outline_A = [] crest_outline_A.append((gear_profile_B[-1][-2], gear_profile_B[-1][-1], 0)) crest_outline_A.append((cx+c['crest_hollow_external_radius']*math.cos(math.pi-crest_gear_angle), cy+c['crest_hollow_external_radius']*math.sin(math.pi-crest_gear_angle), c['crest_cnc_router_bit_radius'])) crest_outline_A.append((bottom_outline_A[0][0]-free_mounting_width, bottom_outline_A[0][1], c['crest_cnc_router_bit_radius'])) crest_outline_A.extend(bottom_outline_A[1:-1]) crest_outline_A.append((bottom_outline_A[-1][0]+free_mounting_width, bottom_outline_A[-1][1], c['crest_cnc_router_bit_radius'])) crest_outline_A.append((cx+c['crest_hollow_external_radius']*math.cos(crest_gear_angle), cy+c['crest_hollow_external_radius']*math.sin(crest_gear_angle), c['crest_cnc_router_bit_radius'])) crest_outline_A.append((gear_profile_B[0][0], gear_profile_B[0][1], 0)) crest_outline_B = cnc25d_api.cnc_cut_outline(crest_outline_A, "crest_outline_A") crest_outline_B.extend(gear_profile_B[1:]) ## crest holes crest_hole_A = [] crest_hole_A.extend(cross_cube_hole_figure_A) # cross_cube top holes ccthy = cy + c['axle_diameter']/2.0+c['height_margin'] cw5 = c['cube_width']/5 tt = c['top_thickness'] ccect = c['cross_cube_extra_cut_thickness'] cccrbr = c['cross_cube_cnc_router_bit_radius'] cc_top_hole = [] cc_top_hole.append((-1*ccect, -1*ccect, -1*cccrbr)) cc_top_hole.append((cw5+1*ccect, -1*ccect, -1*cccrbr)) cc_top_hole.append((cw5+1*ccect, tt+1*ccect, -1*cccrbr)) cc_top_hole.append((-1*ccect, tt+1*ccect, -1*cccrbr)) cc_top_hole.append((-1*ccect, -1*ccect, 0)) crest_hole_A.append(cnc25d_api.outline_shift_xy(cc_top_hole, 1*cw5, 1, ccthy, 1)) crest_hole_A.append(cnc25d_api.outline_shift_xy(cc_top_hole, 3*cw5, 1, ccthy, 1)) # crest hollow cher = c['crest_hollow_external_radius'] chir = c['crest_hollow_internal_radius'] chln = c['crest_hollow_leg_nb'] chsr = c['crest_hollow_smoothing_radius'] if(crest_long_nshort): first_leg_ex_angle = math.asin((c['end_leg_width']+3*cube_height/4.0-cy)/cher) first_leg_in_angle = math.asin((c['end_leg_width']+3*cube_height/4.0-cy)/chir) first_leg_hole_angle = math.asin((c['end_leg_width']/2.0+3*cube_height/4.0-cy)/cher) else: first_leg_ex_angle = crest_gear_angle + 2*math.atan(c['end_leg_width']/(2.0*cher)) first_leg_in_angle = crest_gear_angle + 2*math.atan(c['end_leg_width']/(2.0*chir)) first_leg_hole_angle = crest_gear_angle + math.atan(c['end_leg_width']/(2.0*cher)) if(c['crest_hollow_leg_nb']>1): leg_step_angle = 0 if(chln>2): leg_step_angle = (math.pi-2*first_leg_ex_angle)/(chln-1) middle_leg_ex_half_angle = math.atan(c['middle_leg_width']/(2.0*cher)) middle_leg_in_half_angle = math.atan(c['middle_leg_width']/(2.0*chir)) smoothing_ex_half_angle = math.atan(float(chsr)/(cher-chsr)) smoothing_in_half_angle = math.atan(float(chsr)/(chir+chsr)) ex1_angles = [] ex2_angles = [] ex1_angles.append(first_leg_ex_angle) for i in range(chln-2): ex1_angles.append(first_leg_ex_angle + (i+1)*leg_step_angle + middle_leg_ex_half_angle) ex2_angles.append(first_leg_ex_angle + (i+1)*leg_step_angle - middle_leg_ex_half_angle) ex2_angles.append(math.pi-first_leg_ex_angle) in1_angles = [] in2_angles = [] in1_angles.append(first_leg_in_angle) for i in range(chln-2): in1_angles.append(first_leg_ex_angle + (i+1)*leg_step_angle + middle_leg_in_half_angle) in2_angles.append(first_leg_ex_angle + (i+1)*leg_step_angle - middle_leg_in_half_angle) in2_angles.append(math.pi-first_leg_in_angle) for i in range(chln-1): ea1 = ex1_angles[i] ea2 = ex2_angles[i] ma = (ex1_angles[i]+ex2_angles[i])/2.0 ia1 = in1_angles[i] ia2 = in2_angles[i] if((ea2-ea1)<2.1*smoothing_ex_half_angle): print("ERR419: Error, crest_hollow_smoothing_radius {:0.3f} or crest_hollow_leg_nb {:d} are too big".format(chsr, chln)) sys.exit(2) hollow = [] hollow.append((cx+cher*math.cos(ea1), cy+cher*math.sin(ea1), chsr)) hollow.append((cx+cher*math.cos(ma), cy+cher*math.sin(ma), cx+cher*math.cos(ea2), cy+cher*math.sin(ea2), chsr)) if((ia2-ia1)<2.1*smoothing_in_half_angle): hollow.append((cx+chir*math.cos(ma), cy+chir*math.sin(ma), chsr)) else: hollow.append((cx+chir*math.cos(ia2), cy+chir*math.sin(ia2), chsr)) hollow.append((cx+chir*math.cos(ma), cy+chir*math.sin(ma), cx+chir*math.cos(ia1), cy+chir*math.sin(ia1), chsr)) hollow.append((cx+cher*math.cos(ea1), cy+cher*math.sin(ea1), 0)) crest_hole_A.append(hollow[:]) #[todo] optimization with floor_width # crest gear holes hole_half_angle = math.atan(c['centring_hole_distance']/(2.0*(cher+c['centring_hole_position']))) hole_step_angle = 0 if(chln>2): hole_step_angle = (math.pi-2*first_leg_hole_angle)/(chln-1) hole_angles = [] hole_angles.append(first_leg_hole_angle) for i in range(chln-2): #hole_angles.append(first_leg_hole_angle + (i+1)*hole_step_angle) hole_angles.append(first_leg_ex_angle + (i+1)*leg_step_angle) hole_angles.append(math.pi-first_leg_hole_angle) for a in hole_angles: crest_hole_A.append((cx+(cher+c['fastening_hole_position'])*math.cos(a), cy+(cher+c['fastening_hole_position'])*math.sin(a), c['fastening_hole_radius'])) crest_hole_A.append((cx+(cher+c['centring_hole_position'])*math.cos(a-hole_half_angle), cy+(cher+c['centring_hole_position'])*math.sin(a-hole_half_angle), c['centring_hole_radius'])) crest_hole_A.append((cx+(cher+c['centring_hole_position'])*math.cos(a+hole_half_angle), cy+(cher+c['centring_hole_position'])*math.sin(a+hole_half_angle), c['centring_hole_radius'])) ## crest figure crest_figure = [] crest_figure.append(crest_outline_B) crest_figure.extend(cnc25d_api.cnc_cut_figure(crest_hole_A, "crest_hole_A")) ### r_figures = {} r_height = {} # r_figures['crest_fig'] = crest_figure r_height['crest_fig'] = c['crest_thickness'] ### return((r_figures, r_height))