Skip to main content

Acurately analyze and simulate gcode tool-path for plotters, CNCs, 3D printers and more.

Project description

gcode-simulator

Python package for analyzing and simulating gcode tool-path for plotters, CNC, 3D printers and more.

Features

  • Accurate time estimation with junction deviation modeling
  • Visualization of tool paths with feed rates

Installation

pip install gcode-simulator

Usage

gcode-simulator come with both a cli and a python API.

Command Line Interface

Analyze a G-code file to estimate execution time and visualize the tool path:

gcode-simulator path/to/your/file.gcode

Options

--max-rate-x FLOAT       Maximum feed rate for X axis in mm/min ($110) [default: 3000.0]
--max-rate-y FLOAT       Maximum feed rate for Y axis in mm/min ($111) [default: 3000.0]
--max-accel-x FLOAT      Maximum acceleration for X axis in mm/s^2 ($120) [default: 800.0]
--max-accel-y FLOAT      Maximum acceleration for Y axis in mm/s^2 ($121) [default: 800.0]
--junction-deviation FLOAT  Junction deviation in mm ($11) [default: 0.01]
--grbl-version TEXT      GRBL firmware version [default: 0.9i]
--visualize / --no-visualize  Display a visualization of the toolpath [default: no-visualize]
--json-output / --no-json-output  Output results in JSON format [default: no-json-output]
--help                   Show this message and exit.

Python API

GCodeSimulator

from gcode_simulator import GCodeSimulator, GrblSettings

# Configure GRBL settings
settings = GrblSettings(
    max_rate_x=3000.0,  # mm/min
    max_rate_y=3000.0,  # mm/min
    max_accel_x=800.0,  # mm/s^2
    max_accel_y=800.0,  # mm/s^2
    junction_deviation=0.01,  # mm
    grbl_version='0.9i'
)

# Create simulator with tracing enabled for visualization
simulator = GCodeSimulator(settings, trace=True)

# Load G-code from a file
with open('path/to/your/file.gcode', 'r') as f:
    gcode = f.read()

# Estimate execution time and get boundaries
time_seconds, bounds = simulator.estimate_time(gcode)

print(f"Estimated execution time: {time_seconds:.2f} seconds")
print(f"Width: {bounds.width:.2f}mm, Height: {bounds.height:.2f}mm")

Visualization

from gcode_simulator import GCodeSimulator, GrblSettings
from gcode_simulator.viz import plot_trace

# Setup and run the simulator as shown above
simulator = GCodeSimulator(settings, trace=True)
time_seconds, bounds = simulator.estimate_time(gcode)

# Visualize the tool path with color-coded feed rates
plot_trace(simulator.trace_nodes, bounds)

The visualization shows the G-code path with color-coded feed rates and a grid for scale. Each line segment is colored according to its feed rate, with a color bar indicating the feed rate values.

Feed Rate Visualization

Feed Rate Visualization Closeup

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

gcode_simulator-0.2.1.tar.gz (4.4 MB view details)

Uploaded Source

Built Distribution

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

gcode_simulator-0.2.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file gcode_simulator-0.2.1.tar.gz.

File metadata

  • Download URL: gcode_simulator-0.2.1.tar.gz
  • Upload date:
  • Size: 4.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for gcode_simulator-0.2.1.tar.gz
Algorithm Hash digest
SHA256 7fe8ff182cdb8dc6bf4f74462c7d2f8dea498acaa2535d91eef4f98099eadd38
MD5 4244696e5add8a728c0b4f0e51507f7d
BLAKE2b-256 24d2e7f77e8c80b19a5af5d531f2df2ae0b15ab33477e5e3b216a6a2f250a15f

See more details on using hashes here.

Provenance

The following attestation bundles were made for gcode_simulator-0.2.1.tar.gz:

Publisher: python-publish.yml on mrudelle/gcode-simulator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gcode_simulator-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gcode_simulator-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 548fb95bc313c86b78b7bb21335cfd6538d52f05384647a8114f302cebfd125a
MD5 f8ea922a5f34a7ab98deb2cdd3df6030
BLAKE2b-256 ca029edcbc55e8a06de7af2d4c573d5a6a1056de9668b28b72d0891631964c5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for gcode_simulator-0.2.1-py3-none-any.whl:

Publisher: python-publish.yml on mrudelle/gcode-simulator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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