mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 18:36:00 +08:00
Restore [input_filename] in custom G-code as well
This commit is contained in:
parent
6f9e1cde6e
commit
ec9c1fe654
@ -436,6 +436,29 @@ Print::add_model_object(ModelObject* model_object, int idx)
|
|||||||
// apply config to print object
|
// apply config to print object
|
||||||
o->config.apply(this->default_object_config);
|
o->config.apply(this->default_object_config);
|
||||||
o->config.apply(object_config, true);
|
o->config.apply(object_config, true);
|
||||||
|
|
||||||
|
// update placeholders
|
||||||
|
{
|
||||||
|
// get the first input file name
|
||||||
|
std::string input_file;
|
||||||
|
std::vector<std::string> v_scale;
|
||||||
|
FOREACH_OBJECT(this, object) {
|
||||||
|
const ModelObject &mobj = *(*object)->model_object();
|
||||||
|
v_scale.push_back( boost::lexical_cast<std::string>(mobj.instances[0]->scaling_factor*100) + "%" );
|
||||||
|
if (input_file.empty())
|
||||||
|
input_file = mobj.input_file;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlaceholderParser &pp = this->placeholder_parser;
|
||||||
|
pp.set("scale", v_scale);
|
||||||
|
if (!input_file.empty()) {
|
||||||
|
// get basename with and without suffix
|
||||||
|
const std::string input_basename = boost::filesystem::path(input_file).filename().string();
|
||||||
|
pp.set("input_filename", input_basename);
|
||||||
|
const std::string input_basename_base = input_basename.substr(0, input_basename.find_last_of("."));
|
||||||
|
pp.set("input_filename_base", input_basename_base);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -976,37 +999,14 @@ Print::auto_assign_extruders(ModelObject* model_object) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
Print::output_filename() const
|
Print::output_filename()
|
||||||
{
|
{
|
||||||
PlaceholderParser pp = this->placeholder_parser;
|
this->placeholder_parser.update_timestamp();
|
||||||
|
return this->placeholder_parser.process(this->config.output_filename_format.value);
|
||||||
// get input file name
|
|
||||||
std::string input_file;
|
|
||||||
FOREACH_OBJECT(this, object) {
|
|
||||||
input_file = (*object)->model_object()->input_file;
|
|
||||||
if (!input_file.empty()) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get basename with and without suffix and set placeholders
|
|
||||||
const std::string input_basename = boost::filesystem::path(input_file).filename().string();
|
|
||||||
pp.set("input_filename", input_basename);
|
|
||||||
const std::string input_basename_base = input_basename.substr(0, input_basename.find_last_of("."));
|
|
||||||
pp.set("input_filename_base", input_basename_base);
|
|
||||||
|
|
||||||
// set other variables from model object
|
|
||||||
{
|
|
||||||
std::vector<std::string> v_scale;
|
|
||||||
FOREACH_OBJECT(this, object)
|
|
||||||
v_scale.push_back( boost::lexical_cast<std::string>((*object)->model_object()->instances[0]->scaling_factor*100) + "%" );
|
|
||||||
pp.set("scale", v_scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
pp.update_timestamp();
|
|
||||||
return pp.process(this->config.output_filename_format.value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
Print::output_filepath(const std::string &path) const
|
Print::output_filepath(const std::string &path)
|
||||||
{
|
{
|
||||||
// if we were supplied no path, generate an automatic one based on our first object's input file
|
// if we were supplied no path, generate an automatic one based on our first object's input file
|
||||||
if (path.empty()) {
|
if (path.empty()) {
|
||||||
|
@ -212,8 +212,8 @@ class Print
|
|||||||
double max_allowed_layer_height() const;
|
double max_allowed_layer_height() const;
|
||||||
bool has_support_material() const;
|
bool has_support_material() const;
|
||||||
void auto_assign_extruders(ModelObject* model_object) const;
|
void auto_assign_extruders(ModelObject* model_object) const;
|
||||||
std::string output_filename() const;
|
std::string output_filename();
|
||||||
std::string output_filepath(const std::string &path) const;
|
std::string output_filepath(const std::string &path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void clear_regions();
|
void clear_regions();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user