Simple gcode files produce error: "The selected file: does not contain valid gcode"
 
Notifications
Clear all

[Solved] Simple gcode files produce error: "The selected file: does not contain valid gcode"  

  RSS
Brandon
(@brandon-4)
Active Member
Simple gcode files produce error: "The selected file: does not contain valid gcode"

I've been fiddling around with my own custom gcode. I wanted to validate whether I've written something valid for the MK3s with PrusaSlicer, but it seems to get very mad at me, even when the gcode does almost nothing. For example, I created a gcode file like this:

G28 W ; Home
G21 ; Set units to mm
G90 ; Set absolute positioning

M2 ; end program
M84 ; disable motors

And when I opened it with PrusaSlicer, I got this error:

PrusaSlicer G-code Viewer - Error while loading .gcode file

The selected file /Users/me/empty.gcode does not contain valid gcode.

Any idea what I'm doing wrong? Does PrusaSlicer get mad because the file doesn't do any extrusion?

Posted : 04/09/2021 10:33 pm
Brandon
(@brandon-4)
Active Member
Topic starter answered:
Figured it out

Answering my own question, I found the relevant bit in the source code:

if (p->preview->get_canvas3d()->get_gcode_layers_zs().empty()) {
     MessageDialog(this, _L(
          "The selected file") + ":\n" + filename + "\n" + _L("does not contain valid gcode.")..)
}

So, if I'm reading this right, any gcode file that doesn't extrude anything is considered invalid gcode.

Posted : 05/09/2021 6:39 am
bobstro liked
Neil
 Neil
(@neil-2)
Active Member
RE: Simple gcode files produce error: "The selected file: does not contain valid gcode"

Reopening the wound discussion 🙂

Just wondering if you managed to work around this? I've been wanting to make a pen plotter mod. I wanted to start with some real basics and manually craft the gcode to do some really basic operations, but I'm struggling to create anything that the printer will accept.

Obviously for such a project there's no extrusion or heat and only movement of the three axes.

I tried just with a simple axis move instruction which didn't work, so I assumed there's some additional pre and post steps required.
Editing a file generated by prusa slicer didn't work either.

Any ideas what the minimal gcode would be to complete a single axis move operation (that can then be developed on)?

Posted : 11/01/2022 9:01 am
Brandon
(@brandon-4)
Active Member
Topic starter answered:
RE: Simple gcode files produce error: "The selected file: does not contain valid gcode"

The good news is that I did get my Prusa plotting!

.

The bad news is that I had to give up on PrusaSlicer. As far as I can tell, if you don't extrude anything, PrusaSlicer always rejects the gcode as invalid. I ended up using a vector drawing program with a laser cutter extension, then throwing in standard mk3s starting / ending gcode.

One option might be to ask PrusaSlicer to make a single layer print and then go through the gcode and replace all of the "turn on/off extruder" lines with "raise/lower z axis" lines, but I didn't try it.

Posted : 11/01/2022 6:05 pm
Brandon
(@brandon-4)
Active Member
Topic starter answered:
RE: Simple gcode files produce error: "The selected file: does not contain valid gcode"

The critical bit of gcode is making sure that the file ends with an "M84 ; disable motors" instruction. The mk3s is pretty generous with the gcode it reads, but if the file doesn't end with M84, it assumes that the file is invalid.

I had to fiddle around with the gcode header quite a bit, but the gist of it was that I used the standard stuff that PrusaSlicer does by default, except I removed all the lines about bed temperature and the extruder, I added a line raising the Z axis high enough to keep it away from the pen, and I removed the "W" from "G28 W" because bed leveling is not your friend when there's a big pen taped to the extruder (lost a few pens that way).

Posted : 11/01/2022 6:15 pm
Neil liked
Share: