Post processing script to change M204 S"number" to ACC S"number" R"number*0.5"
February 19, 2019 01:30PM
I'm trying to make a post processing script so that I can send retardation set points to my printer... with no luck..

So I need some help, would anyone be able to make this type of script for Slic3r

In the gcode

M204 Snnnn
nnnn is a number 0-10000

And this is how I would like it

ACC Snnnn R¤¤¤¤¤

nnnn is the same as above and ¤¤¤¤¤ is nnnn*x x would be 0.5 for the most part but easily altered in the script file


My setup
Ubuntu
Slic3r PE
Klipper

Python or Perl if I'm correct

Edited 1 time(s). Last edit at 02/19/2019 01:31PM by Nitram.
Why not just open the file in a text editor and do a find-and-replace?


Son of MegaMax 3D printer: [www.instructables.com]
Ultra MegaMax Dominator 3D printer: [drmrehorst.blogspot.com]
Re: Post processing script to change M204 S"number" to ACC S"number" R"number*0.5"
February 19, 2019 02:34PM
I don't know whether you can do that in slic3r, but you could use a simple sed script to do it.



Large delta printer [miscsolutions.wordpress.com], Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Post processing script to change M204 S"number" to ACC S"number" R"number*0.5"
February 19, 2019 02:43PM
@digi dentist

I have done it by "hand" find and replace,

but I would like a more permanent solution

@dc42

sure it's there [manual.slic3r.org]

and sed is as any other thing with programming.... I don't get it to work..
Re: Post processing script to change M204 S"number" to ACC S"number" R"number*0.5"
February 21, 2019 02:13AM
create a script with the file extension .pl containing the following

#!/usr/bin/perl -i                                                     
use strict;
use warnings;

while (<>) {

    if (/^M204(\h+S(-?\d*\.?\d+))?/) {
	my $S=$2; 
        my $R=$S*0.5;
        $_ = "ACC S$S R$R\n";
    }

    print;
}

make sure to make the file executable with chmod +x

since this edits the file passed to it testing it is tricky, if you don't actually want to modify the file
I used $ cat input.gcode | ./post.pl > out.gcode
If you omit the "> out.gcode" it will output to the console.
NB the warning "-i used with no filenames on the command line, reading from STDIN." is normal for testing.

Edited 3 time(s). Last edit at 02/21/2019 02:44AM by Dust.
Re: Post processing script to change M204 S"number" to ACC S"number" R"number*0.5"
February 21, 2019 06:20AM
I will test it when I get home...

Thank You so much....

I noticed an error of mine


it need to be
ACC S=xxx R=yyyy

#!/usr/bin/perl -i                                                     
use strict;
use warnings;

while (<>) {

    if (/^M204(\h+S(-?\d*\.?\d+))?/) {
	my $S=$2; 
        my $R=$S*0.5;
        $_ = "ACC S=$S R=$R\n";
    }

    print;
}

Once again thanks
Re: Post processing script to change M204 S"number" to ACC S"number" R"number*0.5"
February 21, 2019 11:29AM
work like a charm
Sorry, only registered users may post in this forum.

Click here to login