コード例 #1
0
def to_gcode(svgfile, gcodefile):
    gcode_compiler = Compiler(DrawbotInterface,
                              movement_speed=1000,
                              cutting_speed=300,
                              pass_depth=0)
    curves = parse_file(svgfile)  # Parse an svg file into geometric curves
    gcode_compiler.append_curves(curves)
    gcode_compiler.compile_to_file(gcodefile, passes=1)
コード例 #2
0
def generate_gcode(image,
                   movement_speed=1000,
                   cutting_speed=300,
                   pass_depth=0):  # Дифолті налаштування
    gcode_compiler = Compiler(CustomInterface,
                              movement_speed=movement_speed,
                              cutting_speed=cutting_speed,
                              pass_depth=pass_depth)
    image_path = Path(image).resolve()
    curves = parse_file(image_path)
    gcode_compiler.append_curves(curves)
    gcode_compiler.compile_to_file('test.gco')
コード例 #3
0
def run_test(svg_file_name, debug_file_name):
    curves = parse_file(svg_file_name)

    success = True
    approximations = []
    count = 0
    for curve in curves:
        approximation = LineSegmentChain.line_segment_approximation(curve)
        approximations.append(approximation)
        count += approximation.chain_size()

    generate_debug(approximations, svg_file_name, debug_file_name)

    return success
コード例 #4
0
def run_test(svg_file_name, debug_file_name):
    curves = parse_file(svg_file_name)

    success = True
    approximations = []
    for curve in curves:
        approximation = LineSegmentChain.line_segment_approximation(curve)
        approximations.append(approximation)

        # Todo find a way to automatically determine success. Right now manual revision of debug files is required.

    generate_debug(approximations, svg_file_name, debug_file_name)

    return success
コード例 #5
0
def convertSvgToGcode(svg_path, gcode_path):
    try:
        gcode_compiler = Compiler(interfaces.Gcode,
                                  movement_speed=1000,
                                  cutting_speed=300,
                                  pass_depth=0,
                                  unit='mm')
        curves = parse_file(svg_path, transform_origin=False)
        gcode_compiler.append_curves(curves)
        gcode_compiler.compile_to_file(gcode_path)
    except:
        traceback.print_exc()
        return False

    return True
コード例 #6
0
ファイル: test.py プロジェクト: tommy3001/SvgToGcode
def run_test(svg_file_name, _):
    root = ElementTree().parse(svg_file_name)
    root_curves = parse_root(root)

    with open(svg_file_name, 'rb') as svg_file:
        svg_string = svg_file.read()
    string_curves = parse_string(svg_string)

    file_curves = parse_file(svg_file_name)

    if str(root_curves) != str(string_curves) or str(string_curves) != str(file_curves):
        print("Inconsistent parsing.")
        print("parse_root() ->", root_curves)
        print("parse_string() ->", string_curves)
        print("parse_file() ->", file_curves)
        return False

    return True
コード例 #7
0
from svg_to_gcode.svg_parser import parse_file
from svg_to_gcode.compiler import Compiler, interfaces

# Instantiate a compiler, specifying the interface type and the speed at which the tool should move. pass_depth controls
# how far down the tool moves after every pass. Set it to 0 if your machine does not support Z axis movement.
gcode_compiler = Compiler(interfaces.Gcode, movement_speed=1000, cutting_speed=0, pass_depth=0)

curves = parse_file("SpiralSVG.svg") # Parse an svg file into geometric curves

gcode_compiler.append_curves(curves) 
gcode_compiler.compile_to_file("SpiralSVG.gcode", passes=1)