Hey! This thing is still a Work in Progress. Files, instructions, and other stuff might change!

Yet Another Gcode Viewer

by jonathanw, published

Yet Another Gcode Viewer by jonathanw Dec 17, 2012



Use This Project

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag.

Print Thing Tag

Thing Statistics

23075Views 3353Downloads Found in 3D Printing


yagv - Yet Another Gcode Viewer

This is a fast 3D Gcode Viewer for Reprap-style 3D printers, in Python and OpenGL (via pyglet)

It was written since I could not find a visualizer that fitted my needs, i.e:

  • Load large files painlessly
  • Let me choose the layer to display
  • Color segments according to function
  • Show a full 3D view for better undertanding of the code.

Designed in Ubuntu Linux; Expected to work in any Linux, Windows or OS X

Full code at https://github.com/jonathanwin/yagv and attached



yagv [file.gcode]

  • By default, open data/hana_swimsuit_fv_solid_v1.gcode if no file specified


  • Colors segments according to their type:
    • extruding
    • flying the head to the next extrusion point
    • retracting filament
    • restoring filament
  • Allows displaying layers independently to examine them.
  • Automagically splits the gcode into layers.
  • Automatic scaling to fit the window.
  • Zoom and rotation (Panning planned).


  • Panning for close inspection not yet supported.
  • Retract/restore detected but invisible (0-length segments).
  • Designed with Slic3r output in mind, may not support other slicing programs (suggestions/patches welcome).
  • Some gcodes unsupported:
    • G91: Set to Relative Positioning (used by some slicers)
    • G20: Set Units to Inches (usage unknown)
    • Arcs (G2 & G3 ?)

Supplied demo gcode is a slice of http://www.thingiverse.com/thing:5176 (loaded if called with no file)

Since I started this, hudbrog published his very nice GCode Analyzer/Visualizer; check it out: http://www.thingiverse.com/thing:35248


Download and unzip the program.

Install python 2 and pyglet.

Make sure the yagv file is executable, run "./yagv [file.gcode]"
Alternatively, setup a symlink to the yagv executable in your PATH, or add the yagv folder to the PATH

Under Windows, you may need to run "python path\to\yagv file.gcode" instead (feedback welcome)

More from 3D Printing

view more

All Apps

Upgrade this Thing with Thingiverse Apps

Tools and Utilities

Repair, slice, or enhance this Thing

Auto-magically prepare your 3D models for 3D printing. A cloud based 3D models Preparing and Healing solution for 3D Printing, MakePrintable provides features for model repairing, wall thickness...

App Info Launch App

Thanks for this.

For those having errors, there is a small bug in the code.
in "gcodeParser.py" on line 62, missing the word "parse_"

Go to line 62 and change:
self.G1(args, "G0")

to instead read:
self.parse_G1(args, "G0")

Seemed that it doesn't know some codes.
I failed to view with error:
[WARN] Line 1: Unknown code 'M190' (Text:'M190 S110.000000')
[WARN] Line 2: Unknown code 'M109' (Text:'M109 S250.000000')
[WARN] Line 12: Unknown code 'M82' (Text:'M82 ;set extruder to absolute mode')
[WARN] Line 13: Unknown code 'M107' (Text:'M107 ;start with the fan off')
[WARN] Line 14: G28 unimplemented (Text:'G28 X0 Y0 ;move X/Y to min endstops')
[WARN] Line 15: G28 unimplemented (Text:'G28 Z0 ;move Z to min endstops')
[WARN] Line 22: Unknown code 'M117' (Text:'M117 Printing...')
[WARN] Line 27: Unknown code 'M107' (Text:'M107')
Traceback (most recent call last):
File "yagv", line 403, in
app = App().run(path)
File "yagv", line 32, in run
self.model = self.parser.parseFile(path)
File "d:#soft\engineering\3d_printing\Yet_Another_Gcode_Viewer\yagv\gcodeParser.py", line 22, in parseFile
File "d:#soft\engineering\3d_printing\Yet_Another_GcodeViewer\yagv\gcodeParser.py", line 45, in parseLine
getattr(self, "parse
File "d:#soft\engineering\3d_printing\Yet_Another_Gcode_Viewer\yagv\gcodeParser.py", line 62, in parse_G0
self.G1(args, "G0")
AttributeError: GcodeParser instance has no attribute 'G1'

This is nice in its current state as an easy to launch G-code viewer that doesn't require a browser. I've packaged it for Debian, so it's now apt-get installable in both Debian Unstable and Ubuntu Utopic.

this is really good!

Thanks for sharing this program! I just posted an issue on github but I want to post it here too: I love the design of this program and want to contribute, especially to add support for relative positioning (as I have to use this since I have some issues with absolute pos.) Maybe there are other features I can add in the future (I don't see a "move view" feature but maybe I just didn't see it), please let me know if you're still interested in improving this program.

Thanks for your interest :)
You did well to comment, looks like I don't get automatic notifications for new issues.

