mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-07 06:57:36 -06:00
feat: add model_name and plate_number placeholders (#5401)
This uses the BBS project name from the `Project` tab which could be susceptible to upstream changes removing this feature. The project_name template only works when you open a 3MF file. If you create a new project and set the project name `Model.model_info` is always null whether you save the project or not. If you save the current project, switch to a new project/different project, then re-load it then the template works as expected. The plate number is assumed to always be <100 which matches the formatting of the plate number in the UI. Relates-To: https://github.com/SoftFever/OrcaSlicer/issues/3816
This commit is contained in:
parent
966c18cbad
commit
194ec6b1cd
3 changed files with 25 additions and 0 deletions
|
@ -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()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue