Saturday, April 11, 2015

A 3D printer simulator

Recently I wrote a python code that reads G-code generated by Slic3r, interprets the G-code, and creates a simple 3D plot that simulating a real 3D printer. It provides a nice preview of G-code.

The code can by downloaded here from my google drive.

If the link doesn't work, copy the following url and paste to your browser

The folder contains:


This is the configuration file. The file should contain:
line 1: G-code file name (including path). e.g., gcodes\squirrel_export.gcode
line 2: nS. A positive integer. A new section will be plotted after skipping (nS-1) sections. Minimal value is 1 (every section will be plotted). Smaller nS gives finner (and larger) plot.
line 3: nP. A positive integer. A new point will be plotted after skipping (nP-1) points. Minimal value is 1 (every point will be plotted). Smaller nP gives finner (and larger) plot.
line 4: dx, dy, dz, de. Resolution of the 3D printer in x,y,z direction and resolution of filament extruder. 

The main program that reads configuration from simulator_config.txt and calls and creates plot.

Simple run this code and get a 3D plot

File that contains functions to interprete G-code


A folder that contains some G-code examples.


Here is the example when running the "squirrel_export.gcode" file provided in the google drive folder.

snapshot when code is runing
Finished! You can rotate the view or zoom in/out