Exemple #1
0
def oval(x_center, y_center, x_width, y_height, tool_diameter, feed_rate, z_feed_rate, from_z, to_z, step_z,  safety_z,
         angle=0.0):
         
    r"""Generate Gcode to cut an oval

    Parameters
    ----------
    ...
    angle : float
        clockwise rotation angle
    ...
    """
    point_center = Point(x_center, y_center)
    gcode = list()
    gcode.append(gcodes.g0_gcode(x=x_center, y=y_center, z=safety_z))

    for h in _generate_heights(from_z, to_z, step_z):
        for d in _generate_excentric(0.00, y_height/2.0, tool_diameter):
            point_n = (Point(0.0, d) + point_center).rotate(point_center, angle)
            point_ne = (Point((x_width - y_height) / 2.0, d) + point_center).rotate(point_center, angle)
            point_e_arc_center = (Point((x_width-y_height)/2.0, 0.0) + point_center).rotate(point_center, angle)
            point_se = (Point((x_width - y_height) / 2.0, -d) + point_center).rotate(point_center, angle)
            point_sw = (Point(-(x_width-y_height)/2.0, -d) + point_center).rotate(point_center, angle)
            point_w_arc_center = (Point(-(x_width - y_height)/2.0, 0.0) + point_center).rotate(point_center, angle)
            point_nw = (Point(-(x_width - y_height)/2.0, d) + point_center).rotate(point_center, angle)
            
            gcode.append(gcodes.g1_gcode(z=h, feedrate=z_feed_rate))
            gcode.append(gcodes.g1_gcode(x=point_n.x, y=point_n.y, feedrate=feed_rate))
            gcode.append(gcodes.g1_gcode(x=point_ne.x, y=point_ne.y, feedrate=feed_rate))
            gcode.append(gcodes.g2_gcode(x_end_point=point_se.x, y_end_point=point_se.y, spiral_end_altitude=h,
                                         x_center_offset=(point_e_arc_center - point_ne).x,
                                         y_center_offset=(point_e_arc_center - point_ne).y, feedrate=feed_rate))
            gcode.append(gcodes.g1_gcode(x=point_sw.x, y=point_sw.y, feedrate=feed_rate))
            gcode.append(gcodes.g2_gcode(x_end_point=point_nw.x, y_end_point=point_nw.y, spiral_end_altitude=h,
                                         x_center_offset=(point_w_arc_center - point_sw).x,
                                         y_center_offset=(point_w_arc_center - point_sw).y, feedrate=feed_rate))
            gcode.append(gcodes.g1_gcode(x=point_n.x, y=point_n.y, feedrate=feed_rate))

    gcode.append(gcodes.g1_gcode(z=safety_z, feedrate=feed_rate))
    return ''.join(gcode)
Exemple #2
0
def hole(x_center, y_center, hole_diameter, tool_diameter, feed_rate, from_z, to_z, step_z, safety_z):
    r"""Generate Gcode to cut a hole

    Note
    ----
    If the hole diameter is bigger than 2 x tool_diameter the material in the center is not removed
    
    """
    if hole_diameter < tool_diameter:
        raise exceptions.WrongParameterError('Cannot make a hole smaller than the tool')
    gcode = list()
    gcode.append(gcodes.g0_gcode(z=safety_z))
    gcode.append(gcodes.g0_gcode(x=x_center - hole_diameter / 2 + tool_diameter / 2, y=y_center))

    for h in _generate_heights(from_z, to_z, step_z):
        gcode.append(gcodes.g2_gcode(x_center_offset=hole_diameter / 2 - tool_diameter / 2, y_center_offset=0,
                                     spiral_end_altitude=h, feedrate=feed_rate))
        
    gcode.append(gcodes.g1_gcode(z=safety_z, feedrate=feed_rate))
    
    return ''.join(gcode)
Exemple #3
0
def full_hole(x_center, y_center, hole_diameter, tool_diameter, feed_rate, z_feed_rate, from_z, to_z, step_z, safety_z,
              center_diameter=0.0):
    r"""Generate Gcode to cut a hole and remove the middle material

    If the hole diameter is bigger than 2 x tool_diameter the material in the center is removed
    
    """
    if hole_diameter < tool_diameter:
        raise exceptions.WrongParameterError('Cannot make a hole smaller than the tool')
    gcode = list()
    gcode.append(gcodes.g0_gcode(z=safety_z))
    # gcode.append(_g0_gcode(x=x_center-tool_diameter/2,y=y_center))
    gcode.append(gcodes.g0_gcode(x=x_center - tool_diameter / 2, y=y_center))

    for h in _generate_heights(from_z, to_z, step_z):
        gcode.append(gcodes.g1_gcode(z=h, feedrate=z_feed_rate))
        for e in _generate_excentric(start=center_diameter/2.0, end=hole_diameter / 2, tool_diameter=tool_diameter):
            gcode.append(gcodes.g1_gcode(x=x_center-e, y=y_center, feedrate=feed_rate))
            gcode.append(gcodes.g2_gcode(x_center_offset=e, y_center_offset=0, spiral_end_altitude=h,
                                         feedrate=feed_rate))
        
    gcode.append(gcodes.g1_gcode(z=safety_z, feedrate=feed_rate))
    return ''.join(gcode)