コード例 #1
0
ファイル: nanopcb.py プロジェクト: leethomason/saberCNC
def main():
    parser = argparse.ArgumentParser(
        description='Cut a printed circuit board from a text file.')
    parser.add_argument('filename', help='the source of the ascii art PCB')
    parser.add_argument(
        'material', help='the material to cut (wood, aluminum, etc.)')
    parser.add_argument(
        'pcbDepth', help='depth of the cut. must be negative.', type=float)
    parser.add_argument(
        'drillDepth', help='depth of the drilling and pcb cutting. must be negative.', type=float)
    parser.add_argument(
        '-c', '--no-cut', help='disable cut out the final pcb', action='store_true')
    parser.add_argument(
        '-i', '--info', help='display info and exit', action='store_true')
    parser.add_argument(
        '-d', '--no-drill', help='disable drill holes in the pcb', action='store_true')
    parser.add_argument(
        '-f', '--flip', help='flip in the y axis for pcb under and mounting over', action='store_true')
    parser.add_argument(
        '-o', '--openscad', help='OpenScad printout.', action='store_true')

    args = parser.parse_args()
    mat = init_material(args.material)
    g = G(outfile='path.nc', aerotech_include=False, header=None, footer=None, print_lines=False)

    nanopcb(args.filename, g, mat, args.pcbDepth,
            args.drillDepth, args.no_cut is False, args.info, args.no_drill is False, args.flip, args.openscad)
コード例 #2
0
ファイル: plane.py プロジェクト: leethomason/saberCNC
def main():
    parser = argparse.ArgumentParser(
        description='Cut a plane. Origin of the plane is the current location. '
        +
        'Does not account for tool thickness, so the dx, dy will be fully cut and '
        + 'on the tool center. dx/dy can be positive or negative.')
    parser.add_argument(
        'material',
        help='The material to cut in standard machine-material-size format.',
        type=str)
    parser.add_argument('depth',
                        help='Depth of the cut. Must be negative.',
                        type=float)
    parser.add_argument('dx', help="Size in x.", type=float)
    parser.add_argument('dy', help="Size in y.", type=float)
    args = parser.parse_args()

    mat = init_material(args.material)
    g = G(outfile='path.nc',
          aerotech_include=False,
          header=None,
          footer=None,
          print_lines=False)

    nomad_header(g, mat, CNC_TRAVEL_Z)
    g.spindle('CW', mat['spindle_speed'])
    g.feed(mat['feed_rate'])
    g.move(z=0)

    plane(g, mat, args.depth, 0, 0, args.dx, args.dy)
    g.abs_move(z=CNC_TRAVEL_Z)
    g.spindle()
コード例 #3
0
ファイル: hole.py プロジェクト: leethomason/saberCNC
def main():
    parser = argparse.ArgumentParser(
        description=
        'Cut a hole at given radius and depth. Implemented with helical arcs,'
        + 'and avoids plunging.')
    parser.add_argument(
        'material',
        help='The material to cut in standard machine-material-size format.',
        type=str)
    parser.add_argument('depth',
                        help='Depth of the cut. Must be negative.',
                        type=float)
    parser.add_argument('radius', help='Radius of the hole.', type=float)
    args = parser.parse_args()

    mat = init_material(args.material)
    g = G(outfile='path.nc',
          aerotech_include=False,
          header=None,
          footer=None,
          print_lines=False)

    nomad_header(g, mat, CNC_TRAVEL_Z)
    g.spindle('CW', mat['spindle_speed'])
    g.move(z=0)
    hole(g, mat, args.depth, r=args.radius, offset="inside")
    g.spindle()
コード例 #4
0
def main():
    parser = argparse.ArgumentParser(
        description='Cut holes for wasteboard. Assumes bit at lower left of plate.')
    parser.add_argument('material', help='the material to cut (wood, aluminum, etc.)')
    parser.add_argument('stock_height', help='height of stock. z=0 is top of stock.', type=float)
    args = parser.parse_args()

    mat = init_material(args.material)
    g = G(outfile='path.nc', aerotech_include=False, header=None, footer=None, print_lines=False)
    nomad_header(g, mat, CNC_TRAVEL_Z)
    board(g, mat, args.stock_height)
    g.spindle()
コード例 #5
0
def main():
    try:
        float(sys.argv[3])
        is_number_pairs = True
    except:
        is_number_pairs = len(sys.argv) > 3 and (sys.argv[3].find(',') >= 0)

    if len(sys.argv) < 4:
        print('Drill a set of holes.')
        print('Usage:')
        print('  drill material depth file')
        print('  drill material depth x0,y0 x1,y1 (etc)')
        print('  drill material depth x0 y0 x1 y1 (etc)')
        print('Notes:')
        print('  Runs in absolute coordinates.')
        print('  Travel Z={}'.format(CNC_TRAVEL_Z))
        sys.exit(1)

    mat = init_material(sys.argv[1])
    cut_depth = float(sys.argv[2])
    points = []
    g = G(outfile='path.nc',
          aerotech_include=False,
          header=None,
          footer=None,
          print_lines=False)
    nomad_header(g, mat, CNC_TRAVEL_Z)

    if not is_number_pairs:
        filename = sys.argv[3]
        points = read_DRL(filename)
    else:
        # Comma separated or not?
        if sys.argv[3].find(',') > 0:
            for i in range(3, len(sys.argv)):
                comma = sys.argv[i].find(',')
                x = float(sys.argv[i][0:comma])
                y = float(sys.argv[i][comma + 1:])
                points.append({'x': x, 'y': y})
        else:
            for i in range(3, len(sys.argv), 2):
                points.append({
                    'x': float(sys.argv[i + 0]),
                    'y': float(sys.argv[i + 1])
                })

    drill_points(g, mat, cut_depth, points)
    g.spindle()
コード例 #6
0
def main():
    parser = argparse.ArgumentParser(
        description='Cut a rectangle accounting for tool size.')
    parser.add_argument('material',
                        help='the material to cut (wood, aluminum, etc.)')
    parser.add_argument('depth',
                        help='depth of the cut. must be negative.',
                        type=float)
    parser.add_argument('dx', help='x width of the cut.', type=float)
    parser.add_argument('dy', help='y width of the cut.', type=float)
    parser.add_argument('-f',
                        '--fillet',
                        help='fillet radius',
                        type=float,
                        default=0)
    parser.add_argument('-a',
                        '--align',
                        help="'center', 'inner', 'outer'",
                        type=str,
                        default='center')
    parser.add_argument('-i',
                        '--inside_fill',
                        help="fill inside area",
                        action='store_true')
    parser.add_argument(
        '-o',
        '--origin',
        help="origin, can be 'left', 'bottom', 'right', or 'top'",
        type=str,
        default="left")

    args = parser.parse_args()
    mat = init_material(args.material)

    g = G(outfile='path.nc',
          aerotech_include=False,
          header=None,
          footer=None,
          print_lines=False)
    g.feed(mat['feed_rate'])
    g.absolute()
    g.move(x=0, y=0, z=0)
    g.relative()
    rectangleTool(g, mat, args.depth, args.dx, args.dy, args.fillet,
                  args.origin, args.align, args.inside_fill)
    g.spindle()
コード例 #7
0
def main():
    parser = argparse.ArgumentParser(
        description=
        'Cut out a cylinder or valley. Very carefully accounts for tool geometry.'
    )
    parser.add_argument('material',
                        help='the material to cut (wood, aluminum, etc.)')
    parser.add_argument('diameter',
                        help='diameter of the cylinder.',
                        type=float)
    parser.add_argument('dx',
                        help='dx of the cut, flat over the x direction',
                        type=float)
    parser.add_argument('dy',
                        help='dy of the cut, curves over the y direction',
                        type=float)
    parser.add_argument('-o',
                        '--overlap',
                        help='overlap between each cut',
                        type=float,
                        default=0.5)
    parser.add_argument('-b',
                        '--ball',
                        help="use ball cutter",
                        action="store_true")

    args = parser.parse_args()
    g = G(outfile='path.nc',
          aerotech_include=False,
          header=None,
          footer=None,
          print_lines=False)
    mat = init_material(args.material)

    nomad_header(g, mat, CNC_TRAVEL_Z)
    g.move(z=0)
    hill(g, mat, args.diameter, args.dx, args.dy, args.ball)
    g.spindle()
コード例 #8
0
#
# ECHO: "Plate cut, LEN", 39.25
# ECHO: "width", 16.5
# ECHO: "PORT", 8, "BOLT", 21, "SWITCH", 32.25
#

import sys
from utility import *
from material import init_material
from rectangleTool import rectangleTool
from mecode import G
from hole import hole

mat = init_material(sys.argv[1])
g = G(outfile='path.nc', aerotech_include=False, header=None, footer=None)
nomad_header(g, mat, CNC_TRAVEL_Z)
g.absolute()

depth = -(25.4 / 4 + 1.0)
sink = -1.0

LENGTH = 39.25
WIDTH = 16.5

PORT = 8
BOLT = 21
SWITCH = 32.25
# Weird and tweaked because of a 3.3mm bit (grr)
TRIM = -0.04

TROUGH = 11.0
コード例 #9
0
import sys
import math
from utility import *
from material import init_material
from rectangleTool import rectangleTool
from mecode import G
from hole import hole
from plane import plane

mat0 = init_material(sys.argv[1])
mat1 = init_material(sys.argv[2])

g = G(outfile='path.nc', aerotech_include=False, header=None, footer=None)
nomad_header(g, mat0, CNC_TRAVEL_Z)
g.absolute()
g.move(z=0)

