diff options
author | Alessandro Ranellucci <aar@cpan.org> | 2016-12-20 21:26:23 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2017-02-28 12:28:29 +0300 |
commit | 6f119692571dca109ed4534549472154b792ec25 (patch) | |
tree | 6476c6ce46c0e5dc0f974f9cea39ca71cf2ded7e /xs | |
parent | 4528f35bc0ad179177aa67ad4cc896f6d5121b32 (diff) |
Restore [input_filename] in custom G-code as well
Diffstat (limited to 'xs')
-rw-r--r-- | xs/src/libslic3r/Print.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 44a5abd1f..434535ac9 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -6,6 +6,8 @@ #include "Geometry.hpp" #include "SupportMaterial.hpp" #include <algorithm> +#include <boost/filesystem.hpp> +#include <boost/lexical_cast.hpp> namespace Slic3r { @@ -410,6 +412,29 @@ Print::add_model_object(ModelObject* model_object, int idx) // apply config to print object o->config.apply(this->default_object_config); o->config.apply(object_config, true); + + // update placeholders + { + // get the first input file name + std::string input_file; + std::vector<std::string> v_scale; + for (const PrintObject *object : this->objects) { + 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 |