mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 19:15:54 +08:00
add start_gcode_manual to disable automatic 'start gcode' output
supermerill/SuperSlicer#875
This commit is contained in:
parent
18aae45347
commit
99b3121425
@ -41,6 +41,8 @@ group:Advanced
|
|||||||
setting:variable_layer_height
|
setting:variable_layer_height
|
||||||
|
|
||||||
page:Custom G-code:cog
|
page:Custom G-code:cog
|
||||||
|
group:
|
||||||
|
setting:start_gcode_manual
|
||||||
height:15
|
height:15
|
||||||
group:nolabel:Start G-code
|
group:nolabel:Start G-code
|
||||||
setting:full_width:start_gcode
|
setting:full_width:start_gcode
|
||||||
|
@ -1323,14 +1323,15 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu
|
|||||||
|
|
||||||
std::string start_gcode = this->placeholder_parser_process("start_gcode", print.config().start_gcode.value, initial_extruder_id);
|
std::string start_gcode = this->placeholder_parser_process("start_gcode", print.config().start_gcode.value, initial_extruder_id);
|
||||||
// Set bed temperature if the start G-code does not contain any bed temp control G-codes.
|
// Set bed temperature if the start G-code does not contain any bed temp control G-codes.
|
||||||
if(this->config().gcode_flavor != gcfKlipper && print.config().first_layer_bed_temperature.get_at(initial_extruder_id) != 0)
|
if( !this->config().start_gcode_manual && this->config().gcode_flavor != gcfKlipper && print.config().first_layer_bed_temperature.get_at(initial_extruder_id) != 0)
|
||||||
this->_print_first_layer_bed_temperature(file, print, start_gcode, initial_extruder_id, false);
|
this->_print_first_layer_bed_temperature(file, print, start_gcode, initial_extruder_id, false);
|
||||||
|
|
||||||
//init extruders
|
//init extruders
|
||||||
this->_init_multiextruders(file, print, m_writer, tool_ordering, start_gcode);
|
if (!this->config().start_gcode_manual)
|
||||||
|
this->_init_multiextruders(file, print, m_writer, tool_ordering, start_gcode);
|
||||||
|
|
||||||
// Set extruder(s) temperature before and after start G-code.
|
// Set extruder(s) temperature before and after start G-code.
|
||||||
if ((this->config().gcode_flavor != gcfKlipper || print.config().start_gcode.value.empty()) && print.config().first_layer_temperature.get_at(initial_extruder_id) != 0)
|
if (!this->config().start_gcode_manual && (this->config().gcode_flavor != gcfKlipper || print.config().start_gcode.value.empty()) && print.config().first_layer_temperature.get_at(initial_extruder_id) != 0)
|
||||||
this->_print_first_layer_extruder_temperatures(file, print, start_gcode, initial_extruder_id, false);
|
this->_print_first_layer_extruder_temperatures(file, print, start_gcode, initial_extruder_id, false);
|
||||||
|
|
||||||
// adds tag for processor
|
// adds tag for processor
|
||||||
@ -1350,7 +1351,7 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Disable fan.
|
// Disable fan.
|
||||||
if (print.config().disable_fan_first_layers.get_at(initial_extruder_id))
|
if (!this->config().start_gcode_manual && print.config().disable_fan_first_layers.get_at(initial_extruder_id))
|
||||||
_write(file, m_writer.set_fan(0, true, initial_extruder_id));
|
_write(file, m_writer.set_fan(0, true, initial_extruder_id));
|
||||||
//ensure fan is at the right speed
|
//ensure fan is at the right speed
|
||||||
|
|
||||||
@ -1367,52 +1368,57 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu
|
|||||||
m_seam_placer.init(print);
|
m_seam_placer.init(print);
|
||||||
|
|
||||||
//activate first extruder is multi-extruder and not in start-gcode
|
//activate first extruder is multi-extruder and not in start-gcode
|
||||||
if (m_writer.multiple_extruders) {
|
if (!this->config().start_gcode_manual) {
|
||||||
//if not in gcode
|
if (m_writer.multiple_extruders) {
|
||||||
bool find = false;
|
//if not in gcode
|
||||||
if (!start_gcode.empty()) {
|
bool find = false;
|
||||||
const char *ptr = start_gcode.data();
|
if (!start_gcode.empty()) {
|
||||||
while (*ptr != 0) {
|
const char* ptr = start_gcode.data();
|
||||||
// Skip whitespaces.
|
while (*ptr != 0) {
|
||||||
for (; *ptr == ' ' || *ptr == '\t'; ++ptr);
|
// Skip whitespaces.
|
||||||
if (*ptr == 'T') {
|
for (; *ptr == ' ' || *ptr == '\t'; ++ptr);
|
||||||
// TX for most of the firmwares
|
if (*ptr == 'T') {
|
||||||
find = true;
|
// TX for most of the firmwares
|
||||||
break;
|
|
||||||
} else if (*ptr == 'A' && print.config().gcode_flavor.value == gcfKlipper) {
|
|
||||||
// ACTIVATE_EXTRUDER for klipper (if used)
|
|
||||||
if (std::string::npos != start_gcode.find("ACTIVATE_EXTRUDER", size_t(ptr - start_gcode.data()))) {
|
|
||||||
find = true;
|
find = true;
|
||||||
break;
|
break;
|
||||||
|
} else if (*ptr == 'A' && print.config().gcode_flavor.value == gcfKlipper) {
|
||||||
|
// ACTIVATE_EXTRUDER for klipper (if used)
|
||||||
|
if (std::string::npos != start_gcode.find("ACTIVATE_EXTRUDER", size_t(ptr - start_gcode.data()))) {
|
||||||
|
find = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// Skip the rest of the line.
|
||||||
|
for (; *ptr != 0 && *ptr != '\r' && *ptr != '\n'; ++ptr);
|
||||||
|
// Skip the end of line indicators.
|
||||||
|
for (; *ptr == '\r' || *ptr == '\n'; ++ptr);
|
||||||
}
|
}
|
||||||
// Skip the rest of the line.
|
|
||||||
for (; *ptr != 0 && *ptr != '\r' && *ptr != '\n'; ++ptr);
|
|
||||||
// Skip the end of line indicators.
|
|
||||||
for (; *ptr == '\r' || *ptr == '\n'; ++ptr);
|
|
||||||
}
|
}
|
||||||
}
|
if (!find) {
|
||||||
if (!find) {
|
// Set initial extruder only after custom start G-code.
|
||||||
// Set initial extruder only after custom start G-code.
|
// Ugly hack: Do not set the initial extruder if the extruder is primed using the MMU priming towers at the edge of the print bed.
|
||||||
// Ugly hack: Do not set the initial extruder if the extruder is primed using the MMU priming towers at the edge of the print bed.
|
if (!(has_wipe_tower && print.config().single_extruder_multi_material_priming)) {
|
||||||
if (!(has_wipe_tower && print.config().single_extruder_multi_material_priming)) {
|
_write(file, this->set_extruder(initial_extruder_id, 0.));
|
||||||
_write(file, this->set_extruder(initial_extruder_id, 0.));
|
} else {
|
||||||
|
m_writer.toolchange(initial_extruder_id);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
m_writer.toolchange(initial_extruder_id);
|
// set writer to the tool as should be set in the start_gcode.
|
||||||
|
_write(file, this->set_extruder(initial_extruder_id, 0., true));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// set writer to the tool as should be set in the start_gcode.
|
// if we are running a single-extruder setup, just set the extruder and "return nothing"
|
||||||
_write(file, this->set_extruder(initial_extruder_id, 0., true));
|
_write(file, this->set_extruder(initial_extruder_id, 0.));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if we are running a single-extruder setup, just set the extruder and "return nothing"
|
// the right tool should have been set by the user.
|
||||||
_write(file, this->set_extruder(initial_extruder_id, 0.));
|
m_writer.toolchange(initial_extruder_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
//write temps after custom gcodes to ensure the temperature are good. (after tool selection)
|
//write temps after custom gcodes to ensure the temperature are good. (after tool selection)
|
||||||
if(print.config().first_layer_temperature.get_at(initial_extruder_id) != 0)
|
if (!this->config().start_gcode_manual && print.config().first_layer_temperature.get_at(initial_extruder_id) != 0)
|
||||||
this->_print_first_layer_extruder_temperatures(file, print, start_gcode, initial_extruder_id, true);
|
this->_print_first_layer_extruder_temperatures(file, print, start_gcode, initial_extruder_id, true);
|
||||||
if (print.config().first_layer_bed_temperature.get_at(initial_extruder_id) != 0)
|
if (!this->config().start_gcode_manual && print.config().first_layer_bed_temperature.get_at(initial_extruder_id) != 0)
|
||||||
this->_print_first_layer_bed_temperature(file, print, start_gcode, initial_extruder_id, true);
|
this->_print_first_layer_bed_temperature(file, print, start_gcode, initial_extruder_id, true);
|
||||||
|
|
||||||
// Do all objects for each layer.
|
// Do all objects for each layer.
|
||||||
@ -2699,7 +2705,10 @@ void GCode::set_origin(const Vec2d &pointf)
|
|||||||
|
|
||||||
std::string GCode::preamble()
|
std::string GCode::preamble()
|
||||||
{
|
{
|
||||||
std::string gcode = m_writer.preamble();
|
std::string gcode;
|
||||||
|
|
||||||
|
if (!this->config().start_gcode_manual)
|
||||||
|
gcode = m_writer.preamble();
|
||||||
|
|
||||||
/* Perform a *silent* move to z_offset: we need this to initialize the Z
|
/* Perform a *silent* move to z_offset: we need this to initialize the Z
|
||||||
position of our writer object so that any initial lift taking place
|
position of our writer object so that any initial lift taking place
|
||||||
|
@ -692,8 +692,13 @@ const std::vector<std::string>& Preset::printer_options()
|
|||||||
"min_length",
|
"min_length",
|
||||||
//FIXME the print host keys are left here just for conversion from the Printer preset to Physical Printer preset.
|
//FIXME the print host keys are left here just for conversion from the Printer preset to Physical Printer preset.
|
||||||
"host_type", "print_host", "printhost_apikey", "printhost_cafile", "printhost_port",
|
"host_type", "print_host", "printhost_apikey", "printhost_cafile", "printhost_port",
|
||||||
"single_extruder_multi_material", "start_gcode", "end_gcode", "before_layer_gcode", "layer_gcode", "toolchange_gcode",
|
"single_extruder_multi_material",
|
||||||
|
"start_gcode",
|
||||||
|
"start_gcode_manual",
|
||||||
|
"end_gcode",
|
||||||
|
"before_layer_gcode",
|
||||||
|
"layer_gcode",
|
||||||
|
"toolchange_gcode",
|
||||||
"color_change_gcode", "pause_print_gcode", "template_custom_gcode", "feature_gcode",
|
"color_change_gcode", "pause_print_gcode", "template_custom_gcode", "feature_gcode",
|
||||||
"between_objects_gcode", "printer_vendor", "printer_model", "printer_variant", "printer_notes", "cooling_tube_retraction",
|
"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",
|
"cooling_tube_length", "high_current_on_filament_swap", "parking_pos_retraction", "extra_loading_move", "max_print_height",
|
||||||
|
@ -164,6 +164,7 @@ bool Print::invalidate_state_by_config_options(const std::vector<t_config_option
|
|||||||
"slowdown_below_layer_time",
|
"slowdown_below_layer_time",
|
||||||
"standby_temperature_delta",
|
"standby_temperature_delta",
|
||||||
"start_gcode",
|
"start_gcode",
|
||||||
|
"start_gcode_manual",
|
||||||
"start_filament_gcode",
|
"start_filament_gcode",
|
||||||
"thin_walls_speed",
|
"thin_walls_speed",
|
||||||
"time_estimation_compensation",
|
"time_estimation_compensation",
|
||||||
|
@ -3462,19 +3462,27 @@ void PrintConfigDef::init_fff_params()
|
|||||||
def->label = L("Start G-code");
|
def->label = L("Start G-code");
|
||||||
def->category = OptionCategory::customgcode;
|
def->category = OptionCategory::customgcode;
|
||||||
def->tooltip = L("This start procedure is inserted at the beginning, after bed has reached "
|
def->tooltip = L("This start procedure is inserted at the beginning, after bed has reached "
|
||||||
"the target temperature and extruder just started heating, and before extruder "
|
"the target temperature and extruder just started heating, and before extruder "
|
||||||
"has finished heating. If Slic3r detects M104 or M190 in your custom codes, "
|
"has finished heating. If Slic3r detects M104 or M190 in your custom codes, "
|
||||||
"such commands will not be prepended automatically so you're free to customize "
|
"such commands will not be prepended automatically so you're free to customize "
|
||||||
"the order of heating commands and other custom actions. Note that you can use "
|
"the order of heating commands and other custom actions. Note that you can use "
|
||||||
"placeholder variables for all Slic3r settings, so you can put "
|
"placeholder variables for all Slic3r settings, so you can put "
|
||||||
"a \"M109 S[first_layer_temperature]\" command wherever you want."
|
"a \"M109 S[first_layer_temperature]\" command wherever you want."
|
||||||
"\n placeholders: initial_extruder, total_layer_count, has_wipe_tower, has_single_extruder_multi_material_priming, total_toolchanges, bounding_box[minx,miny,maxx,maxy]");
|
"\n placeholders: initial_extruder, total_layer_count, has_wipe_tower, has_single_extruder_multi_material_priming, total_toolchanges, bounding_box[minx,miny,maxx,maxy]");
|
||||||
def->multiline = true;
|
def->multiline = true;
|
||||||
def->full_width = true;
|
def->full_width = true;
|
||||||
def->height = 12;
|
def->height = 12;
|
||||||
def->mode = comExpert;
|
def->mode = comExpert;
|
||||||
def->set_default_value(new ConfigOptionString("G28 ; home all axes\nG1 Z5 F5000 ; lift nozzle\n"));
|
def->set_default_value(new ConfigOptionString("G28 ; home all axes\nG1 Z5 F5000 ; lift nozzle\n"));
|
||||||
|
|
||||||
|
def = this->add("start_gcode_manual", coBool);
|
||||||
|
def->label = L("Only custom Start G-code");
|
||||||
|
def->category = OptionCategory::customgcode;
|
||||||
|
def->tooltip = L("Ensure that the slicer won't add heating, fan, extruder... commands before or just after your start-gcode."
|
||||||
|
"If set to true, you have to write a good and complete start_gcode, as no checks are made anymore.");
|
||||||
|
def->mode = comExpert;
|
||||||
|
def->set_default_value(new ConfigOptionBool(false));
|
||||||
|
|
||||||
def = this->add("start_filament_gcode", coStrings);
|
def = this->add("start_filament_gcode", coStrings);
|
||||||
def->label = L("Start G-code");
|
def->label = L("Start G-code");
|
||||||
def->full_label = ("Filament start G-code");
|
def->full_label = ("Filament start G-code");
|
||||||
@ -5437,7 +5445,8 @@ void PrintConfigDef::to_prusa(t_config_option_key& opt_key, std::string& value,
|
|||||||
"external_perimeter_extrusion_spacing",
|
"external_perimeter_extrusion_spacing",
|
||||||
"infill_extrusion_spacing",
|
"infill_extrusion_spacing",
|
||||||
"solid_infill_extrusion_spacing",
|
"solid_infill_extrusion_spacing",
|
||||||
"top_infill_extrusion_spacing"
|
"top_infill_extrusion_spacing",
|
||||||
|
"start_gcode_manual",
|
||||||
|
|
||||||
};
|
};
|
||||||
//looks if it's to be removed, or have to be transformed
|
//looks if it's to be removed, or have to be transformed
|
||||||
|
@ -1089,6 +1089,7 @@ public:
|
|||||||
ConfigOptionFloats retract_speed;
|
ConfigOptionFloats retract_speed;
|
||||||
ConfigOptionStrings start_filament_gcode;
|
ConfigOptionStrings start_filament_gcode;
|
||||||
ConfigOptionString start_gcode;
|
ConfigOptionString start_gcode;
|
||||||
|
ConfigOptionBool start_gcode_manual;
|
||||||
ConfigOptionBool single_extruder_multi_material;
|
ConfigOptionBool single_extruder_multi_material;
|
||||||
ConfigOptionBool single_extruder_multi_material_priming;
|
ConfigOptionBool single_extruder_multi_material_priming;
|
||||||
ConfigOptionBool wipe_tower_no_sparse_layers;
|
ConfigOptionBool wipe_tower_no_sparse_layers;
|
||||||
@ -1202,6 +1203,7 @@ protected:
|
|||||||
OPT_PTR(single_extruder_multi_material_priming);
|
OPT_PTR(single_extruder_multi_material_priming);
|
||||||
OPT_PTR(wipe_tower_no_sparse_layers);
|
OPT_PTR(wipe_tower_no_sparse_layers);
|
||||||
OPT_PTR(start_gcode);
|
OPT_PTR(start_gcode);
|
||||||
|
OPT_PTR(start_gcode_manual);
|
||||||
OPT_PTR(start_filament_gcode);
|
OPT_PTR(start_filament_gcode);
|
||||||
OPT_PTR(tool_name);
|
OPT_PTR(tool_name);
|
||||||
OPT_PTR(toolchange_gcode);
|
OPT_PTR(toolchange_gcode);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user