Contributions are very welcome indeed :)

Relative positioning support would be nice, it should indeed be quite simple. I haven't started on it myself yet.

I have done some improvement on model centering, but haven't released it -- guess I should ;)
I do plan on model moving, but haven't gotten anywhere with that yet. Maybe I (we) need to borrow the (slightly complex) dynamics from Meshlab?

This is the error message(s), using OS X 10.8:

/Users/Reuben/programming/yagv/$ ./yagvTraceback (most recent call last):  File "./yagv", line 12, in <module>    from http://pyglet.glpyglet.gl import *  File "build/bdist.macosx-10.8-intel/egg/pyglet/gl/http://__init__.py__init__.py", line 510, in <module>  File "build/bdist.macosx-10.8-intel/egg/pyglet/window/http://__init__.py__init__.py", line 1669, in <module>  File "build/bdist.macosx-10.8-intel/egg/pyglet/window/carbon/http://__init__.py__init__.py", line 69, in <module>  File "build/bdist.macosx-10.8-intel/egg/pyglet/http://lib.pylib.py", line 90, in load_library  File "build/bdist.macosx-10.8-intel/egg/pyglet/http://lib.pylib.py", line 226, in load_framework  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/http://__init__.py__init__.py", line 431, in LoadLibrary    return self._dlltype(name)  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/http://__init__.py__init__.py", line 353, in init    self._handle = _dlopen(self._name, mode)OSError: dlopen(/System/Library/Frameworks/QuickTime.framework/QuickTime, 6): no suitable image found.  Did find: /System/Library/Frameworks/QuickTime.framework/QuickTime: mach-o, but wrong architecture /System/Library/Frameworks/QuickTime.framework/QuickTime: mach-o, but wrong architecture</module></module></module></module>

Very nice. Works on OS X 10.8 after running: export VERSIONER_PYTHON_PREFER_32_BIT=yes in the terminal.

Great job! I'm looking forward to seeing how your project progresses.

Thanks for the feedback!
What error were you getting before adding this command variable?

WOW. This is awesome!
The fastest, most usable and prettiest stand-alone GCODE viewer I tried so far. I really think you should contact Alessandro from Slic3r to see if he is interested to integrate your work into the Slic3r GUI... Some kind of integrated GCODE visualisation to inspect the code after slicing whould be quite cool, i think..
And please keep up the development - it's worth it :-)

Thanks, glad you like it!
Full integration with Slic3r would not be easy, as it uses a different programming language, but a 'launch yagv' button would be possible.
Integration with Printrun Pronterface would be easier since it is also written in python.

I shall see what I can do :)

How to install this Viewer in the first place?

i got Readme file(not very helping) with a .md ending...
http://gcodeParser.pygcodeParser.py and yagv file.....
and the data folder with gcode.

what has to move where? on a Mac...?!?
how to tell yagv where it should get pyglet and python?

double click the yagv.. nothing happens
i get the ImportError: No module named pyglet

the only thing i maybe can run is the gcode-parser who will start xcode...

Looks like I need to make more user-friendly instructions :)

As of v0.3:
yagv does not need installing, it can be run directly from its decompressed folder.

You will however need to install pyglet manually. Python is probably already installed on Mac & Linux.
Once installed, python & pyglet should need no configuration.

To run yagv, open a terminal in the yagv folder, and run "yagv path/to/your/file.gcode"; or just "yagv", whch will load the demo file.
To just run yagv on the demo file, you can also just double click on yagv (as you did).

If you're getting "ImportError: No module named pyglet", it would seem that pyglet isn't installed properly, but python is.
I expect you downloaded "pyglet-1.1.4.dmg" from here: http://pyglet.org/download.htmlhttp://pyglet.org/download.htm... ; did you then install it by opening the dmg file and running the mpkg installer?


Not familiar with python how would I launch this on windows?

Once python and pyglet are installed, open a terminal(console)
Use 'cd' to navigate into the yagv folder (where yagv, http://README.mdREADME.md etc. are)
Then run: python yagv "full path to your .gcode file"

Please let me know by Private Message via my profile if you can't get it to work.

I'll try and get something done so you can drag and drop .gcode files straight onto an icon or something in the future.