mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-09 07:56:24 -06:00
Enable absolute/relative extrusion option on non BBL printers (#205)
Add the option to use non-relative extrusion in printer config screen. Some extruders do not play well with relative extrusion... Remove reference to multi-extruder Remove reference to multi-extruder change g-code comment for M83 relative extrusion changed comment for M83 Remove commented line of code In this specific case, we delete the old line of code because it refers to a variable that was deleted from the rest of the code (RELATIVE_E_AXIS)
This commit is contained in:
parent
594c22cde0
commit
5692e02c54
13 changed files with 43 additions and 30 deletions
|
@ -22,7 +22,7 @@ double Extruder::extrude(double dE)
|
|||
{
|
||||
// BBS
|
||||
if (m_share_extruder) {
|
||||
if (RELATIVE_E_AXIS)
|
||||
if (m_config->use_relative_e_distances)
|
||||
m_share_E = 0.;
|
||||
m_share_E += dE;
|
||||
m_absolute_E += dE;
|
||||
|
@ -30,7 +30,7 @@ double Extruder::extrude(double dE)
|
|||
m_share_retracted -= dE;
|
||||
} else {
|
||||
// in case of relative E distances we always reset to 0 before any output
|
||||
if (RELATIVE_E_AXIS)
|
||||
if (m_config->use_relative_e_distances)
|
||||
m_E = 0.;
|
||||
m_E += dE;
|
||||
m_absolute_E += dE;
|
||||
|
@ -51,7 +51,7 @@ double Extruder::retract(double length, double restart_extra)
|
|||
{
|
||||
// BBS
|
||||
if (m_share_extruder) {
|
||||
if (RELATIVE_E_AXIS)
|
||||
if (m_config->use_relative_e_distances)
|
||||
m_share_E = 0.;
|
||||
double to_retract = std::max(0., length - m_share_retracted);
|
||||
if (to_retract > 0.) {
|
||||
|
@ -63,7 +63,7 @@ double Extruder::retract(double length, double restart_extra)
|
|||
return to_retract;
|
||||
} else {
|
||||
// in case of relative E distances we always reset to 0 before any output
|
||||
if (RELATIVE_E_AXIS)
|
||||
if (m_config->use_relative_e_distances)
|
||||
m_E = 0.;
|
||||
double to_retract = std::max(0., length - m_retracted);
|
||||
if (to_retract > 0.) {
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
double retract(double length, double restart_extra);
|
||||
double unretract();
|
||||
double E() const { return m_share_extruder ? m_share_E : m_E; }
|
||||
void reset_E() { m_E = 0.; }
|
||||
void reset_E() { m_E = 0.; m_share_E = 0.; }
|
||||
double e_per_mm(double mm3_per_mm) const { return mm3_per_mm * m_e_per_mm3; }
|
||||
double e_per_mm3() const { return m_e_per_mm3; }
|
||||
// Used filament volume in mm^3.
|
||||
|
@ -66,7 +66,7 @@ private:
|
|||
GCodeConfig *m_config;
|
||||
// Print-wide global ID of this extruder.
|
||||
unsigned int m_id;
|
||||
// Current state of the extruder axis, may be resetted if relative_e_axis.
|
||||
// Current state of the extruder axis, may be resetted if use_relative_e_distances.
|
||||
double m_E;
|
||||
// Current state of the extruder tachometer, used to output the extruded_volume() and used_filament() statistics.
|
||||
double m_absolute_E;
|
||||
|
|
|
@ -355,7 +355,6 @@ bool GCode::gcode_label_objects = true;
|
|||
new_filament_e_feedrate = new_filament_e_feedrate == 0 ? 100 : new_filament_e_feedrate;
|
||||
|
||||
config.set_key_value("max_layer_z", new ConfigOptionFloat(gcodegen.m_max_layer_z));
|
||||
config.set_key_value("relative_e_axis", new ConfigOptionBool(RELATIVE_E_AXIS));
|
||||
config.set_key_value("toolchange_count", new ConfigOptionInt((int)gcodegen.m_toolchange_count));
|
||||
//BBS: fan speed is useless placeholer now, but we don't remove it to avoid
|
||||
//slicing error in old change_filament_gcode in old 3MF
|
||||
|
@ -1632,7 +1631,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
|||
std::function<void(void)> throw_if_canceled_func = [&print]() { print.throw_if_canceled(); };
|
||||
m_seam_placer.init(print, throw_if_canceled_func);
|
||||
|
||||
// BBS: priming logic is removed, always set first extruer here.
|
||||
// BBS: priming logic is removed, always set first extruder here.
|
||||
//if (! (has_wipe_tower && print.config().single_extruder_multi_material_priming))
|
||||
{
|
||||
// Set initial extruder only after custom start G-code.
|
||||
|
@ -3066,8 +3065,11 @@ GCode::LayerResult GCode::process_layer(
|
|||
m_object_layer_over_raft = object_layer_over_raft;
|
||||
if (m_config.reduce_crossing_wall)
|
||||
m_avoid_crossing_perimeters.init_layer(*m_layer);
|
||||
if (GCode::gcode_label_objects)
|
||||
if (GCode::gcode_label_objects) {
|
||||
gcode += std::string("; printing object ") + instance_to_print.print_object.model_object()->name + " id:" + std::to_string(instance_to_print.layer_id) + " copy " + std::to_string(instance_to_print.instance_id) + "\n";
|
||||
if (!m_config.use_relative_e_distances)
|
||||
gcode += m_writer.reset_e(true);
|
||||
}
|
||||
// When starting a new object, use the external motion planner for the first travel move.
|
||||
const Point &offset = instance_to_print.print_object.instances()[instance_to_print.instance_id].shift;
|
||||
std::pair<const PrintObject*, Point> this_object_copy(&instance_to_print.print_object, offset);
|
||||
|
@ -3158,8 +3160,11 @@ GCode::LayerResult GCode::process_layer(
|
|||
// ironing
|
||||
gcode += this->extrude_infill(print,by_region_specific, true);
|
||||
}
|
||||
if (GCode::gcode_label_objects)
|
||||
if (GCode::gcode_label_objects) {
|
||||
gcode += std::string("; stop printing object ") + instance_to_print.print_object.model_object()->name + " id:" + std::to_string(instance_to_print.layer_id) + " copy " + std::to_string(instance_to_print.instance_id) + "\n";
|
||||
if (!m_config.use_relative_e_distances)
|
||||
gcode += m_writer.reset_e(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4213,7 +4218,6 @@ std::string GCode::set_extruder(unsigned int extruder_id, double print_z)
|
|||
dyn_config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index));
|
||||
dyn_config.set_key_value("layer_z", new ConfigOptionFloat(print_z));
|
||||
dyn_config.set_key_value("max_layer_z", new ConfigOptionFloat(m_max_layer_z));
|
||||
dyn_config.set_key_value("relative_e_axis", new ConfigOptionBool(RELATIVE_E_AXIS));
|
||||
dyn_config.set_key_value("toolchange_count", new ConfigOptionInt((int)m_toolchange_count));
|
||||
//BBS: fan speed is useless placeholer now, but we don't remove it to avoid
|
||||
//slicing error in old change_filament_gcode in old 3MF
|
||||
|
|
|
@ -401,7 +401,7 @@ std::vector<PerExtruderAdjustments> CoolingBuffer::parse_layer_gcode(const std::
|
|||
}
|
||||
if ((line.type & CoolingLine::TYPE_G92) == 0) {
|
||||
//BBS: G0, G1, G2, G3. Calculate the duration.
|
||||
if (RELATIVE_E_AXIS)
|
||||
if (m_config.use_relative_e_distances.value)
|
||||
// Reset extruder accumulator.
|
||||
current_pos[3] = 0.f;
|
||||
float dif[4];
|
||||
|
|
|
@ -54,7 +54,7 @@ std::string SpiralVase::process_layer(const std::string &gcode)
|
|||
// For absolute extruder distances it will be switched off.
|
||||
// Tapering the absolute extruder distances requires to process every extrusion value after the first transition
|
||||
// layer.
|
||||
bool transition = m_transition_layer && RELATIVE_E_AXIS;
|
||||
bool transition = m_transition_layer && m_config.use_relative_e_distances;
|
||||
float layer_height_factor = layer_height / total_layer_length;
|
||||
float len = 0.f;
|
||||
m_reader.parse_buffer(gcode, [&new_gcode, &z, total_layer_length, layer_height_factor, transition, &len]
|
||||
|
|
|
@ -82,7 +82,7 @@ const char* GCodeReader::parse_line_internal(const char *ptr, const char *end, G
|
|||
}
|
||||
}
|
||||
|
||||
if (gline.has(E) && RELATIVE_E_AXIS)
|
||||
if (gline.has(E) && m_config.use_relative_e_distances)
|
||||
m_position[E] = 0;
|
||||
|
||||
// Skip the rest of the line.
|
||||
|
|
|
@ -61,11 +61,9 @@ std::string GCodeWriter::preamble()
|
|||
FLAVOR_IS(gcfSmoothie) ||
|
||||
FLAVOR_IS(gcfKlipper))
|
||||
{
|
||||
if (RELATIVE_E_AXIS) {
|
||||
gcode << "M83 ; only support relative e\n";
|
||||
if (this->config.use_relative_e_distances) {
|
||||
gcode << "M83 ; use relative distances for extrusion\n";
|
||||
} else {
|
||||
//BBS: don't support absolute e distance
|
||||
assert(0);
|
||||
gcode << "M82 ; use absolute distances for extrusion\n";
|
||||
}
|
||||
gcode << this->reset_e(true);
|
||||
|
@ -246,7 +244,7 @@ std::string GCodeWriter::reset_e(bool force)
|
|||
m_extruder->reset_E();
|
||||
}
|
||||
|
||||
if (! RELATIVE_E_AXIS) {
|
||||
if (! this->config.use_relative_e_distances) {
|
||||
std::ostringstream gcode;
|
||||
gcode << "G92 E0";
|
||||
//BBS
|
||||
|
|
|
@ -803,7 +803,7 @@ static std::vector<std::string> s_Preset_printer_options {
|
|||
"printhost_cafile","printhost_port","printhost_authorization_type",
|
||||
"printhost_user", "printhost_password", "printhost_ssl_ignore_revoke",
|
||||
"z_lift_type", "thumbnails",
|
||||
"use_firmware_retraction"
|
||||
"use_firmware_retraction", "use_relative_e_distances"
|
||||
};
|
||||
|
||||
static std::vector<std::string> s_Preset_sla_print_options {
|
||||
|
|
|
@ -152,7 +152,8 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
|
|||
// SoftFever
|
||||
"seam_gap",
|
||||
"role_based_wipe_speed",
|
||||
"wipe_speed"
|
||||
"wipe_speed",
|
||||
"use_relative_e_distances"
|
||||
};
|
||||
|
||||
static std::unordered_set<std::string> steps_ignore;
|
||||
|
@ -918,6 +919,9 @@ StringObjectException Print::validate(StringObjectException *warning, Polygons*
|
|||
return { ("Different nozzle diameters and different filament diameters is not allowed when prime tower is enabled.") };
|
||||
}
|
||||
|
||||
if (! m_config.use_relative_e_distances)
|
||||
return { ("The Wipe Tower is currently only supported with the relative extruder addressing (use_relative_e_distances=1).") };
|
||||
|
||||
if (m_config.ooze_prevention)
|
||||
return { ("Ooze prevention is currently not supported with the prime tower enabled.") };
|
||||
|
||||
|
@ -1120,7 +1124,6 @@ StringObjectException Print::validate(StringObjectException *warning, Polygons*
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
const ConfigOptionDef* bed_type_def = print_config_def.get("curr_bed_type");
|
||||
assert(bed_type_def != nullptr);
|
||||
|
||||
|
|
|
@ -3224,6 +3224,15 @@ void PrintConfigDef::init_fff_params()
|
|||
def->gui_type = ConfigOptionDef::GUIType::one_string;
|
||||
def->set_default_value(new ConfigOptionPoints{Vec2d(300, 300)});
|
||||
|
||||
def = this->add("use_relative_e_distances", coBool);
|
||||
def->label = L("Use relative E distances");
|
||||
def->tooltip = L("Relative extrusion is recommended when using \"label_objects\" option."
|
||||
"Some extruders work better with this option unckecked (absolute extrusion mode). "
|
||||
"Wipe tower is only compatible with relative mode. It is always enabled on "
|
||||
"BambuLab printers. Default is checked");
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionBool(true));
|
||||
|
||||
def = this->add("wall_generator", coEnum);
|
||||
def->label = L("Wall generator");
|
||||
def->category = L("Quality");
|
||||
|
|
|
@ -853,7 +853,7 @@ PRINT_CONFIG_CLASS_DEFINE(
|
|||
((ConfigOptionBool, auxiliary_fan))
|
||||
// SoftFever
|
||||
((ConfigOptionBool, use_firmware_retraction))
|
||||
|
||||
((ConfigOptionBool, use_relative_e_distances))
|
||||
)
|
||||
|
||||
// This object is mapped to Perl as Slic3r::Config::Print.
|
||||
|
|
|
@ -78,10 +78,6 @@ static constexpr double BRIDGE_INFILL_MARGIN = 1;
|
|||
#define scale_(val) ((val) / SCALING_FACTOR)
|
||||
#define unscale_(val) ((val) * SCALING_FACTOR)
|
||||
|
||||
//BBS: BBS only support relative E and can't been changed by user at the moment. because
|
||||
//BBS need to support skip object when printing.
|
||||
static constexpr bool RELATIVE_E_AXIS = 1;
|
||||
|
||||
#define SCALED_EPSILON scale_(EPSILON)
|
||||
|
||||
#ifndef UNUSED
|
||||
|
|
|
@ -2987,6 +2987,7 @@ void TabPrinter::build_fff()
|
|||
#endif
|
||||
|
||||
optgroup = page->new_optgroup(L("Advanced"), L"param_advanced");
|
||||
optgroup->append_single_option_line("use_relative_e_distances");
|
||||
optgroup->append_single_option_line("gcode_flavor");
|
||||
option = optgroup->get_option("thumbnails");
|
||||
option.opt.full_width = true;
|
||||
|
@ -3553,6 +3554,8 @@ void TabPrinter::toggle_options()
|
|||
//}
|
||||
if (m_active_page->title() == "Basic information") {
|
||||
toggle_option("single_extruder_multi_material", have_multiple_extruders);
|
||||
// Hide relative extrusion option for BBL printers
|
||||
toggle_line("use_relative_e_distances", !is_BBL_printer);
|
||||
|
||||
auto flavor = m_config->option<ConfigOptionEnum<GCodeFlavor>>("gcode_flavor")->value;
|
||||
bool is_marlin_flavor = flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue