Conditional gcode to disable power recovery when printing in vase/spiralize mode

What is the problem?

I use Cura slicer which does not support conditional statements (if this then else etc) in the start/end gcode. Specifically I want to turn off the power recovery feature when printing in spiralize mode. So I was wondering if I could do it via Octoprint start gcode script.

What did you already try to solve it?

I know the machine tag in Cura for spiralize (magic_spiralize) and I can resolve that to true or false if I reference it in the Cura start gcode code. And I know the command I want to send for when its true (M413 S0) or false (M413 S1). As cura does not allow simple conditional statements like other slicers can therefore Octoprint start gcode support it. So I know I can write a conditional statement in the gcode scripts "before print" in Octoprint but how do I access the value of the magic_spiralize setting which is only contained at the end of the gcode file as shown below?

;End of Gcode
";SETTING_3 celeration_enabled = True\nmagic_spiralize = True\nretraction_combi

Ender 3 S1
Cura 4.13
OctoPrint 1.7.3
OctoPi 0.18.0

Hello @Carnaue !

OctoPrint does not know in what mode something is printed. This (in this case vase mode) is internal setting in the slicer.

If Cura does not support conditions, I'll suggest to setup a profile for vase mode that includes the disable power recovery gcode.


Thanks Ewald, I have done that and it works well enough. Its a pity Cura does not support conditional statements and conditions like Prusa slicer yet.

1 Like

Have been able to resolve this now with a few settings in Cura. In Cura you can identify if you have spiralize/vase mode active by referring to the variable {magic_spiralize}. So if you want to disable power loss recovery when printing in vase mode you can insert M413 S{magic_spiralize} in your machine start gcode. This will parse to M413 STrue if vase mode is active or M413 SFalse if vase mode is not active. Then you need to use a Cura post processing script to find/replace find M413 STrue and replace with M413 S0 (this disables power loss recovery) and find M413 SFalse and replace with M413 S1 (enables power loss recovery). Nice tidy solution fully automated.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.