Welcome! Log In Create A New Profile

Advanced

Slic3r G-code [layer_num] help

Posted by tripstar76 
Slic3r G-code [layer_num] help
March 18, 2015 07:50PM
I'm wondering if someone could give an example of the [layer_num] variable in the custom g-code, layer change g-code?
I'm struggling how I could, say, change the extruder temp to 180 at layer 7 for example, and maybe change it again a few layers later?


Thanks, John.
Re: Slic3r G-code [layer_num] help
March 24, 2015 02:20PM
Ok, well lets say your first layer is 0.4mm thick, then each layer after that is 0.2mm thick. Your first layer would be in the gcode as G1 Z0.400 F5000 (or some other value for F). Layer two would be G1 Z0.600, etc. So, with our theoretical thicknesses here, if we wanted to find layer 7 in the gcode we'd search for "Z1.6", and to add an extruder temp change to 180 we'd add the line "M104 S180". Doesn't matter which line the temperature code is on, you can put it in anywhere.
Re: Slic3r G-code [layer_num] help
March 24, 2015 11:04PM
To do what you're wanting to do directly in Slic3r you'd need the ability to perform math and/or use conditional statements on the Slic3r environment variables, and I've not found any documentation suggesting either is currently possible.

What you can do is add a commented line to the layer-change G-code to make it easier to find and modify after the fact, either for a post-processing script or manual text-editing...something along the lines of:

; Start of Layer [layer_num]!

Note, based on my experimentation with it, [layer_num] is zero-indexed, so to find the beginning of the seventh layer you would want to search for "Layer 6!"

I put the exclamation point in so it will only find Layer 6, not Layer 60 or 61 or 62, or so forth. If high-level environment variable math is ever implemented, exclamation point might mean factorial, so you might have to change it to keep your layer numbers from being 1, 1, 2, 6, 24, 120, and so forth.
Sorry, only registered users may post in this forum.

Click here to login