plane(g, mat0, -2, 0, 0, 10, 10)

tool_change(g, mat1, 1)

g.move(x=2, y=2)
g.move(z=-2)
plane(g, mat1, -2, 0, 0, 6, 6)
コード例 #10
0
ファイル: topcut.py プロジェクト: vargose/OpenSaber
from utility import *
from material import init_material
from capsule import capsule
from mecode import G

# inner line to inner line: 47mm
# 2.5mm space
# capsule at center

mat = init_material("np883-aluminum-3.175")
g = G(outfile='path.nc', aerotech_include=False, header=None, footer=None)
nomad_header(g)

# at center of switch hole; move to center of capsule.
g.move(y=42.0/2 - 16.2/2)
capsule(g, mat, -10, 42.0, 16.2, None, True, 'y')



コード例 #11
0
                  size + TRIM_CHIP * 2,
                  size + TRIM_CHIP * 2,
                  0,
                  "center",
                  "inner",
                  fill=True)

    # overcut
    g.move(z=-DZ_EDGE)
    g.move(x=x - size / 2 - TRIM_CHIP, y=y - size / 2 - TRIM_CHIP)
    overCut(g, mat, d, size + TRIM_CHIP * 2, size + TRIM_CHIP * 2)

    g.move(z=0)


mat = init_material("np883-hdpe-3.175")
g = G(outfile='path.nc',
      aerotech_include=False,
      header=None,
      footer=None,
      print_lines=False)
nomad_header(g, mat, CNC_TRAVEL_Z)

g.absolute()

# level part
# really need overcut support. until then...hole the corners.
half = mat['tool_size'] / 2
g.move(x=-D + half, y=-D + half)
g.move(z=0)
hole(g, mat, -DZ_EDGE, d=4.0)
コード例 #12
0
ファイル: woodcut.py プロジェクト: vargose/OpenSaber
H_WOOD = 8.0
H_STOCK = 13.30
X_CAPSULE = 42.0
Y_CAPSULE = 16.2
Z_PAD = 0.5
TOOL = 3.175
DZ_CENTER = (X_CAPSULE - Y_CAPSULE) / 2
MAT = 'np883-hardwood-{0}'.format(TOOL)
D_OUTER = 32.0  # FIXME

center = Rectangle(0, -Y_CAPSULE / 2, X_CAPSULE, Y_CAPSULE / 2)
bounds = Bounds(TOOL, center)
bottom = -H_WOOD - Z_PAD
top = -(H_STOCK - H_WOOD)

mat = init_material(MAT)
g = G(outfile='path.nc',
      aerotech_include=False,
      header=None,
      footer=None,
      print_lines=False)
nomad_header(g, mat, H_STOCK + CNC_TRAVEL_Z)

g.absolute()
g.move(z=0)

if (H_STOCK < H_WOOD):
    raise RuntimeError("Stock can be the same as the wood, but not lower.")

if H_STOCK > H_WOOD:
    plane(g, mat, top, bounds.outer.x0, bounds.outer.y0, bounds.outer.x1,
コード例 #13
0
from utility import *
from material import init_material
from rectangleTool import rectangleTool
from mecode import G
from hole import hole

mat = init_material("np883-aluminum-1.0")
g = G(outfile='path.nc', aerotech_include=False, header=None, footer=None)
nomad_header(g, mat, CNC_TRAVEL_Z)

# DOTSTAR_Z = 73.0 - 21.0 = 52.0;
# and origin, since it is recessed in

DOTSTAR_PITCH = 7.0
depths = [-0.5, -1.0, -2.0]

for d in depths:
    for i in range(4):
        x = i * DOTSTAR_PITCH
        travel(g, mat, y=x)
        g.move(z=0)
        hole(g, mat, d, d=1.7)
コード例 #14
0
ファイル: kenobi_iv.py プロジェクト: vargose/OpenSaber
from material import init_material
from mecode import G
from drill import drill
from hole import hole
from utility import CNC_TRAVEL_Z
from rectangle import rectangle

mat = init_material("np883-fr-1.0")
tool_size = 1.0
half_tool = tool_size / 2
cut_depth = -2.5

g = G(outfile='path.nc',
      aerotech_include=False,
      header=None,
      footer=None,
      print_lines=False)
g.absolute()
g.feed(mat['feed_rate'])
g.move(z=CNC_TRAVEL_Z)
g.spindle('CW', mat['spindle_speed'])

# Drill holes for the tactile switch.
holes = [[15.25, 14.75], [19.85, 14.75], [15.25, 8.26], [19.85, 8.26]]

for h in holes:
    g.move(x=h[0], y=h[1])
    drill(g, mat, cut_depth)

# Mounting holes.
mount = [[2.54, 3.175], [22.225, 3.175], [2.54, 19.685], [22.225, 19.685]]