add z offset option

This commit is contained in:
SoftFever 2023-10-24 18:49:53 +08:00
parent 0851e0934b
commit 6023f79be3
7 changed files with 23 additions and 20 deletions

View file

@ -2199,7 +2199,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
this->placeholder_parser().set("first_layer_bed_temperature", new ConfigOptionInts(*first_bed_temp_opt)); this->placeholder_parser().set("first_layer_bed_temperature", new ConfigOptionInts(*first_bed_temp_opt));
this->placeholder_parser().set("first_layer_temperature", new ConfigOptionInts(m_config.nozzle_temperature_initial_layer)); this->placeholder_parser().set("first_layer_temperature", new ConfigOptionInts(m_config.nozzle_temperature_initial_layer));
this->placeholder_parser().set("max_print_height",new ConfigOptionInt(m_config.printable_height)); this->placeholder_parser().set("max_print_height",new ConfigOptionInt(m_config.printable_height));
this->placeholder_parser().set("z_offset", new ConfigOptionFloat(0.0f)); this->placeholder_parser().set("z_offset", new ConfigOptionFloat(m_config.z_offset));
this->placeholder_parser().set("plate_name", new ConfigOptionString(print.get_plate_name())); this->placeholder_parser().set("plate_name", new ConfigOptionString(print.get_plate_name()));
this->placeholder_parser().set("first_layer_height", new ConfigOptionFloat(m_config.initial_layer_print_height.value)); this->placeholder_parser().set("first_layer_height", new ConfigOptionFloat(m_config.initial_layer_print_height.value));
@ -2440,8 +2440,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
if (has_wipe_tower && ! layers_to_print.empty()) { if (has_wipe_tower && ! layers_to_print.empty()) {
m_wipe_tower.reset(new WipeTowerIntegration(print.config(), print.get_plate_index(), print.get_plate_origin(), * print.wipe_tower_data().priming.get(), print.wipe_tower_data().tool_changes, *print.wipe_tower_data().final_purge.get())); m_wipe_tower.reset(new WipeTowerIntegration(print.config(), print.get_plate_index(), print.get_plate_origin(), * print.wipe_tower_data().priming.get(), print.wipe_tower_data().tool_changes, *print.wipe_tower_data().final_purge.get()));
//BBS //BBS
//file.write(m_writer.travel_to_z(initial_layer_print_height + m_config.z_offset.value, "Move to the first layer height")); file.write(m_writer.travel_to_z(initial_layer_print_height + m_config.z_offset.value, "Move to the first layer height"));
file.write(m_writer.travel_to_z(initial_layer_print_height, "Move to the first layer height"));
#if 0 #if 0
if (print.config().single_extruder_multi_material_priming) { if (print.config().single_extruder_multi_material_priming) {
file.write(m_wipe_tower->prime(*this)); file.write(m_wipe_tower->prime(*this));
@ -2528,8 +2527,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
DynamicConfig config; DynamicConfig config;
config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index)); config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index));
//BBS //BBS
//config.set_key_value("layer_z", new ConfigOptionFloat(m_writer.get_position()(2) - m_config.z_offset.value)); config.set_key_value("layer_z", new ConfigOptionFloat(m_writer.get_position()(2) - m_config.z_offset.value));
config.set_key_value("layer_z", new ConfigOptionFloat(m_writer.get_position()(2)));
config.set_key_value("max_layer_z", new ConfigOptionFloat(m_max_layer_z)); config.set_key_value("max_layer_z", new ConfigOptionFloat(m_max_layer_z));
if (print.config().single_extruder_multi_material) { if (print.config().single_extruder_multi_material) {
// Process the filament_end_gcode for the active filament only. // Process the filament_end_gcode for the active filament only.
@ -4093,8 +4091,7 @@ std::string GCode::preamble()
position of our writer object so that any initial lift taking place position of our writer object so that any initial lift taking place
before the first layer change will raise the extruder from the correct before the first layer change will raise the extruder from the correct
initial Z instead of 0. */ initial Z instead of 0. */
//m_writer.travel_to_z(m_config.z_offset.value); m_writer.travel_to_z(m_config.z_offset.value);
m_writer.travel_to_z(0.0);
return gcode; return gcode;
} }
@ -4107,8 +4104,7 @@ std::string GCode::change_layer(coordf_t print_z)
// Increment a progress bar indicator. // Increment a progress bar indicator.
gcode += m_writer.update_progress(++ m_layer_index, m_layer_count); gcode += m_writer.update_progress(++ m_layer_index, m_layer_count);
//BBS //BBS
//coordf_t z = print_z + m_config.z_offset.value; // in unscaled coordinates coordf_t z = print_z + m_config.z_offset.value; // in unscaled coordinates
coordf_t z = print_z; // in unscaled coordinates
if (EXTRUDER_CONFIG(retract_when_changing_layer) && m_writer.will_move_z(z)) { if (EXTRUDER_CONFIG(retract_when_changing_layer) && m_writer.will_move_z(z)) {
LiftType lift_type = this->to_lift_type(ZHopType(EXTRUDER_CONFIG(z_hop_types))); LiftType lift_type = this->to_lift_type(ZHopType(EXTRUDER_CONFIG(z_hop_types)));
//BBS: force to use SpiralLift when change layer if lift type is auto //BBS: force to use SpiralLift when change layer if lift type is auto
@ -4128,7 +4124,7 @@ std::string GCode::change_layer(coordf_t print_z)
m_need_change_layer_lift_z = true; m_need_change_layer_lift_z = true;
} }
m_nominal_z = print_z; m_nominal_z = z;
// forget last wiping path as wiping after raising Z is pointless // forget last wiping path as wiping after raising Z is pointless
// BBS. Dont forget wiping path to reduce stringing. // BBS. Dont forget wiping path to reduce stringing.

