コード例 #1
0
ファイル: reader.py プロジェクト: gntech/pycnc
def gcode_reader(filename=None, content=None):
    """ x """
    if filename == None:
        temp = content.splitlines(True)
        lines = [l.decode() for l in temp]
    else:
        with open(filename, "r") as f:
            lines = f.readlines()

    profile = []
    for line in lines:
        p = gcode_parser(line)
        if isinstance(p, Point):
            if p.x == None or p.y == None:
                if isinstance(profile[-1], Gap):
                    prev = profile[-2]
                else:
                    prev = profile[-1]
                if p.x == None:
                    p.x = prev.x
                if p.y == None:
                    p.y = prev.y

            profile.append(p)
        elif isinstance(p, G2) or isinstance(p, G3):
            temp = linearize(p, profile[-1])
            profile += temp
        else:
            profile.append(p)

    return profile
コード例 #2
0
ファイル: base_paths.py プロジェクト: gntech/pycnc
def circle_segment(x, y, z0, z1, r, alpha_start, alpha_end, tool):
    """ x """
    a1 = np.radians(alpha_start)
    a2 = np.radians(alpha_end)

    i1 = -r * math.cos(a1)
    j1 = -r * math.sin(a1)
    i2 = -r * math.cos(a2)
    j2 = -r * math.sin(a2)

    x1 = x - i1
    y1 = y - j1
    x2 = x - i2
    y2 = y - j2

    start = Point(x=x1, y=y1)
    arc = G2(x=x2, y=y2, i=i1, j=j1)
    # rev_arc G3(x=x1, y=y1, i=i2, j=j2)

    return linearize(arc, start)