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
https://drive.google.com/folderview?id=0B8QP2HPTAprrVUdKMFZaQXJjRFk&usp=sharing


The folder contains:

simulator_config.txt

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.

Rapibot_simulator.py 

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

Simple run this code and get a 3D plot

Gcode_interpretation_functions.py

File that contains functions to interprete G-code

gcodes

A folder that contains some G-code examples.


Example 

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