Slic3r post processing script August 07, 2014 03:05PM |
Registered: 10 years ago Posts: 6,409 |
Re: Slic3r post processing script August 07, 2014 03:35PM |
Moderator Registered: 12 years ago Posts: 964 |
Re: Slic3r post processing script August 07, 2014 05:01PM |
Registered: 10 years ago Posts: 6,409 |
#!C:/perl/bin/perl -i use strict; use warnings; $^I = '.bak'; print "Hello World\n";
#!C:/perl/bin/perl -i use strict; use warnings; $^I = '.bak'; my $z = 0; # read stdin and any/all files passed as parameters one line at a time while (<> ) { # if we find a Z word, save it $z = $1 if /Z\s*(\d+(\.\d+)?)/; # if we don't have Z, but we do have X and Y if (!/Z/ && /X/ && /Y/ && $z > 0) { # chop off the end of the line (incl. comments), saving chopped section in $1 s/\s*([\r\n\;\(].*)/" Z$z $1"/es; # print start of line, insert our Z value then re-add the chopped end of line # print "$_ Z$z $1"; } #else { # nothing interesting, print line as-is print or die $!; #} }
Re: Slic3r post processing script August 07, 2014 05:16PM |
Moderator Registered: 12 years ago Posts: 964 |
Re: Slic3r post processing script August 07, 2014 05:22PM |
Registered: 10 years ago Posts: 6,409 |
Re: Slic3r post processing script August 07, 2014 05:33PM |
Moderator Registered: 12 years ago Posts: 964 |
Re: Slic3r post processing script August 08, 2014 03:19AM |
Registered: 10 years ago Posts: 6,409 |
use strict; use warnings; print "Prova di scrittura file"; open OUTPUT, ">d:/output.txt"; print OUTPUT "Questa è una prova\n"; close OUTPUT;
Re: Slic3r post processing script August 08, 2014 03:31AM |
Moderator Registered: 12 years ago Posts: 964 |
use strict; use warnings; use utf8;
Re: Slic3r post processing script August 09, 2014 02:04PM |
Registered: 10 years ago Posts: 6,409 |
Re: Slic3r post processing script [RISOLTO] August 13, 2014 07:40AM |
Registered: 10 years ago Posts: 6,409 |
#!/usr/bin/perl -i use strict; use warnings; use English '-no_match_vars'; use File::Temp qw/ tempfile /; use File::Copy qw/ move /; my $file_in = 'D:\Stampanti 3D\Setup\RepetierHost\composition.gcode'; my ($file_out_h, $file_out_name) = tempfile() or die( "Non è possibile aprire il file temporaneo!" ); my $x = 0; my $y = 0; my $xmin = 999999; my $xmax = 0; my $ymin = 999999; my $ymax = 0; open FILE1, $file_in; while ( < FILE1 > ) { #Cerca il comando G1 Xxx Yyy nel gcode e memorizza i valori xx e yy if (/^G1 X ( [ 0-9.]+) Y([0-9.]+)/) { $x = $1; $y = $2; if ($x < $xmin) {$xmin = $x;} if ($x > $xmax) {$xmax = $x;} if ($y < $ymin) {$ymin = $y;} if ($y > $ymax) {$ymax = $y;} } } close FILE1; open FILE1, $file_in; while ( < FILE1 > ) { if (/^G29/) { print $file_out_h "G29 L$xmin F$ymin R$xmax B$ymax ;autobed level at L(XMIN) F(YMIN) R(XMAX) B(YMAX)\n"; }else{ print $file_out_h $_; } } close FILE1; close $file_out_h; move( $file_out_name, $file_in );
Re: Slic3r post processing script [RISOLTO] August 13, 2014 04:11PM |
Moderator Registered: 12 years ago Posts: 964 |