Welcome! Log In Create A New Profile

Advanced

Experimental G Code Blender

Posted by wd5gnr 
Experimental G Code Blender
January 12, 2013 02:23AM
Inspired by the reference in Slicer is Nicer about printing different layers from different Slicer outputs, I have put a GPL experimental gcode blender on github:

[github.com]

I just posted this -- consider it maybe even pre beta.

The idea is from the "Slicer is nicer" series where the author talks about mixing different sliced files. So printing a statue, you might print the base at 0.4mm layers with 33% infill and the top part at 0.1 with no infill at all.

I am very interested to see if anyone has success with this method. If there is demand, I may produce binaries and/or a Qt GUI front end for Linux/Windows/etc.

Here's the README:
What is Gblend?

Gblend allows you to take multiple gcode filies and merge then into a single file, taking layers from each file and joining them.

There are several 3D printing use cases for this:

1) You can slice an object using multiple settings and then take slices from each setting and merge them. For example, you might slice a statue so that the bottom layers are solid and low resolution while the top is at a finer resolution and hollow.

2) You can remove one or more slices of a print.

3) You can merge multiple files together to print them as one, although current slicing software will do a better job of this for you.

4) You can mix different objects. For example, you might blend a base and an object.

5) You can break a file at a layer and insert code such as a filament change.

Note that Gblend does not manipulate coordinates, so any translation of objects (for example, in #3 and #4 above) has to be done in the original source file.

Suppose you have a statue that is 50mm high. The first 26mm is a base and the rest is the body of the statue. You might want to print the base at 0.5mm with 40% honeycomb infill. However, the body might benefit from .1mm layers with 0% infill. These instructions assume you will start with an STL file that describes the model and use a slicing program such as slic3r.

In your slicer configuration, it is helpful, although perhaps not absolutely necessary, to add a special comment to the "preamble" and "post" G-code. That is, the slicer's configuration usually has a way for you to set some G code that is sent before printing and after printing. You often use this to home the head, set calibration parameters, etc. You should place copies of these codes in separate files (for example, start.gcode and end.gcode). You can leave the code in your slicer setup, but add a comment at the end of the start code:

; %%%GBLEND_START

Also add one at the start of the end code:

; %%%GBLEND_END

Now slice the model multiple times using the settings you want. Be sure to save each slicing operation t
o a separate file. I might create two files for the statue: statue_solid.gcode and statue_hollow.gcode.
Gblend can merge these files to create one gcode file that has the desired print.

gblend = start.gcode [ statue_solid.gcode 26.4 status_hollow.gcode ] = end.gcode >status-print.gcode

Interpreting this command line in English it says: copy (=) start.gcode to the output. Then take statue_solid.gcode and copy from the start of the actual print ([) up to (but not including) 26.4mm. Then starting at 26.4mm, copy to the end of the print (]) to status_hollow.gcode and finally copy (=) end.gcode totally.

You can use the following flags for the start:
[ - Start of printable object (after %%%GBLEND_START)
[5.2 - Start at 5.2mm
5.2 - Start at 5.2mm (same as [5.2)

Normally, the start of the next file determines the end of the previous file. If you want to specify a specific stop, you can use a close bracket. For example:

[20.0 foo.gcode 21.0]
will cause Gblend to copy the layers from 20.0mm up to and including 21.00mm. Without the bracket it would not copy the 21.00mm layer since that would be the start of the next file. If you use an explicit end, you will probably want to specify the next file's start as well:

[20.0 foo.gcode 21.0] 21.4 bar.gcode ]

If there is no next file or if you specify ] by itself (like bar.gcode in the above example) gblend copies to the end of the file.

Any time gblend is looking for the start or end of a file, it only looks in between the %%%GBLEND_START and %%%GBLEND_END comments. You can stop that behavior using -S and -E, respectively. You can also specify different tags using -s or -e. The only exception is the = tag which reads the entire file from beginning to end without searching for the tags. Gblend ignores a semicolon at the start of a tag so:

; %%%GBLEND_START

and

;%%%GBLEND_START

will both work. If you specify your own tag, it can not contain any spaces, tabs, or newlines. That is, "%%%GBLEND START" is not a legal tag because it has a space in it.
Re: Experimental G Code Blender
January 12, 2013 04:41PM
Seeing how most people in RepRap use absolute extrusion distance does this account for that and insert a G92 E to set the extrusion distance to the last discarded?

For those of use that use Relative extrusion this is never an issue and will work for sure.

If you ever decide to upgrade to Cura this would make a great plugin for the plugin feature.


FFF Settings Calculator Gcode post processors Geometric Object Deposition Tool Blog
Tantillus.org Mini Printable Lathe How NOT to install a Pololu driver
Re: Experimental G Code Blender
January 12, 2013 04:49PM
I use absolute extrusion distances and that's why I mention on the issues that you can't just cut a slice out of something--but I guess with relative coordinates you could. The program as of today is pretty simple, it just grabs layers. So say I have file1, file2, and file3 -- presumably the same object but sliced differently--I can take the first 5mm from file1, 5mm - 25mm from file2 and 25mm to the top from file3 (or whatever).

I have used Cura and that's an idea. What I would wish for is programs like Slic3r could have an advanced setting where you could tell a list of settings to apply at different layer heights.
Re: Experimental G Code Blender
January 22, 2013 02:22AM
I am very interested in this. Only problem is I don't know programming, and I don't know Linux very well.

Would very much appreciate a Windows version!
Re: Experimental G Code Blender
January 22, 2013 11:32PM
Ok, the bin directory now has prebuilt binaries for amd64, i386, and Windows. Windows very lightly tested and no assurance any of the executables will actually work ;-)
Re: Experimental G Code Blender
February 01, 2013 06:20AM
Hello wd5gnr, nice script!

Work is being done to allow different settings for different regions in a single slicing job... so many things in my todo list, but I want it so badly winking smiley
rocky
Re: Experimental G Code Blender
March 27, 2013 02:37AM
You are on to something very powerful...would love to be involved!!
Please keep me informed. Let me know if I can test code or write code.
Sorry, only registered users may post in this forum.

Click here to login