Add a "between extrusion role" gcode input window, to let insert gcode inside a layer and not only at the begin and the end.

#108
This commit is contained in:
supermerill 2019-10-29 17:49:29 +01:00
parent 51bcae96ea
commit 1bf0b1c1d7
6 changed files with 70 additions and 2 deletions

View File

@ -2909,6 +2909,15 @@ std::string GCode::_before_extrude(const ExtrusionPath &path, const std::string
double F = speed * 60; // convert mm/sec to mm/min
// extrude arc or line
if (path.role() != m_last_extrusion_role) {
DynamicConfig config;
config.set_key_value("extrusion_role", new ConfigOptionString(extrusion_role_to_string_for_parser(path.role())));
config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index + 1));
config.set_key_value("layer_z", new ConfigOptionFloat(m_config.z_offset.value));
gcode += this->placeholder_parser_process("feature_gcode",
m_config.feature_gcode.value, m_writer.extruder()->id(), &config)
+ "\n";
}
if (m_enable_extrusion_role_markers) {
if (path.role() != m_last_extrusion_role) {
char buf[32];
@ -3266,4 +3275,40 @@ void GCode::ObjectByExtruder::Island::Region::append(const std::string& type, co
perimeters_or_infills_overrides->push_back(copies_extruder);
}
std::string
GCode::extrusion_role_to_string_for_parser(const ExtrusionRole & role) {
switch (role) {
case erPerimeter:
return "Perimeter";
case erExternalPerimeter:
return "ExternalPerimeter";
case erOverhangPerimeter:
return "OverhangPerimeter";
case erInternalInfill:
return "InternalInfill";
case erSolidInfill:
return "SolidInfill";
case erTopSolidInfill:
return "TopSolidInfill";
case erBridgeInfill:
return "BridgeInfill";
case erGapFill:
return "GapFill";
case erSkirt:
return "Skirt";
case erSupportMaterial:
return "SupportMaterial";
case erSupportMaterialInterface:
return "SupportMaterialInterface";
case erWipeTower:
return "WipeTower";
case erCustom:
case erMixed:
case erCount:
case erNone:
default:
return "Mixed";
}
}
} // namespace Slic3r

View File

@ -182,6 +182,7 @@ public:
// inside the generated string and after the G-code export finishes.
std::string placeholder_parser_process(const std::string &name, const std::string &templ, unsigned int current_extruder_id, const DynamicConfig *config_override = nullptr);
bool enable_cooling_markers() const { return m_enable_cooling_markers; }
std::string extrusion_role_to_string_for_parser(const ExtrusionRole &);
// For Perl bindings, to be used exclusively by unit tests.
unsigned int layer_count() const { return m_layer_count; }

View File

@ -1477,8 +1477,8 @@ void PrintConfigDef::init_fff_params()
def = this->add("layer_gcode", coString);
def->label = L("After layer change G-code");
def->tooltip = L("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].");
"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].");
def->cli = "after-layer-gcode|layer-gcode";
def->multiline = true;
def->full_width = true;
@ -1486,6 +1486,19 @@ void PrintConfigDef::init_fff_params()
def->mode = comExpert;
def->set_default_value(new ConfigOptionString(""));
def = this->add("feature_gcode", coString);
def->label = L("After layer change G-code");
def->tooltip = L("This custom code is inserted at every extrusion type change."
"Note that you can use placeholder variables for all Slic3r settings as well as [extrusion_role], [layer_num] and [layer_z] that can take these string values:"
" { Perimeter, ExternalPerimeter, OverhangPerimeter, InternalInfill, SolidInfill, TopSolidInfill, BridgeInfill, GapFill, Skirt, SupportMaterial, SupportMaterialInterface, WipeTower, Mixed }."
" Mixed is only used when the role of the extrusion is not unique, not exactly inside an other category or not known.");
def->cli = "feature-gcode";
def->multiline = true;
def->full_width = true;
def->height = 5;
def->mode = comExpert;
def->set_default_value(new ConfigOptionString(""));
def = this->add("exact_last_layer_height", coBool);
def->label = L("Exact last layer height");
def->category = L("Layers and Perimeters");

View File

@ -799,6 +799,7 @@ public:
ConfigOptionEnum<GCodeFlavor> gcode_flavor;
ConfigOptionBool gcode_label_objects;
ConfigOptionString layer_gcode;
ConfigOptionString feature_gcode;
ConfigOptionFloat max_print_speed;
ConfigOptionFloat max_volumetric_speed;
#ifdef HAS_PRESSURE_EQUALIZER
@ -890,6 +891,7 @@ protected:
OPT_PTR(gcode_flavor);
OPT_PTR(gcode_label_objects);
OPT_PTR(layer_gcode);
OPT_PTR(feature_gcode);
OPT_PTR(max_print_speed);
OPT_PTR(max_volumetric_speed);
#ifdef HAS_PRESSURE_EQUALIZER

View File

@ -494,6 +494,7 @@ const std::vector<std::string>& Preset::printer_options()
"use_firmware_retraction", "use_volumetric_e", "variable_layer_height",
"host_type", "print_host", "printhost_apikey", "printhost_cafile",
"single_extruder_multi_material", "start_gcode", "end_gcode", "before_layer_gcode", "layer_gcode", "toolchange_gcode",
"feature_gcode",
"between_objects_gcode", "printer_vendor", "printer_model", "printer_variant", "printer_notes", "cooling_tube_retraction",
"cooling_tube_length", "high_current_on_filament_swap", "parking_pos_retraction", "extra_loading_move", "max_print_height",
"default_print_profile", "inherits",

View File

@ -2074,6 +2074,12 @@ void TabPrinter::build_fff()
option.opt.full_width = true;
option.opt.height = gcode_field_height;//150;
optgroup->append_single_option_line(option);
optgroup = page->new_optgroup(_(L("Between extrusion role change G-code")), 0);
option = optgroup->get_option("feature_gcode");
option.opt.full_width = true;
option.opt.height = gcode_field_height;//150;
optgroup->append_single_option_line(option);
page = add_options_page(_(L("Notes")), "note.png");
optgroup = page->new_optgroup(_(L("Notes")), 0);