svg2plot.tui#

Terminal user interface (TUI) that allows users to select SVG files, convert them to G-Code, and send the G-Code to the plotter.

Key features include:

  1. File Browser: Allows users to navigate through directories and select files.

  2. SVG to G-Code Conversion: Converts SVG graphics into G-Code commands using the vpype library, with options for path optimization, movement speed and pen pressure settings.

  3. Plotting: Connects to the plotter via serial interface, performs a homing cycle if necessary, and sends G-Code commands to start plotting.

  4. Error Handling: Includes checks for path length limits and SVG file properties (e.g., dimensions, respect of dpi conventions).

Functions

convert_svg_gcode(console, svg_file)

create_temporary_file(data[, suffix])

Creates a tempfile.NamedTemporaryFile object for data.

file_browser(console, current_directory)

get_files_in_directory(directory)

header(console)

TODO: add some parameters (/dev/ttyUSB0, baudrate, etc.)

is_adobe_svg(file[, head])

Check in header if svg file has been generated by Adobe Illustrator.

main()

make_toml(p)

no_size(svg)

Check in header if svg file has a width/height value.

select_plot_pression()

Prompt selection of pressure value.

setup_plotter(console, gcode_file)

too_many_lines(drawing, console)

Get metadate from SVG file, particularly the number of segments.

Classes

Controller(*args, **kwargs)

Class to communicate with the plotter's controller.

class Controller(*args: Any, **kwargs: Any)[source]#

Bases: Serial

Class to communicate with the plotter’s controller.

send(console: rich.console.Console, commands: str | list[str]) str[source]#
stream(console: rich.console.Console, commands: str | list[str]) None[source]#
connect(console: rich.console.Console) None[source]#
disconnect(console: rich.console.Console) None[source]#
get_files_in_directory(directory: str) tuple[rich.table.Table, dict[int, str]][source]#
header(console: rich.console.Console) None[source]#

TODO: add some parameters (/dev/ttyUSB0, baudrate, etc.)

file_browser(console: rich.console.Console, current_directory: str) str[source]#
too_many_lines(drawing: vpype.Document, console: rich.console.Console) bool[source]#

Get metadate from SVG file, particularly the number of segments.

no_size(svg: str) bool[source]#

Check in header if svg file has a width/height value.

Adobe Illustrator tends not to.

is_adobe_svg(file: str, head: int = 10) bool[source]#

Check in header if svg file has been generated by Adobe Illustrator.

select_plot_pression() str[source]#

Prompt selection of pressure value.

create_temporary_file(data: str, suffix: str = '') str[source]#

Creates a tempfile.NamedTemporaryFile object for data.

  • source:https://programtalk.com/vs4/python/Aguila-team/aguila_nlu/rasa_nlu/utils/__init__.py/

make_toml(p: str) str[source]#
convert_svg_gcode(console: rich.console.Console, svg_file: str) str | None[source]#
setup_plotter(console: rich.console.Console, gcode_file: str) None[source]#
main()[source]#