Skip to main content

svg2gcode: convert an SVG (Scalable Vector Graphic) image to gcode.

Project description

svg2gcode

A commandline steering program that enables laser cutting of svg drawings<svg:path ..>tags and combined engraving of svg images<svg:image ..>tags. It is based on library SvgToGcode (fork: https://github.com/johannesnoordanus/SvgToGcode) which should be installed (*).

Drawings and images can be composed using Inkscape (for example) and saved to a .svg file. This file can be converted to gcode by svg2gcode. Gcode produced in this way has the advantage that drawings and images have the same - relative - position and orientation as can be seen on the composer window. This makes combined cutting and engraving as easy as orientating the (wood) slab once.

Controlling laser power, pixel size and other settings can be done via commandline parameters (see below) or within Inkscape using the XMLeditor. Image attributes gcode_pixelsize, gcode_maxpower and gcode_speed can be set per object (they must be created: use +). Note that this overrides explicit or default commandline settings.

Tip: use commandline program grblhud (https://github.com/johannesnoordanus/grblhud) to have full control over gcode execution.

Install:

> 
> pip install svg2gcode

(*) Note that library svg_to_gcode is included in this package.

Usage:

See notes below.

$ svg2gcode --help
usage: svg2gcode.py [-h] [--showimage] [--pixelsize <default:0.1>] [--imagespeed <default:800>] [--cuttingspeed <default:1000>] [--imagepower <default:300>]
                    [--cuttingpower <default:0.85>] [--maxlaserpower <default:1000>] [--rapidmove] [--xmaxtravel <default:300>] [--ymaxtravel <default:400>] [--fan] [-V]
                    svg gcode

Convert svg to gcode for GRBL v1.1 compatible diode laser engravers.

positional arguments:
  svg                   svg file to be converted to gcode
  gcode                 gcode output file

options:
  -h, --help            show this help message and exit
  --showimage           show b&w converted image
  --pixelsize <default:0.1>
                        pixel size in mm (XY-axis): each image pixel is drawn this size
  --imagespeed <default:800>
                        image draw speed in mm/min
  --cuttingspeed <default:1000>
                        cutting speed in mm/min
  --imagepower <default:300>
                        maximum laser power while drawing an image (as a rule of thumb set to 1/3 of the machine maximum)
  --cuttingpower <default:0.85>
                        percentage of maximum laser power for line drawings/cutting
  --maxlaserpower <default:1000>
                        maximum laser power of laser cutter
  --rapidmove           generate inbetween G0 moves
  --xmaxtravel <default:300>
                        machine x-axis lengh in mm
  --ymaxtravel <default:400>
                        machine y-axis lengh in mm
  --fan                 set machine fan on
  -V, --version         show version number and exit

Notes:

  • example command to create two types of gcode file, one containing the drawings of the .svg, the other containing the images:
  > svg2gcode ambachtmanlogo.svg logo.gc
  > ..
  > ls *.gc 
  > logo.gc             # all drawings
  > logo_images.gc      # all images
  • drawing objects - within the composer - must be converted to apathto be translated to a gcode sequence
  • also, image objects should not be converted to a path
  • images must be included within the .svg file (not linked) and be base64 encoded.
  • images can be in several formats (my tests included .png and .jpg image files)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

svg2gcode-1.1.2.tar.gz (43.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

svg2gcode-1.1.2-py3-none-any.whl (55.1 kB view details)

Uploaded Python 3

File details

Details for the file svg2gcode-1.1.2.tar.gz.

File metadata

  • Download URL: svg2gcode-1.1.2.tar.gz
  • Upload date:
  • Size: 43.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.2

File hashes

Hashes for svg2gcode-1.1.2.tar.gz
Algorithm Hash digest
SHA256 f131e52f9cb08588610c40bcd0503024ba3e5706f10375a147df8edd97ef94e5
MD5 5f5fcc3fbf71a6ec376217cf698dbae8
BLAKE2b-256 885f166c3947029337444ba68e41654c375b4e84d7b3b95225b727929e5f50d2

See more details on using hashes here.

File details

Details for the file svg2gcode-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: svg2gcode-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 55.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.2

File hashes

Hashes for svg2gcode-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 83980005b03542d236f3650a910bc0227725eed7307d29d4c5b7de1b3e9cf2e4
MD5 6eac21573886bd114c91f6ed17795db2
BLAKE2b-256 ae48b9182a73f6d836910023b101fdbcfcfc758a7e1ef92b50d40c4fafc35518

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page