Hello.
Does anyone know of a way to change the G-Code of a print in bambulab?
I don’t need to add code between layers, but rather I need to change the order in which something is printed in a single layer.
Regards, Danio.
Hello.
Does anyone know of a way to change the G-Code of a print in bambulab?
I don’t need to add code between layers, but rather I need to change the order in which something is printed in a single layer.
Regards, Danio.
Unfortunately I don’t think it’s doable.
On bambu lab studio you can only modified the outputted gcode through the slicer setting. Or via a script but I have the feeling what you want to modify is very specific and can’t be really automated
Hey, thanks for your answer.
It would be enough to insert a small slice of g-code (that I already made) into the middle of a layer, is that possible?
For that you can just open the gcode file on a text/code editor (notepad, text editor(Mac), visual studio code,… ) and copy past the lines you want to add. The hardest part is to find where to add them.
What kind of gcode commands do you want to add?
I just want to make sure that the ironing flow doesn’t continue into a part of the print, so I want to either move the last movement of a layer to its beginning or stop, extrude and wipe after the ironing part.
I understand what you’re saying, it’s almost like a post processor software used for CNC machining but isn’t when it comes to edits.
CNC machines you’ll use say masterCAM and create toolpaths make a part then [Post] to a machine which uses a seperate application that generates the post but it’s created in a [notepad] type setting. So you’ll be able to make edits then save and post to the machine.
Slicers are bypassing that but simply taking the model > slicing [posting] > Bambu Cloud [Machine network] > machine download.
or SD Card then machine, although you’re able to see the code no edits can be made since it’s not wrote outside the software and printers don’t have that amount of hardware to handle processes like that (i dont think)
The gcode is very verbose, plenty of comments, so an ordinary text editor can get you to the correct layer fairly quickly. In the slicer, when sliced, if you right-click the slider at the rhs, you can add gcode at the beginning of a layer, maybe a comment as a row of ##### which may give an easier way of finding a layer when editing the code.
You cant alter individual gcode such as the arcs, linear moves, or feed/speed rates. This is why there’s only sections you can add code to that’s implemented to the “sliced” code but you cannot perform manual edit changes to sliced code, I’ve only ever sent gcode text to a machine using [Pronterface]. Still only able to send commands, not copy - pasting a whole sliced program…
Thanks a ton for your answers.
Using debonr’s trick is a great timesaver.
Thanks for clarifying Henlor and ProtoSpyre, I will try a different method.
Contrary to what people have said it is possible to alter G-Code post slicing and run it on the printer. I warn you that editing the gcode will be done at your own risk as you can really mess up your printer if you don’t know what you are doing.
Edit - See my post further down.
You might want to investigate using a modifier as this is a pretty powerful tool in Bambu Studio.
From what you saying it might be doable to do this with the slicer settings.
Here is a list of things I’d tried.
Yes its possible to write a python script to take the exported plate sliced file, unzip each component file, edit the gcode, zip each element back up into another plate sliced file.
You can then load this back into Bambu Studio, preview the altered gcode, and then sent it to the printer.
I’ve for example used this method to strip out the prime tower from the gcode. I know you can turn it off - but that also disables most ‘flush-into’ stuff too.
This is where I have gotten stuck. I had always assumed it was because my modified gcode didn’t match the the old md5 file. But I don’t think this is entirely the problem because if I re-zip an unziped 3mf file and rename it (.zip to .3mf) I can’t recreate the original 3mf.
Any pointers?
I haven’t had any success with Bambu Studio accepting files that I have manually zipped by compressing them on a Mac on I think using a ZIP command, but for me it works every time if you use python.
I use the python ZipFile add-in to unzip directly from the 3mf file and back to an updated file. I haven’t made any manual edits to the files - they have all been done with python too.
I generally iterate through every subfile - zipping the ones I am not interested straight back up, and altering the ones I want to change - using for example xml.etree.ElementTree for the XML files
I didn’t do any special compressing of the output zip files - so they are generally much larger than the input files.
If I ever get the hang of GITHUB I will publish a few of my scripts at some point.
EUREKA!
I never thought to try only editing the gcode file inside of the archived package.
Using 7-Zip (Windows)
Navigate to the Metadata folder and right click on the .gcode file. Select “Edit” and it will open the file in a text editor.
Make your gcode edit and close the file. It will ask you if you want to save the changes. Click “Save”
7-Zip will ask if you want to update the archive. Select “OK”
That’s it.
You can open the .gcode.3mf file in Bambu Studio to preview your changes.
As you can see here I simply added an additional move on X on the second layer.
Brilliant!
Sorry for the late response, and thanks a million for your answer!
Hey, I’ve just got around to testing it, but I cannot find a gcode file inside of the 3mf file. is there a specific way to save it?
This will create a FILENAME.gcode.3mf file
In this file,