From 3e94add8a824e341b83eddcda277be55f7000c64 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 9 Jun 2012 17:52:03 +0200 Subject: [PATCH] Pass config options as environment variables to post-processing scripts --- lib/Slic3r/Config.pm | 10 ++++++++++ lib/Slic3r/Print.pm | 1 + 2 files changed, 11 insertions(+) diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index aa645b99d..5c3529caf 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -528,6 +528,16 @@ sub save { close $fh; } +sub setenv { + my $class = shift; + foreach my $opt (sort keys %$Options) { + next if $Options->{$opt}{gui_only}; + my $value = get($opt); + $value = $Options->{$opt}{serialize}->($value) if $Options->{$opt}{serialize}; + $ENV{"SLIC3R_" . uc $opt} = $value; + } +} + sub load { my $class = shift; my ($file) = @_; diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 7bf490c56..2c9948ce1 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -311,6 +311,7 @@ sub export_gcode { # run post-processing scripts if (@$Slic3r::post_process) { $status_cb->(95, "Running post-processing scripts"); + Slic3r::Config->setenv; for (@$Slic3r::post_process) { Slic3r::debugf " '%s' '%s'\n", $_, $output_file; system($_, $output_file);