Exemplo n.º 1
0
def temple_hinge_pockets(temples):
    # We're operating in a 90 degree rotated fixture
    #l_hinge = poly.rotate_90(temples["left_hinge_contour"])
    #r_hinge = poly.rotate_90(temples["right_hinge_contour"])

    l_hinge = temples["left_hinge_contour"]
    r_hinge = temples["right_hinge_contour"]
    if not poly.is_ccw(l_hinge):
        l_hinge = poly.reverse(l_hinge)
    if not poly.is_ccw(r_hinge):
        r_hinge = poly.reverse(r_hinge)

    left_hinge_pocket_contours = []
    while len(l_hinge) > 0:
        l_hinge = poly.erode(1.5875 / 2, l_hinge)
        if len(l_hinge) > 0:
            l_hinge = l_hinge[0]
            left_hinge_pocket_contours.append(l_hinge)

    right_hinge_pocket_contours = []
    while len(r_hinge) > 0:
        r_hinge = poly.erode(1.5875 / 2, r_hinge)
        if len(r_hinge) > 0:
            r_hinge = r_hinge[0]
            right_hinge_pocket_contours.append(r_hinge)
    r = [
        cam.comment("Hinge Pockets"),
        cam.feedrate(750),
        cam.change_tool("1/16in endmill"),
        cam.start_spindle(15000),
        cam.dwell(3),
        cam.comment("Right Hinge Pocket"),
        cam.pocket(right_hinge_pocket_contours,
                   -abs(temples['pocket_depth']),
                   retract=0),
        cam.rapid([None, None, 20.0]),
        cam.comment("Left Hinge Pocket"),
        cam.pocket(left_hinge_pocket_contours,
                   -abs(temples['pocket_depth']),
                   retract=0),
        cam.rapid([None, None, 20.0]),
        cam.comment("Hinge Holes"),
        cam.change_tool("1mm drill"),
        cam.start_spindle(4500),
        cam.dwell(2),
        [
            cam.rmp(p + [-8.0], retract=10.0)
            for p in temples['right_hinge_holes']
        ],
        [
            cam.rmp(p + [-8.0], retract=10.0)
            for p in temples['left_hinge_holes']
        ],
        cam.rapid([None, None, 20.0]),
        cam.move([None, None, 0]),
        cam.contour(poly.rotate_90(temples['left_temple_contour']), True),
        cam.contour(poly.rotate_90(temples['right_temple_contour']), True),
    ]
    return r
Exemplo n.º 2
0
def face_hinge_pockets(hinge_num, xposition, yposition):
    left_hinge = hinges.get_hinge(hinge_num)
    right_hinge = hinges.get_hinge(hinge_num, False)
    left_translate = [xposition, -yposition]
    #left_translate = [xposition, 0]
    right_translate = [xposition, yposition]
    #right_translate = [xposition, 0]
    # Adjust by pocket depth of hinge
    pocket_depth = left_hinge['pocket_depth']

    left_contour = poly.translate(left_hinge["face_contour"], left_translate[0], left_translate[1])
    right_contour = poly.translate(right_hinge["face_contour"], right_translate[0], right_translate[1])
    left_holes = poly.translate(left_hinge["face_holes"], left_translate[0], left_translate[1])
    right_holes = poly.translate(right_hinge["face_holes"], right_translate[0], right_translate[1])

    if not poly.is_ccw(left_contour):
        left_contour = poly.reverse(left_contour)
    if not poly.is_ccw(right_contour):
        right_contour = poly.reverse(right_contour)

    left_hinge_pocket_contours = [];
    while len(left_contour) > 0:
        left_contour = poly.erode(1.5875/2, left_contour)
        if len(left_contour) > 0:
            left_contour = left_contour[0]
            left_hinge_pocket_contours.append(left_contour)

    right_hinge_pocket_contours = [];
    while len(right_contour) > 0:
            right_contour = poly.erode(1.5875/2, right_contour)
            if len(right_contour) > 0:
                right_contour = right_contour[0]
                right_hinge_pocket_contours.append(right_contour)
    r = [
        cam.comment("Hinge Pockets"),
        cam.feedrate(750),
        cam.change_tool("1/16in endmill"),
        cam.start_spindle(15000),
        cam.dwell(3),
        cam.comment("Right Hinge Pocket"),
        cam.pocket(right_hinge_pocket_contours, -abs(right_hinge['pocket_depth']), retract=0),
        cam.rapid([None, None, 20.0]),
        cam.comment("Left Hinge Pocket"),
        cam.pocket(left_hinge_pocket_contours, -abs(left_hinge['pocket_depth']), retract=0),
        cam.rapid([None, None, 20.0]),
        cam.comment("Hinge Holes"),
        cam.change_tool("1mm drill"),
        cam.start_spindle(4500),
        cam.dwell(2),
        [cam.rmp(p + [-8.0], retract=10.0) for p in right_holes],
        [cam.rmp(p + [-8.0], retract=10.0) for p in left_holes],
        cam.rapid([None, None, 20.0]),
    ]
    return r