View file

@ -10,9 +10,7 @@ class SpiralVase {
public: public:
SpiralVase(const PrintConfig &config) : m_config(config) SpiralVase(const PrintConfig &config) : m_config(config)
{ {
//BBS m_reader.z() = (float)m_config.z_offset;
//m_reader.z() = (float)m_config.z_offset;
m_reader.z() = 0.0f;
m_reader.apply_config(m_config); m_reader.apply_config(m_config);
}; };

View file

@ -833,7 +833,9 @@ static std::vector<std::string> s_Preset_printer_options {
"printhost_user", "printhost_password", "printhost_ssl_ignore_revoke", "thumbnails", "thumbnails_format", "printhost_user", "printhost_password", "printhost_ssl_ignore_revoke", "thumbnails", "thumbnails_format",
"use_firmware_retraction", "use_relative_e_distances", "printer_notes", "use_firmware_retraction", "use_relative_e_distances", "printer_notes",
"cooling_tube_retraction", "cooling_tube_retraction",
"cooling_tube_length", "high_current_on_filament_swap", "parking_pos_retraction", "extra_loading_move", "purge_in_prime_tower", "enable_filament_ramming"}; "cooling_tube_length", "high_current_on_filament_swap", "parking_pos_retraction", "extra_loading_move", "purge_in_prime_tower", "enable_filament_ramming",
"z_offset"
};
static std::vector<std::string> s_Preset_sla_print_options { static std::vector<std::string> s_Preset_sla_print_options {
"layer_height", "layer_height",

View file

@ -289,8 +289,8 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
|| opt_key == "wiping_volumes_extruders" || opt_key == "wiping_volumes_extruders"
|| opt_key == "enable_filament_ramming" || opt_key == "enable_filament_ramming"
|| opt_key == "purge_in_prime_tower" || opt_key == "purge_in_prime_tower"
|| opt_key == "z_offset"
) { ) {
//|| opt_key == "z_offset") {
steps.emplace_back(psWipeTower); steps.emplace_back(psWipeTower);
steps.emplace_back(psSkirtBrim); steps.emplace_back(psSkirtBrim);
} else if (opt_key == "filament_soluble" } else if (opt_key == "filament_soluble"

View file

@ -3426,6 +3426,16 @@ def = this->add("filament_loading_speed", coFloats);
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionEnum<SlicingMode>(SlicingMode::Regular)); def->set_default_value(new ConfigOptionEnum<SlicingMode>(SlicingMode::Regular));
def = this->add("z_offset", coFloat);
def->label = L("Z offset");
def->tooltip = L("This value will be added (or subtracted) from all the Z coordinates "
"in the output G-code. It is used to compensate for bad Z endstop position: "
"for example, if your endstop zero actually leaves the nozzle 0.3mm far "
"from the print bed, set this to -0.3 (or fix your endstop).");
def->sidetext = L("mm");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0));
def = this->add("enable_support", coBool); def = this->add("enable_support", coBool);
//BBS: remove material behind support //BBS: remove material behind support
def->label = L("Enable support"); def->label = L("Enable support");

View file

@ -1117,7 +1117,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE(
// BBS: wipe tower is only used for priming // BBS: wipe tower is only used for priming
((ConfigOptionFloat, prime_volume)) ((ConfigOptionFloat, prime_volume))
((ConfigOptionFloat, flush_multiplier)) ((ConfigOptionFloat, flush_multiplier))
//((ConfigOptionFloat, z_offset)) ((ConfigOptionFloat, z_offset))
// BBS: project filaments // BBS: project filaments
((ConfigOptionFloats, filament_colour_new)) ((ConfigOptionFloats, filament_colour_new))
// BBS: not in any preset, calculated before slicing // BBS: not in any preset, calculated before slicing

View file

@ -3121,10 +3121,7 @@ void TabPrinter::build_fff()
optgroup->append_single_option_line("printable_height"); optgroup->append_single_option_line("printable_height");
optgroup->append_single_option_line("nozzle_volume"); optgroup->append_single_option_line("nozzle_volume");
optgroup->append_single_option_line("best_object_pos"); optgroup->append_single_option_line("best_object_pos");
optgroup->append_single_option_line("z_offset");
#if 0
//optgroup->append_single_option_line("z_offset");
#endif
// ConfigOptionDef def; // ConfigOptionDef def;
// def.type = coInt, // def.type = coInt,