A more efficient G-Code viewer for large files

I've been experimenting with a new G-Code viewer, with the goal of removing the rather low limit on the size of files the current viewer can handle. It seemed like an interesting and fun challenge to handle very large and complex G-Code files in the browser efficiently.

It's still a very rough prototype, but in general it can display very large G-Code files in the browser with pretty low memory usage. I haven't managed to slice a file I couldn't display so far, the largest one I successfully loaded in the browser was around 1 GB. Memory usage is typically around 40-60% of the G-Code file size.

You can try the G-Code viewer at the following address:

https://fabian-h.github.io/gcode-viewer/

or view the source at

It's open sourced under the Apache 2.0 license.

There is no progress bar or any feedback yet while loading, but it's quite fast and unless you load a very large file it should be finished in a few seconds. I got a bit sidetracked trying to make the parser fast, so while the viewer is seriously lacking in features, it makes up for that by being very fast in loading G-Code.

Right now this is a standalone project, but if I can get this working well enough it I'll take a look at whether it makes sense to create a library that can be integrated into Octoprint.

There are a lot of limitations right now, it only handles a subset of G-Code commands, but enough to display the stuff I've tried. I've tested it mostly with files slices by Slic3r PE so far. On Firefox you have to reload the page to load a new file if you have one loaded already, I didn't get the drag events right yet there. And you can only change the linewidth right now, I want to add more display parameters to this. Drawing is much faster on Firefox for some reason on my computer, I'm not yet sure if this is a general issue or not.

5 Likes

Really nice, and works very smooth. Nice and simple interface. Once you do get to a point, you should definitely look at integrating it within the OctoPrint gcode viewer viewModel. Any plans on supporting 3D view?

I've thought about a 3D view, and I actually have some experience in using WebGL for 2D stuff. But that area is rather complex and difficult to work with, you're close to the hardware and you never get any meaningful errors, at best you get just a black screen if you make a mistake. I'll probably try that at some point, but I'm not sure I'll succeed.

Cool, just a thought. I created a plugin that enables the 3d view in octoprint using its gcode.ws implementation. It's not great but does allow you to look at the object from upgraded gcode files.

Cool :slight_smile:
Can I switch between 3D and standard view when I use your plugin?

Yeah, it adds a 3D button to the gcode viewer tab that you toggle on/off. It's not very pretty, and it doesn't go along with print progress, etc. but does show the gcode as a 3d object.

1 Like

what a shame I hoped for a 3D progress :smiley:
But still thanks for the plugin - I'll test it soon :slight_smile:

1 Like

I am really sad that my Bresser Saurus/FlashForge Finder cant use OctoPrint fully. I would like that have that G-Code viewer (real time) line follower working in my Printers, but it doesnt.

Is this an alternative? And to get it connected to my OctoPrint?

SSL errors? Is this project still alive fabian?

Hello @Oxize !

Do you print from the printer's SD card?

Yes, i have an Bresser Saurus (FlashForge Finder) which doesnt fully support OctoPrint yet. I though this was a sort of alternative.

If i knew this earlier, i would buy an other printer, which can actually fully works with OctoPrint. Waiting on MRNT (Flashforge Plugin Maker) will be endless and i dont have hope for that.

If you print from the printer's SD card, OctoPrint has no control or knowledge about what is happening on the printer.

You only get the gcode viewers graphics when you print from OctoPrint.

This is the way with every printer.

I know, like i said. FlashForge Plugin is half build into OctoPrint. The controls works, the webcams works, the plugin works, the Gcode viewer isnt.

When i push an Object directly through Octoprint, my printer doesnt know what to do. Mrnt on Github was bussy with that, but i geuss this is all we get for now. No direct implementation into OctoPrint.

Either i have to buy an other printer which is fully compatible with OctoPrint. And Octoprints compat list isnt really update lately.

Then I would recommend to open a new thread Get Help with all the required information that are asked for in the template.

Which template?

I even sended Mrnt to help with testing things.

When you open a new thread in get help, there is already something written.
On the right side of the edit window you find blue words. These are links to find the required information

Sorry where?

Do you think its worth to put my Bresser Saurus in there since i know already Mnrt on Github doesnt can do much anymore?

It's worth a try

Something like this?