Exemplo n.º 3
0
def temple_hinge_pockets(temples):
    # We're operating in a 90 degree rotated fixture
    #l_hinge = poly.rotate_90(temples["left_hinge_contour"])
    #r_hinge = poly.rotate_90(temples["right_hinge_contour"])

    l_hinge = temples["left_hinge_contour"]
    r_hinge = temples["right_hinge_contour"]
    if not poly.is_ccw(l_hinge):
        l_hinge = poly.reverse(l_hinge)
    if not poly.is_ccw(r_hinge):
        r_hinge = poly.reverse(r_hinge)

    left_hinge_pocket_contours = [];
    while len(l_hinge) > 0:
        l_hinge = poly.erode(1.5875/2, l_hinge)
        if len(l_hinge) > 0:
            l_hinge = l_hinge[0]
            left_hinge_pocket_contours.append(l_hinge)

    right_hinge_pocket_contours = [];
    while len(r_hinge) > 0:
            r_hinge = poly.erode(1.5875/2, r_hinge)
            if len(r_hinge) > 0:
                r_hinge = r_hinge[0]
                right_hinge_pocket_contours.append(r_hinge)
    r = [
        cam.comment("Hinge Pockets"),
        cam.feedrate(750),
        cam.change_tool("1/16in endmill"),
        cam.start_spindle(15000),
        cam.dwell(3),
        cam.comment("Right Hinge Pocket"),
        cam.pocket(right_hinge_pocket_contours, -abs(temples['pocket_depth']), retract=0),
        cam.rapid([None, None, 20.0]),
        cam.comment("Left Hinge Pocket"),
        cam.pocket(left_hinge_pocket_contours, -abs(temples['pocket_depth']), retract=0),
        cam.rapid([None, None, 20.0]),
        cam.comment("Hinge Holes"),
        cam.change_tool("1mm drill"),
        cam.start_spindle(4500),
        cam.dwell(2),
        [cam.rmp(p + [-8.0], retract=10.0) for p in temples['right_hinge_holes']],
        [cam.rmp(p + [-8.0], retract=10.0) for p in temples['left_hinge_holes']],
        cam.rapid([None, None, 20.0]),

        cam.move([None, None, 0]),
        cam.contour(poly.rotate_90(temples['left_temple_contour']), True),
        cam.contour(poly.rotate_90(temples['right_temple_contour']), True),
    ]
    return r
Exemplo n.º 4
0
def mill_hinges(outdir):
    """Creates the g-code for the first milling operation.  The
    first milling operation is done on an unregistered plastic blank,
    so includes creating registration holes for subsequent operations."""
    y_offsets = [y*15 for y in range(-5, 6)]
    x_offsets = [x*7 for x in range(-3, 4)]

    hinge = hinges.get_hinge(2);
    contour = hinge['face_contour']

    contours = []
    erode = poly.erode(1.5875/2, contour)
    while len(erode) > 0:
        if len(erode) >= 1:
            contours.append(erode[0])
        else:
            break
        erode = poly.erode(1.5875/2, contours[-1])



    program = [
        cam.setup(),
        cam.select_fixture("blank_clamp"),
        cam.retract_spindle(),
        cam.activate_pin("stock_clamp"),
        cam.change_tool("1/16in endmill"),
        cam.rapid([0,0]),
        cam.start_spindle(20000),
        cam.dwell(3),
#        cam.pocket(contours, -1, -1),
#        cam.rapid([None, None, 20.0]),
#        cam.change_tool("1mm drill"),
#        cam.start_spindle(4500),
#        [cam.rmp(p + [-2.5], retract=10.0) for p in hinge['face_holes']],
        ]



    for y_offset in y_offsets:
        for x_offset in x_offsets:
            program += [
                cam.rapid([x_offset, y_offset]),
                cam.temporary_offset((0,0)),
                cam.pocket(contours, -1.2, -1.2),
                cam.rapid([None, None, 20.0]),
                cam.remove_temporary_offset(),
                    ]
#    program += [
#            cam.change_tool("1mm drill"),
#            cam.start_spindle(4500),
#            ]
#    for y_offset in y_offsets:
#        for x_offset in x_offsets:
#            program += [
#                cam.rapid([x_offset, y_offset]),
#                cam.temporary_offset((0,0)),
#                [cam.rmp(p + [-2.5], retract=10.0) for p in hinge['face_holes']],
#                cam.rapid([None, None, 20.0]),
#                cam.remove_temporary_offset(),
#                    ]

    program += [
        cam.deactivate_pin("stock_clamp"),
        cam.end_program(),
    ]


    open(outdir + "/face_stage1.ngc", "w").write(to_string(program))
