New placeholder parser values for output file name template;

{num_objects} - number of printable objects on the plater.
{num_instances} - number of printable instances on the plater, adding up
  	all printable instances of all objects.
Implements #2735 #3339 #4607
This commit is contained in:
Vojtech Bubnik 2021-10-29 14:27:36 +02:00
parent 3216448bbc
commit 1ddd060982

View File

@ -26,14 +26,17 @@ void PrintBase::update_object_placeholders(DynamicConfig &config, const std::str
// get the first input file name
std::string input_file;
std::vector<std::string> v_scale;
int num_objects = 0;
int num_instances = 0;
for (const ModelObject *model_object : m_model.objects) {
ModelInstance *printable = nullptr;
for (ModelInstance *model_instance : model_object->instances)
if (model_instance->is_printable()) {
printable = model_instance;
break;
++ num_instances;
}
if (printable) {
++ num_objects;
// CHECK_ME -> Is the following correct ?
v_scale.push_back("x:" + boost::lexical_cast<std::string>(printable->get_scaling_factor(X) * 100) +
"% y:" + boost::lexical_cast<std::string>(printable->get_scaling_factor(Y) * 100) +
@ -43,6 +46,9 @@ void PrintBase::update_object_placeholders(DynamicConfig &config, const std::str
}
}
config.set_key_value("num_objects", new ConfigOptionInt(num_objects));
config.set_key_value("num_instances", new ConfigOptionInt(num_instances));
config.set_key_value("scale", new ConfigOptionStrings(v_scale));
if (! input_file.empty()) {
// get basename with and without suffix