Skip to main content

gcody

Gcody is a python wrapper for GCODE. It gives common programming language functionality to GCODE as well as several visualization tools. This is an early draft of gcody and it is intended for general writing of GCODE, not printer specific code. Gcody was inspired by mecode.

Basics:

# gcody example creating a serpentine pattern and an elephant

# these are both normally imported from gcody
from gcody import *

# creating parameters
distance = 10
cycles = 10

# creating gcode object
g = gcode()

# writes the GCODE command to use relative coordinates
# this changes how position is recorded internally (in gcode object)
# abs_coords is the default setting for gcode and is the default for gcody as well
g.rel_move()

# moves the print head back and forth in x
g.move(distance, speed=10, com='Moves head 10 in x')


# moves the print head back and forth in x
for i in range(1,cycles):
    # simple move allows for modality (not repeating commands)
    # it makes the GCODE prettier :)
    # unfortunately, not all printers support it :(
    g.simple_move(y=10) # movement in y
    g.simple_move((-1)**i * distance) # movement in x

# creates a matplotlib figure matching the path of the printer head
g.view('b')

# This is an animated figure showsing the progression of the printer path
g.animated('b',save_file='snake.gif')


# saves the GCODE to a file
g.save('snake') # outputs file 'snake.gcode'
g.save('snake','txt') # outputs file 'snake.txt'

The output GCODE is:

G91 ; use relative coordinates
F600 ; 10 mmps motion
G1 X10.000000 ; Moves head 10 in x
Y10.000000
X-10.000000
Y10.000000
X10.000000
Y10.000000
X-10.000000
Y10.000000
X10.000000
Y10.000000
X-10.000000
Y10.000000
X10.000000
Y10.000000
X-10.000000
Y10.000000
X10.000000
Y10.000000
X-10.000000

The other features of gcody are readying existing GCODE and displaying it:

# file from https://www.thingiverse.com/thing:998999/#files
# gcode generated with latest Cura (https://ultimaker.com/en/products/ultimaker-cura-software)
file = 'elefante_small.gcode'

# This reads the GCODE file line by line and converts it into a gcode object
# GCODE file can be hundreds of thousands of lines, if not more. This means reading them
# can be slow. The math comes out to is roughly 13,000 move lines per second.
elefante = read(file)

# This figure colors the lines draw with a color that corresponds to a print time
elefante.cbar_view() # This method takes ~60 seconds to work.

# this view has a slider bar that allows one to select the print time
elefante.slide_view('r')

See images on github!

Dependencies:

  • Numpy
  • Matplotlib

Optional Dependencies

  • pillow, ImageMagic, of FFmpeg as optional dependancies for matplotlib to save videos
  • Mayavi for viewing backends

To Do:

  • Add clockwise motion commands
  • Add in other GCODE commands
  • Add more complex combinations of move
  • Take requests for features

Metadata

Release files for gcody 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gcody 0.5.1
File Size Uploaded Provenance Actions
gcody-0.5.1.tar.gz 19.1 kB Without provenance Details for gcody-0.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gcody 0.5.1
File Interpreter ABI Platform Actions
gcody-0.5.1-py3-none-any.whl Python 3 none any Details for gcody-0.5.1-py3-none-any.whl

Total release size: 40.3 kB

Release files / gcody-0.5.1.tar.gz

Download URL gcody-0.5.1.tar.gz
Size 19.1 kB
Tags Source
SHA-256 checksum
How to use checksums
62356437cf566c4bc00d7e80457a15a8dc8983b36ab17b35a0d29ef076b72800
BLAKE2b-256 checksum
How to use checksums
15205096eafb141533e51d4a605cc658b059d0c16295067734b0ac3421159ee8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / gcody-0.5.1-py3-none-any.whl

Download URL gcody-0.5.1-py3-none-any.whl
Size 21.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f27988cef177e155d532f6c87f0b947286b49aef5291120a182c0edd4ecb14e2
BLAKE2b-256 checksum
How to use checksums
3ab624b51485a076b404dabbccb8e3ee84c0bc140390bb465a43b6431d3aca55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for gcody 0.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page