Exemplo n.º 5
0
def temple_hinge_pockets(temples, thinned):
    # We're operating in a 90 degree rotated fixture
    #l_hinge = poly.rotate_90(temples["left_hinge_contour"])
    #r_hinge = poly.rotate_90(temples["right_hinge_contour"])
    print 'Generating temple hinge pockets'

    l_hinge = temples["left_hinge_contour"]
    r_hinge = temples["right_hinge_contour"]
    if not poly.is_ccw(l_hinge):
        l_hinge = poly.reverse(l_hinge)
    if not poly.is_ccw(r_hinge):
        r_hinge = poly.reverse(r_hinge)

    #pocket_depth = temples['pocket_depth'] + thinned
    pocket_depth = 1 + thinned;

    def pocket_contours(contour):
        contours = []
        erode = poly.erode(1.5875/2, contour)
        making_progress = True
        while len(erode) > 0 and making_progress:
            making_progress = False
            for path in erode:
                if len(path) > 5:
                    making_progress = True
                    contours.append(path)
            erode = poly.erode(1.5875/2, contours[-1])
        return contours

    left_hinge_pocket_contours = pocket_contours(l_hinge)
    right_hinge_pocket_contours = pocket_contours(r_hinge)
#    left_hinge_pocket_contours = [];
#    while len(l_hinge) > 0:
#        l_hinge = poly.erode(1.5875/2, l_hinge)
#        if len(l_hinge) > 0:
#            l_hinge = l_hinge[0]
#            left_hinge_pocket_contours.append(l_hinge)
#    right_hinge_pocket_contours = [];
#    while len(r_hinge) > 0:
#            r_hinge = poly.erode(1.5875/2, r_hinge)
#            if len(rhinge_) == 1:
#                right_hinge_pocket
#            if len(r_hinge) > 0:
#                r_hinge = r_hinge[0]
#                right_hinge_pocket_contours.append(r_hinge)
    r = [
        cam.comment("Hinge Pockets"),
        cam.feedrate(750),
        cam.change_tool("1/16in endmill"),
        cam.start_spindle(22000),
        cam.dwell(5),
        cam.comment("Right Hinge Pocket"),
        cam.pocket(right_hinge_pocket_contours, -abs(pocket_depth), retract=0),
        cam.rapid([None, None, 20.0]),
        cam.comment("Left Hinge Pocket"),
        cam.pocket(left_hinge_pocket_contours, -abs(pocket_depth), retract=0),
        cam.rapid([None, None, 20.0]),
        cam.comment("Hinge Holes"),
        cam.change_tool("1mm drill"),
        cam.start_spindle(5000),
        cam.dwell(2),
        [cam.rmp(p + [-8.0], retract=10.0) for p in temples['right_hinge_holes']],
        [cam.rmp(p + [-8.0], retract=10.0) for p in temples['left_hinge_holes']],
        cam.rapid([None, None, 20.0]),
    ]
    return r
