Cura: Adding M42 gcode to layer 2 on every slice?

Created on 6 Apr 2018  路  16Comments  路  Source: Ultimaker/Cura

This is not a bug. I just don't know where else to turn to.
I want to add an M42 P6 S255 to the start of layer 2 on every file I slice with cura.
How can I do that?
There is a place for start and end gcodes, but nothing in between.
I know there must be a way, but after a few hours, I give up.
Thanks for any help.

Cura Question

Most helpful comment

You can do this with the search and replace post-processing script. I have tested this and it works. There's something broken with entering text in Cura at the moment so it tends to forget what you have just entered into a field.

screenshot_2018-04-06_07-34-47

All 16 comments

You can do this with the search and replace post-processing script. I have tested this and it works. There's something broken with entering text in Cura at the moment so it tends to forget what you have just entered into a field.

screenshot_2018-04-06_07-34-47

Note that the Search in @smartavionics' example will only detect the first layer change. I would use this instead:

Search:
;LAYER:
Replace:
M42 P6 S255\n;LAYER:

That way it works on all layers and it keeps the layer number comments intact.

Hi Aldo, the OP asks for the M42 to be output on the start of layer 2 not on all layers after layer 1 which is why I explicitly match that layer number. I agree that my solution leaves out the layer:1 comment.

Doh, better brush up on my reading skills...

BTW, I tried using ;LAYER:1$ as the search string but it didn't seem to understand $. Is that right?

The string that is being matched is the whole layer, consisting of multiple lines. "$" matches the end of the string, not the end of a line.

Ah, thanks, that makes sense.

omg, Thank you. Works like a charm!

It works, but as you said, it forgets!
Is there any way to fix the code?
As it is, it would be no different from opening the gcode in Notepad++ and doing a search and replace manually! Wanted to avoid doing that for each and every file I slice.

In Cura 3.3, the setting will persist between launches of Cura. In the Cura 3.3 beta there is currently a bug that will make the setting not "take" unless you type it in very slowly.

Where do I get the 3.3? I found 3.3 Beta, but not 3.3!

3.3 isn't released yet.

me so sad :(

I downloaded the 3.3 Beta for shits and giggles, and also out of desperation. I typed it slow, and now it remembers, and is no longer suffering from amnesia !! Yey
Do you happen to know which python source is responsible for this function?

The amnesia problem is in Uranium, the commit that fixes it is:

https://github.com/Ultimaker/Uranium/commit/7b53e35fcb7f28ca4cda43a79102f5bfee44106d

Dude! u d man.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DamianSepczuk picture DamianSepczuk  路  3Comments

ferociousdiablo picture ferociousdiablo  路  3Comments

jellewie picture jellewie  路  3Comments

timherrm picture timherrm  路  3Comments

Liger0 picture Liger0  路  3Comments