diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 71614cda043..ed71e9bc263 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -2399,6 +2399,8 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato 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("z_offset", new ConfigOptionFloat(m_config.z_offset)); + this->placeholder_parser().set("model_name", new ConfigOptionString(print.get_model_name())); + this->placeholder_parser().set("plate_number", new ConfigOptionString(print.get_plate_number_formatted())); 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)); diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 46918088eda..2b1492a2f55 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -2841,10 +2841,30 @@ std::string Print::output_filename(const std::string &filename_base) const DynamicConfig config = this->finished() ? this->print_statistics().config() : this->print_statistics().placeholders(); config.set_key_value("num_filaments", new ConfigOptionInt((int)m_config.nozzle_diameter.size())); config.set_key_value("plate_name", new ConfigOptionString(get_plate_name())); + config.set_key_value("plate_number", new ConfigOptionString(get_plate_number_formatted())); + config.set_key_value("model_name", new ConfigOptionString(get_model_name())); return this->PrintBase::output_filename(m_config.filename_format.value, ".gcode", filename_base, &config); } +std::string Print::get_model_name() const +{ + if (model().model_info != nullptr) + { + return model().model_info->model_name; + } else { + return ""; + } +} + +std::string Print::get_plate_number_formatted() const +{ + std::string plate_number = std::to_string(get_plate_index() + 1); + static const size_t n_zero = 2; + + return std::string(n_zero - std::min(n_zero, plate_number.length()), '0') + plate_number; +} + //BBS: add gcode file preload logic void Print::set_gcode_file_ready() { diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp index 23a3a001591..bd7b867b99e 100644 --- a/src/libslic3r/Print.hpp +++ b/src/libslic3r/Print.hpp @@ -903,6 +903,9 @@ class Print : public PrintBaseWithState std::string output_filename(const std::string &filename_base = std::string()) const override; + std::string get_model_name() const; + std::string get_plate_number_formatted() const; + size_t num_print_regions() const throw() { return m_print_regions.size(); } const PrintRegion& get_print_region(size_t idx) const { return *m_print_regions[idx]; } const ToolOrdering& get_tool_ordering() const { return m_wipe_tower_data.tool_ordering; }