Exemplo n.º 6
0
def face_hinge_pockets(hinge_num, hinge_height, temple_position, centering_shift, thin_back):

    print 'Generating face hinge pockets', hinge_num
    xposition = hinge_height;
    yposition = temple_position+3.0; # 4mm for the temple, but less 1mm for temple hinge pocket
    print 'Position is ', xposition, yposition
    left_hinge = hinges.get_hinge(hinge_num)
    print 'Got left hinge'
    right_hinge = hinges.get_hinge(hinge_num, False)
    print 'Retrieved hinge contours'
    left_translate = [xposition, yposition]
    right_translate = [xposition, -yposition]
    print 'Calculated hinge translations'
    #right_translate = [xposition, 0]
    # Adjust by pocket depth of hinge
    #pocket_depth = left_hinge['pocket_depth']+thin_back

    pocket_depth = 1 + thin_back
    drill_depth = -thin_back - 2.0

    left_contour = poly.mirror_x(poly.rotate_90(left_hinge["face_contour"]), False)
    right_contour = poly.mirror_x(poly.rotate_90(right_hinge["face_contour"]), False)
    left_holes = poly.mirror_x(poly.rotate_90(left_hinge["face_holes"]), False)
    right_holes = poly.mirror_x(poly.rotate_90(right_hinge["face_holes"]), False)
    left_contour = poly.translate(left_contour, left_translate[0], -left_translate[1])
    right_contour = poly.translate(right_contour, right_translate[0], -right_translate[1])
    left_holes = poly.translate(left_holes, left_translate[0], -left_translate[1])
    right_holes = poly.translate(right_holes, right_translate[0], -right_translate[1])

    # Now center everything on the stock
    left_contour = poly.translate(left_contour, centering_shift[0], -centering_shift[1])
    right_contour = poly.translate(right_contour, centering_shift[0], -centering_shift[1])
    left_holes = poly.translate(left_holes, centering_shift[0], -centering_shift[1])
    right_holes = poly.translate(right_holes, centering_shift[0], -centering_shift[1])

    if not poly.is_ccw(left_contour):
        left_contour = poly.reverse(left_contour)
    if not poly.is_ccw(right_contour):
        right_contour = poly.reverse(right_contour)

    left_hinge_pocket_contours = [];
    while len(left_contour) > 0:
        left_contour = poly.erode(1.5875/2, left_contour)
        if len(left_contour) > 0:
            left_contour = left_contour[0]
            left_hinge_pocket_contours.append(left_contour)

    right_hinge_pocket_contours = [];
    while len(right_contour) > 0:
            right_contour = poly.erode(1.5875/2, right_contour)
            if len(right_contour) > 0:
                right_contour = right_contour[0]
                right_hinge_pocket_contours.append(right_contour)
    r = [
        cam.comment("Hinge Pockets"),
        cam.feedrate(750),
        cam.change_tool("1/16in endmill"),
        cam.start_spindle(20000),
        cam.dwell(3),
        cam.comment("Right Hinge Pocket"),
        cam.pocket(right_hinge_pocket_contours, -abs(pocket_depth), retract=-abs(pocket_depth)),
        cam.rapid([None, None, 20.0]),
        cam.comment("Left Hinge Pocket"),
        cam.pocket(left_hinge_pocket_contours, -abs(pocket_depth), retract=-abs(pocket_depth)),
        cam.rapid([None, None, 20.0]),
        cam.comment("Hinge Holes"),
        cam.change_tool("1mm drill"),
        cam.start_spindle(5000),
        cam.dwell(2),
        [cam.rmp(p + [drill_depth], retract=10.0) for p in right_holes],
        [cam.rmp(p + [drill_depth], retract=10.0) for p in left_holes],
        cam.rapid([None, None, 20.0]),
    ]
    return r
Exemplo n.º 7
0
def face_hinge_pockets(hinge_num, xposition, yposition):
    left_hinge = hinges.get_hinge(hinge_num)
    right_hinge = hinges.get_hinge(hinge_num, False)
    left_translate = [xposition, -yposition]
    #left_translate = [xposition, 0]
    right_translate = [xposition, yposition]
    #right_translate = [xposition, 0]
    # Adjust by pocket depth of hinge
    pocket_depth = left_hinge['pocket_depth']

    left_contour = poly.translate(left_hinge["face_contour"],
                                  left_translate[0], left_translate[1])
    right_contour = poly.translate(right_hinge["face_contour"],
                                   right_translate[0], right_translate[1])
    left_holes = poly.translate(left_hinge["face_holes"], left_translate[0],
                                left_translate[1])
    right_holes = poly.translate(right_hinge["face_holes"], right_translate[0],
                                 right_translate[1])

    if not poly.is_ccw(left_contour):
        left_contour = poly.reverse(left_contour)
    if not poly.is_ccw(right_contour):
        right_contour = poly.reverse(right_contour)

    left_hinge_pocket_contours = []
    while len(left_contour) > 0:
        left_contour = poly.erode(1.5875 / 2, left_contour)
        if len(left_contour) > 0:
            left_contour = left_contour[0]
            left_hinge_pocket_contours.append(left_contour)

    right_hinge_pocket_contours = []
    while len(right_contour) > 0:
        right_contour = poly.erode(1.5875 / 2, right_contour)
        if len(right_contour) > 0:
            right_contour = right_contour[0]
            right_hinge_pocket_contours.append(right_contour)
    r = [
        cam.comment("Hinge Pockets"),
        cam.feedrate(750),
        cam.change_tool("1/16in endmill"),
        cam.start_spindle(15000),
        cam.dwell(3),
        cam.comment("Right Hinge Pocket"),
        cam.pocket(right_hinge_pocket_contours,
                   -abs(right_hinge['pocket_depth']),
                   retract=0),
        cam.rapid([None, None, 20.0]),
        cam.comment("Left Hinge Pocket"),
        cam.pocket(left_hinge_pocket_contours,
                   -abs(left_hinge['pocket_depth']),
                   retract=0),
        cam.rapid([None, None, 20.0]),
        cam.comment("Hinge Holes"),
        cam.change_tool("1mm drill"),
        cam.start_spindle(4500),
        cam.dwell(2),
        [cam.rmp(p + [-8.0], retract=10.0) for p in right_holes],
        [cam.rmp(p + [-8.0], retract=10.0) for p in left_holes],
        cam.rapid([None, None, 20.0]),
    ]
    return r