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 considering acceleration limits
  • Junction deviation modeling for realistic speed transitions
  • Visualization of tool paths with color-coded feed rates
  • Support for different GRBL firmware versions
  • JSON output option for integration with other tools

Installation

pip install gcode-simulator

## Features

- Accurate time estimation considering acceleration limits
- Junction deviation modeling for realistic speed transitions
- Visualization of tool paths with color-coded feed rates
- Support for different GRBL firmware versions
- JSON output option for integration with other tools

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.0.3.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.0.3-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gcode_simulator-0.0.3.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.0.3.tar.gz
Algorithm Hash digest
SHA256 e275edd01e8966c88f7851c234f5f033629cdfec596476f019d03ae4ee4ed0a7
MD5 04fcb71cd655c69ffc2d31e5dbe4bb41
BLAKE2b-256 4d5b63eec20b5306c267a8ed1fd41dab8a928141ec0991997de0718b5401efdd

See more details on using hashes here.

Provenance

The following attestation bundles were made for gcode_simulator-0.0.3.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.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for gcode_simulator-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6d7f34661df5c0d94af3bd95ffd0c0abafa7d0e6abc2c90702c4fa5bd4ff2402
MD5 4bb4a48a1afd0d8c4e12f55bf09ea71b
BLAKE2b-256 eef3631a03d41f3e3c77231dbe89b3bcfeae2228d1259af689c0258ba428e253

See more details on using hashes here.

Provenance

The following attestation bundles were made for gcode_simulator-0.0.3-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