New --before-layer-change option and new layer_z placeholder. #2602

This commit is contained in:
Alessandro Ranellucci 2015-01-30 20:08:00 +01:00
parent 2d3fdf920b
commit 059b00a829
6 changed files with 33 additions and 6 deletions

View File

@ -219,7 +219,8 @@ The author of the Silk icon set is Mark James.
--end-gcode Load final G-code from the supplied file. This will overwrite --end-gcode Load final G-code from the supplied file. This will overwrite
the default commands (turn off temperature [M104 S0], the default commands (turn off temperature [M104 S0],
home X axis [G28 X], disable motors [M84]). home X axis [G28 X], disable motors [M84]).
--layer-gcode Load layer-change G-code from the supplied file (default: nothing). --before-layer-gcode Load before-layer-change G-code from the supplied file (default: nothing).
--layer-gcode Load after-layer-change G-code from the supplied file (default: nothing).
--toolchange-gcode Load tool-change G-code from the supplied file (default: nothing). --toolchange-gcode Load tool-change G-code from the supplied file (default: nothing).
--seam-position Position of loop starting points (random/nearest/aligned, default: aligned). --seam-position Position of loop starting points (random/nearest/aligned, default: aligned).
--external-perimeters-first Reverse perimeter order. (default: no) --external-perimeters-first Reverse perimeter order. (default: no)

View File

