feat: add svg to gcode parser
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
*.pyc
|
||||
.venv
|
||||
*.bin
|
||||
*.bin
|
||||
*.gcode
|
||||
12
config.toml
Normal file
12
config.toml
Normal file
@@ -0,0 +1,12 @@
|
||||
[gwrite.hp7044b]
|
||||
unit = "mm"
|
||||
document_start = "(document_start)\n"
|
||||
layer_start = "(Start Layer)\n"
|
||||
line_start = "(Start Block)\n"
|
||||
segment_first = """G00 Z5
|
||||
G00 X{x:.4f}f Y{y:.4f} Z1
|
||||
"""
|
||||
segment = """G01 X{x:.4f} Y{y:.4f} Z-1\n"""
|
||||
line_end = """G00 Z 5.0000\n"""
|
||||
document_end = """G00 X0.0000 Y0.0000"""
|
||||
invert_y = true
|
||||
@@ -1,3 +1,4 @@
|
||||
vsketch
|
||||
vpype-perspective
|
||||
vpype-gcode
|
||||
PyQT5
|
||||
25
svg_to_gcode.py
Executable file
25
svg_to_gcode.py
Executable file
@@ -0,0 +1,25 @@
|
||||
#! /usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import shlex
|
||||
import vpype
|
||||
import vpype_cli
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Convert SVG files to G-code.")
|
||||
parser.add_argument("input", type=str, help="Input SVG file path")
|
||||
parser.add_argument("output", type=str, help="Output G-code file path")
|
||||
vpype_args = parser.parse_args()
|
||||
|
||||
svg_collection, width, height = vpype.read_svg(vpype_args.input, 4)
|
||||
doc = vpype.Document(svg_collection, page_size=(width, height))
|
||||
|
||||
@vpype_cli.cli.command(group="vsketch")
|
||||
@vpype_cli.global_processor
|
||||
def vsketchinput(document):
|
||||
document.extend(doc)
|
||||
return document
|
||||
|
||||
vpype_args = "vsketchinput gwrite -p hp7044b {}".format(vpype_args.output)
|
||||
vpype.config_manager.load_config_file("config.toml")
|
||||
vpype_cli.cli.main(prog_name="vpype", args=shlex.split(vpype_args), standalone_mode=False)
|
||||
Reference in New Issue
Block a user