Page 1 of 1

Custom Gcode line in Cura 4.0 ?

Posted: Fri May 24, 2019 2:19 am
by GAQ
Hi all,

I've been playing around swapping between Slic3r and Cura.
I have Cura 4.0, I have several flavours of Slic3r available, the most commonly used being Slic3r PE as supplied via Josef Prusa.

I have a question regarding some custom gcode placed at the end of a run...
I quite like this line I use in Slic3r

"...
{if layer_z < max_print_height}G1 Z{z_offset+min(layer_z+10, max_print_height)}{endif} ; Move print head up 10mm
..."

Now at the end of a print, Slicer knows the current height of the head on the Z axis and inserts a relevant bit of code here...
Say the print ends at a height of 46.7mm, then when Slic3r produces the gcode for the printer, then using this line it would insert
- G1 Z56.7 ; Move print head up 10mm -
Fantastic, the head moves up 10mm, the next line in my custom gcode for the end of the run moves the bed forwards to allow easy removal of the component...
Every different component with a different ending height automatically gets the correct Z movement code to lift the head by 10mm.

Now this doesn't work in Cura 4.0
Naturally, the variables will be different and Cura doesn't recognise these as numbers it can use.

Question is...

Does anyone out there know a similar line of code that will work in Cura ???

Hopes,

Gerry

Re: Custom Gcode line in Cura 4.0 ?

Posted: Fri May 24, 2019 6:42 pm
by William
Hi, If you want to test the z-axis height and auto-level, you can use G30 (Z-axis single point test); G31 (output Z-axis height test micro switch status)

Re: Custom Gcode line in Cura 4.0 ?

Posted: Sat May 25, 2019 8:54 am
by GAQ
Hi William,

Thanks for the reply...

What I'm actually after is the ability to AUTOMATICALLY (So it's the same for every component) Lift the nozzle up at the end of printing by a fixed amount...
Now I'll look at the gcodes you've suggested, but the Slic3r working code I quoted works by Slic3r having the internal variables, knowing where the Z height is currently situated and then being able to add 10 to this figure, then producing the "G1 Z-whatever-this-turns-out-to-be" line correctly no matter what the component is.
This is great as it avoids silly mistakes when for instance you print a component that's 45mm high... you have an end gcode with the line...
G1 Z55, and it works fine... Right until you print a component that's 90mm high and forget to change the ending gcode !!!
The nozzle tries to smash through your long awaited print !
The Slic3r code line I quoted is the same for EVERY component.
It looks up the current height and adds 10mm.
It outputs the gcode to the output file as a direct G1 statement... (Please check and see just how well this works.)

I'm not trying to test the z axis height, nor auto level... ??? !
I'm looking for an ending gcode that automatically lifts the nozzle 10mm higher than the component in Cura...
WITHOUT knowing the height and coding manually in notepad every time as I'm doing now.

Gerry

Re: Custom Gcode line in Cura 4.0 ?

Posted: Sun Jun 02, 2019 2:24 pm
by _kaktus_
Hi.
:mrgreen:

And did you try any other way...
Maybe the G91 command will pass the exam in this case :?:

G91: Set to Relative Positioning

Re: Custom Gcode line in Cura 4.0 ?

Posted: Sun Jun 02, 2019 9:16 pm
by GAQ
Hi Kaktus,

I did indeed end up using the G91 command as you suggest...
My end code for Cura 4.1 currently reads...

Code: Select all

G92 E0
G91 ; set to relative positioning
G1 E-5 F300 ; retract the filament a bit before lifting the nozzle to release some of the pressure
G1 Z5 ; raise Z 5mm from current position
G90 ; set to absolute positioning
G1 F1000 ; re-set travel speed from 300
G1 X20 Y180 F3000 ; home X axis and push Y forward
M104 S0 ; turn off extruder
M140 S0 ; turn off heatbed
M106 S0 ; turn off fan
M84 ; disable motors
M82 ;absolute extrusion mode
I just note that I've introduced an extra F value - I put the 1st one in to combat the slow speed following the F300 retraction.

This code seems to work fine.
Naturally, this doesn't check for the max height being reached, but the machine won't go above this anyway.
(And I'm never operating so high - or at least haven't to date.)

Gerry

Re: Custom Gcode line in Cura 4.0 ?

Posted: Mon Jun 03, 2019 3:10 am
by _kaktus_
:D