@ -945,7 +945,7 @@ sub build {
octoprint_host octoprint_apikey octoprint_host octoprint_apikey
use_firmware_retraction pressure_advance vibration_limit use_firmware_retraction pressure_advance vibration_limit
use_volumetric_e use_volumetric_e
start_gcode end_gcode layer_gcode toolchange_gcode start_gcode end_gcode before_layer_gcode layer_gcode toolchange_gcode
nozzle_diameter extruder_offset nozzle_diameter extruder_offset
retract_length retract_lift retract_speed retract_restart_extra retract_before_travel retract_layer_change wipe retract_length retract_lift retract_speed retract_restart_extra retract_before_travel retract_layer_change wipe
retract_length_toolchange retract_restart_extra_toolchange retract_length_toolchange retract_restart_extra_toolchange
@ -1110,7 +1110,16 @@ sub build {
$optgroup->append_single_option_line($option); $optgroup->append_single_option_line($option);
} }
{ {
my $optgroup = $page->new_optgroup('Layer change G-code', my $optgroup = $page->new_optgroup('Before layer change G-code',
label_width => 0,
);
my $option = $optgroup->get_option('before_layer_gcode');
$option->full_width(1);
$option->height(150);
$optgroup->append_single_option_line($option);
}
{
my $optgroup = $page->new_optgroup('After layer change G-code',
label_width => 0, label_width => 0,
); );
my $option = $optgroup->get_option('layer_gcode'); my $option = $optgroup->get_option('layer_gcode');

View File

@ -318,9 +318,14 @@ sub process_layer {
} }
# set new layer - this will change Z and force a retraction if retract_layer_change is enabled # set new layer - this will change Z and force a retraction if retract_layer_change is enabled
$gcode .= $self->_gcodegen->placeholder_parser->process($self->print->config->before_layer_gcode, {
layer_num => $layer->id,
layer_z => $layer->print_z,
}) . "\n" if $self->print->config->before_layer_gcode;
$gcode .= $self->_gcodegen->change_layer($layer); $gcode .= $self->_gcodegen->change_layer($layer);
$gcode .= $self->_gcodegen->placeholder_parser->process($self->print->config->layer_gcode, { $gcode .= $self->_gcodegen->placeholder_parser->process($self->print->config->layer_gcode, {
layer_num => $layer->id, layer_num => $layer->id,
layer_z => $layer->print_z,
}) . "\n" if $self->print->config->layer_gcode; }) . "\n" if $self->print->config->layer_gcode;
# extrude skirt # extrude skirt

View File

@ -371,6 +371,7 @@ $j
--end-gcode Load final G-code from the supplied file. This will overwrite --end-gcode Load final G-code from the supplied file. This will overwrite
the default commands (turn off temperature [M104 S0], the default commands (turn off temperature [M104 S0],
home X axis [G28 X], disable motors [M84]). home X axis [G28 X], disable motors [M84]).
--before-layer-gcode Load before-layer-change G-code from the supplied file (default: nothing).
--layer-gcode Load layer-change G-code from the supplied file (default: nothing). --layer-gcode Load layer-change G-code from the supplied file (default: nothing).
--toolchange-gcode Load tool-change G-code from the supplied file (default: nothing). --toolchange-gcode Load tool-change G-code from the supplied file (default: nothing).
--seam-position Position of loop starting points (random/nearest/aligned, default: $config->{seam_position}). --seam-position Position of loop starting points (random/nearest/aligned, default: $config->{seam_position}).

View File

@ -22,6 +22,14 @@ PrintConfigDef::build_def() {
Options["bed_temperature"].min = 0; Options["bed_temperature"].min = 0;
Options["bed_temperature"].max = 300; Options["bed_temperature"].max = 300;
Options["before_layer_gcode"].type = coString;
Options["before_layer_gcode"].label = "Before layer change G-code";
Options["before_layer_gcode"].tooltip = "This custom code is inserted at every layer change, right before the Z move. Note that you can use placeholder variables for all Slic3r settings as well as [layer_num] and [layer_z].";
Options["before_layer_gcode"].cli = "before-layer-gcode=s";
Options["before_layer_gcode"].multiline = true;
Options["before_layer_gcode"].full_width = true;
Options["before_layer_gcode"].height = 50;
Options["bottom_solid_layers"].type = coInt; Options["bottom_solid_layers"].type = coInt;
Options["bottom_solid_layers"].label = "Bottom"; Options["bottom_solid_layers"].label = "Bottom";
Options["bottom_solid_layers"].category = "Layers and Perimeters"; Options["bottom_solid_layers"].category = "Layers and Perimeters";
@ -438,9 +446,9 @@ PrintConfigDef::build_def() {
Options["interface_shells"].category = "Layers and Perimeters"; Options["interface_shells"].category = "Layers and Perimeters";
Options["layer_gcode"].type = coString; Options["layer_gcode"].type = coString;
Options["layer_gcode"].label = "Layer change G-code"; Options["layer_gcode"].label = "After layer change G-code";
Options["layer_gcode"].tooltip = "This custom code is inserted at every layer change, right after the Z move and before the extruder moves to the first layer point. Note that you can use placeholder variables for all Slic3r settings."; Options["layer_gcode"].tooltip = "This custom code is inserted at every layer change, right after the Z move and before the extruder moves to the first layer point. Note that you can use placeholder variables for all Slic3r settings as well as [layer_num] and [layer_z].";
Options["layer_gcode"].cli = "layer-gcode=s"; Options["layer_gcode"].cli = "after-layer-gcode|layer-gcode=s";
Options["layer_gcode"].multiline = true; Options["layer_gcode"].multiline = true;
Options["layer_gcode"].full_width = true; Options["layer_gcode"].full_width = true;
Options["layer_gcode"].height = 50; Options["layer_gcode"].height = 50;

View File

@ -324,6 +324,7 @@ class PrintRegionConfig : public virtual StaticPrintConfig
class GCodeConfig : public virtual StaticPrintConfig class GCodeConfig : public virtual StaticPrintConfig
{ {
public: public:
ConfigOptionString before_layer_gcode;
ConfigOptionString end_gcode; ConfigOptionString end_gcode;
ConfigOptionString extrusion_axis; ConfigOptionString extrusion_axis;
ConfigOptionFloats extrusion_multiplier; ConfigOptionFloats extrusion_multiplier;
@ -346,6 +347,7 @@ class GCodeConfig : public virtual StaticPrintConfig
ConfigOptionBool use_volumetric_e; ConfigOptionBool use_volumetric_e;
GCodeConfig() : StaticPrintConfig() { GCodeConfig() : StaticPrintConfig() {
this->before_layer_gcode.value = "";
this->end_gcode.value = "M104 S0 ; turn off temperature\nG28 X0 ; home X axis\nM84 ; disable motors\n"; this->end_gcode.value = "M104 S0 ; turn off temperature\nG28 X0 ; home X axis\nM84 ; disable motors\n";
this->extrusion_axis.value = "E"; this->extrusion_axis.value = "E";
this->extrusion_multiplier.values.resize(1); this->extrusion_multiplier.values.resize(1);
@ -377,6 +379,7 @@ class GCodeConfig : public virtual StaticPrintConfig
}; };
ConfigOption* option(const t_config_option_key opt_key, bool create = false) { ConfigOption* option(const t_config_option_key opt_key, bool create = false) {
if (opt_key == "before_layer_gcode") return &this->before_layer_gcode;
if (opt_key == "end_gcode") return &this->end_gcode; if (opt_key == "end_gcode") return &this->end_gcode;
if (opt_key == "extrusion_axis") return &this->extrusion_axis; if (opt_key == "extrusion_axis") return &this->extrusion_axis;
if (opt_key == "extrusion_multiplier") return &this->extrusion_multiplier; if (opt_key == "extrusion_multiplier") return &this->extrusion_multiplier;