Custom Gcode line in Cura 4.0 ?

Share your configuration profile, please specify your printer model and the slicer software.
Post Reply
GAQ
Posts: 101
Joined: Mon Jan 08, 2018 9:10 pm
Location: Manchester UK
Contact:

Custom Gcode line in Cura 4.0 ?

Post by GAQ » Fri May 24, 2019 2:19 am

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

User avatar
William
Site Admin
Posts: 6340
Joined: Tue Jun 07, 2016 9:38 am

Re: Custom Gcode line in Cura 4.0 ?

Post by William » Fri May 24, 2019 6:42 pm

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)
-Keep your mind and try to test it. :)
-Everything will be fun!-Support all Getech printer.
-You can ask me the questions and I will kindly reply.
-Respect others is the best way you can get help!

GAQ
Posts: 101
Joined: Mon Jan 08, 2018 9:10 pm
Location: Manchester UK
Contact:

Re: Custom Gcode line in Cura 4.0 ?

Post by GAQ » Sat May 25, 2019 8:54 am

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

User avatar
_kaktus_
Site Admin
Posts: 1260
Joined: Fri Dec 15, 2017 10:06 pm
Location: PL
Contact:

Re: Custom Gcode line in Cura 4.0 ?

Post by _kaktus_ » Sun Jun 02, 2019 2:24 pm

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
On the forum I help to use the rod, I don't give fish.
Geeetech Prusa I3 M201 Dual extruder Mixcolor 3D printer, bought 2017-12-19, already built, in the cognitive and improvement phase
Geeetech filament, ABS only
Geeetech 3D WiFi Module for 3D Printer, bought 2018-04-15, He got a new life, and still lies in a drawer.
Positively frenzied customer of Getech Technology.

GAQ
Posts: 101
Joined: Mon Jan 08, 2018 9:10 pm
Location: Manchester UK
Contact:

Re: Custom Gcode line in Cura 4.0 ?

Post by GAQ » Sun Jun 02, 2019 9:16 pm

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

User avatar
_kaktus_
Site Admin
Posts: 1260
Joined: Fri Dec 15, 2017 10:06 pm
Location: PL
Contact:

Re: Custom Gcode line in Cura 4.0 ?

Post by _kaktus_ » Mon Jun 03, 2019 3:10 am

:D
On the forum I help to use the rod, I don't give fish.
Geeetech Prusa I3 M201 Dual extruder Mixcolor 3D printer, bought 2017-12-19, already built, in the cognitive and improvement phase
Geeetech filament, ABS only
Geeetech 3D WiFi Module for 3D Printer, bought 2018-04-15, He got a new life, and still lies in a drawer.
Positively frenzied customer of Getech Technology.

Post Reply