def center_position(ai_center_diameter, ai_pd1, ai_pd2, ai_pd3, ai_pd4, ai_optional_additional_axis_length): """ compute the four axis center """ # inter-axis length l12 = (ai_pd1+ai_pd2)/2.0 + ai_optional_additional_axis_length l23 = (ai_pd2+ai_pd3)/2.0 + ai_optional_additional_axis_length l34 = (ai_pd3+ai_pd4)/2.0 + ai_optional_additional_axis_length l41 = (ai_pd4+ai_pd1)/2.0 + ai_optional_additional_axis_length # l13 arbitrary l13_min = max(l12, l23, l34, l41) l13_max = min(l12+l23, l34+l41) l13 = (l13_min+l13_max)/2.0 print("l13: min {:0.3f} max {:0.3f} l13 {:0.3f}".format(l13_min, l13_max, l13)) # c1 c1x = 0.0 c1y = 0.0 # c3 c3x = c1x + 0.0 c3y = c1y + l13 # c2 # law of cosines: BAC = math.acos((b**2+c**2-a**2)/(2*b*c)) a213 = math.acos((l12**2+l13**2-l23**2)/(2*l12*l13)) c2a = math.pi/2-a213 c2x = c1x + l12*math.cos(c2a) c2y = c1y + l12*math.sin(c2a) # c4 a314 = math.acos((l41**2+l13**2-l34**2)/(2*l41*l13)) c4a = math.pi/2+a314 c4x = c1x + l41*math.cos(c4a) c4y = c1y + l41*math.sin(c4a) # info_txt info_txt = """ center coordiantes: c1: x {:0.3f} y {:0.3f} c2: x {:0.3f} y {:0.3f} c3: x {:0.3f} y {:0.3f} c4: x {:0.3f} y {:0.3f} """.format(c1x, c1y, c2x, c2y, c3x, c3y, c4x, c4y) print("{:s}".format(info_txt)) ### dxf # plank outline smooth_radius = 40 center_plank_A = [ (c1x, c1y-smooth_radius, smooth_radius), (c2x+smooth_radius, c2y, smooth_radius), (c3x, c3y+smooth_radius, smooth_radius), (c4x-smooth_radius, c4y, smooth_radius), (c1x, c1y-smooth_radius, 0)] center_plank_B = cnc25d_api.cnc_cut_outline(center_plank_A, "center_plank_A") # figure center_figure = [ center_plank_B, (c1x, c1y, ai_center_diameter/2.0), (c2x, c2y, ai_center_diameter/2.0), (c3x, c3y, ai_center_diameter/2.0), (c4x, c4y, ai_center_diameter/2.0)] if(not sim): cnc25d_api.generate_output_file(center_figure, "test_output/jh01_zahnrad_center_{:0.2f}.dxf".format(ai_optional_additional_axis_length), 10.0, "hello")
def center_position(ai_center_diameter, ai_pd1, ai_pd2, ai_pd3, ai_pd4, ai_optional_additional_axis_length): """ compute the four axis center """ # inter-axis length l12 = (ai_pd1 + ai_pd2) / 2.0 + ai_optional_additional_axis_length l23 = (ai_pd2 + ai_pd3) / 2.0 + ai_optional_additional_axis_length l34 = (ai_pd3 + ai_pd4) / 2.0 + ai_optional_additional_axis_length l41 = (ai_pd4 + ai_pd1) / 2.0 + ai_optional_additional_axis_length # l13 arbitrary l13_min = max(l12, l23, l34, l41) l13_max = min(l12 + l23, l34 + l41) l13 = (l13_min + l13_max) / 2.0 print("l13: min {:0.3f} max {:0.3f} l13 {:0.3f}".format( l13_min, l13_max, l13)) # c1 c1x = 0.0 c1y = 0.0 # c3 c3x = c1x + 0.0 c3y = c1y + l13 # c2 # law of cosines: BAC = math.acos((b**2+c**2-a**2)/(2*b*c)) a213 = math.acos((l12**2 + l13**2 - l23**2) / (2 * l12 * l13)) c2a = math.pi / 2 - a213 c2x = c1x + l12 * math.cos(c2a) c2y = c1y + l12 * math.sin(c2a) # c4 a314 = math.acos((l41**2 + l13**2 - l34**2) / (2 * l41 * l13)) c4a = math.pi / 2 + a314 c4x = c1x + l41 * math.cos(c4a) c4y = c1y + l41 * math.sin(c4a) # info_txt info_txt = """ center coordiantes: c1: x {:0.3f} y {:0.3f} c2: x {:0.3f} y {:0.3f} c3: x {:0.3f} y {:0.3f} c4: x {:0.3f} y {:0.3f} """.format(c1x, c1y, c2x, c2y, c3x, c3y, c4x, c4y) print("{:s}".format(info_txt)) ### dxf # plank outline smooth_radius = 40 center_plank_A = [(c1x, c1y - smooth_radius, smooth_radius), (c2x + smooth_radius, c2y, smooth_radius), (c3x, c3y + smooth_radius, smooth_radius), (c4x - smooth_radius, c4y, smooth_radius), (c1x, c1y - smooth_radius, 0)] center_plank_B = cnc25d_api.cnc_cut_outline(center_plank_A, "center_plank_A") # figure center_figure = [ center_plank_B, (c1x, c1y, ai_center_diameter / 2.0), (c2x, c2y, ai_center_diameter / 2.0), (c3x, c3y, ai_center_diameter / 2.0), (c4x, c4y, ai_center_diameter / 2.0) ] if (not sim): cnc25d_api.generate_output_file( center_figure, "test_output/jh01_zahnrad_center_{:0.2f}.dxf".format( ai_optional_additional_axis_length), 10.0, "hello")
################################################################ # define the CNC router_bit radius #router_bit_radius = 4.0 # in mm ################################################################ # Design your XY outline of your 2.5D part design ################################################################ outer_rectangle_A = [ # format-A outline [-60, -40, 10], # first point of the outline [ 60, -40, 5], # first segment [ 60, 40, 0], # second segment [-60, 40, 5], # third segment [-60, -40, 0]] # last segment outer_rectangle_B = cnc25d_api.cnc_cut_outline(outer_rectangle_A, "outer_rectangle_A") # convert from format-A to format-B inner_shape_A = [ # format-A outline [ 0, 0, 5], # first point of the outline [ 40, 0, -5], # first segment: it's a line [ 20, 30, 0, 0, 0]] # second and last segment: it's an arc inner_shape_B = cnc25d_api.cnc_cut_outline(inner_shape_A, "inner_shape_A") # convert from format-A to format-B inner_circle1 = [-30, 0, 15] # circle of center (-30, 0) and radius 15 simple_figure = [outer_rectangle_B, inner_shape_B, inner_circle1] overlay_figure = [outer_rectangle_A, inner_shape_A, inner_circle1] simple_figure_info = """ Some info there that will appear in the parameter window
0 * my_router_bit_radius, ], # this corner will be leaved unchanged [1 * big_length + 0 * small_length, 1 * big_length + 0 * small_length, my_router_bit_radius], [0 * big_length + 0 * small_length, 1 * big_length + 0 * small_length, my_router_bit_radius], [0 * big_length + 0 * small_length, 0 * big_length + 0 * small_length, 0 * my_router_bit_radius], ] # The last point is equal to the Start point. The router_bit request must be set to zero. my_curve = [[20, 0], [22, 10], [25, 20], [29, 30], [35, 40], [43, 50], [60, 60]] ################################################################ # Combine your outline and your router_bit constraint ################################################################ ## use the Cnc25D API function cnc_cut_outline to create a makable outline from the wished outline # the second argument is just used to enhance the error, warning and debug messages my_outline_for_cnc = cnc25d_api.cnc_cut_outline(my_outline, "api_example") # other help functions to manipulate outlines # outline_shift_x my_outline_for_cnc_x_shifted = cnc25d_api.outline_shift_x(my_outline_for_cnc, big_length * 4, 1) # outline_shift_y my_outline_for_cnc_y_shifted = cnc25d_api.outline_shift_y(my_outline_for_cnc, big_length * 6, -1) # outline_shift_xy my_outline_for_cnc_xy_shifted = cnc25d_api.outline_shift_xy( my_outline_for_cnc, big_length * 4, 0.5, big_length * 4, 0.5 ) # outline_rotate my_outline_for_cnc_rotated = cnc25d_api.outline_rotate(my_outline_for_cnc, big_length * 2, big_length * 2, math.pi / 4) # outline_close # it has no effect because the outline is already closed # notice that the help functions to manipulate outlines can be used before or after applying the function cnc25d_api.cnc_cut_outline() my_outline_for_cnc_closed = cnc25d_api.cnc_cut_outline(
# define the CNC router_bit radius #router_bit_radius = 4.0 # in mm ################################################################ # Design your XY outline of your 2.5D part design ################################################################ outer_rectangle_A = [ # format-A outline [-60, -40, 10], # first point of the outline [60, -40, 5], # first segment [60, 40, 0], # second segment [-60, 40, 5], # third segment [-60, -40, 0] ] # last segment outer_rectangle_B = cnc25d_api.cnc_cut_outline( outer_rectangle_A, "outer_rectangle_A") # convert from format-A to format-B inner_shape_A = [ # format-A outline [0, 0, 5], # first point of the outline [40, 0, -5], # first segment: it's a line [20, 30, 0, 0, 0] ] # second and last segment: it's an arc inner_shape_B = cnc25d_api.cnc_cut_outline( inner_shape_A, "inner_shape_A") # convert from format-A to format-B inner_circle1 = [-30, 0, 15] # circle of center (-30, 0) and radius 15 simple_figure = [outer_rectangle_B, inner_shape_B, inner_circle1] overlay_figure = [outer_rectangle_A, inner_shape_A, inner_circle1]
my_curve=[ [20,0], [22,10], [25,20], [29,30], [35,40], [43,50], [60,60]] ################################################################ # Combine your outline and your router_bit constraint ################################################################ ## use the Cnc25D API function cnc_cut_outline to create a makable outline from the wished outline # the second argument is just used to enhance the error, warning and debug messages my_outline_for_cnc = cnc25d_api.cnc_cut_outline(my_outline, 'api_example') # other help functions to manipulate outlines #outline_shift_x my_outline_for_cnc_x_shifted = cnc25d_api.outline_shift_x(my_outline_for_cnc, big_length*4, 1) #outline_shift_y my_outline_for_cnc_y_shifted = cnc25d_api.outline_shift_y(my_outline_for_cnc, big_length*6, -1) #outline_shift_xy my_outline_for_cnc_xy_shifted = cnc25d_api.outline_shift_xy(my_outline_for_cnc, big_length*4, 0.5, big_length*4, 0.5) #outline_rotate my_outline_for_cnc_rotated = cnc25d_api.outline_rotate(my_outline_for_cnc, big_length*2, big_length*2, math.pi/4) #outline_close # it has no effect because the outline is already closed # notice that the help functions to manipulate outlines can be used before or after applying the function cnc25d_api.cnc_cut_outline() my_outline_for_cnc_closed = cnc25d_api.cnc_cut_outline(cnc25d_api.outline_close(cnc25d_api.outline_shift_x(my_outline, -1*big_length, 0.25)), 'api_example2') #outline_reverse # reverse the order of the segments. If the outline is closed, it changes the orientation from CW to CCW and vice versa