mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-11 01:09:02 +08:00
Use input name for cut. Also use find_last_of() instead of find_first_of() to properly capture names with periods in them.
Fixes #4136
This commit is contained in:
parent
695f5fd86c
commit
7bf852201f
@ -138,11 +138,11 @@ main(int argc, char **argv)
|
||||
std::string outfile = cli_config.output.value;
|
||||
if (outfile.empty()) outfile = model.objects.front()->input_file;
|
||||
// Check if the file is already a 3mf.
|
||||
if(outfile.substr(outfile.find_first_of('.'), outfile.length()) == ".3mf")
|
||||
outfile = outfile.substr(0, outfile.find_first_of('.')) + "_2" + ".3mf";
|
||||
if(outfile.substr(outfile.find_last_of('.'), outfile.length()) == ".3mf")
|
||||
outfile = outfile.substr(0, outfile.find_last_of('.')) + "_2" + ".3mf";
|
||||
else
|
||||
// Remove the previous extension and add .3mf extention.
|
||||
outfile = outfile.substr(0, outfile.find_first_of('.')) + ".3mf";
|
||||
outfile = outfile.substr(0, outfile.find_last_of('.')) + ".3mf";
|
||||
IO::TMF::write(model, outfile);
|
||||
boost::nowide::cout << "File file exported to " << outfile << std::endl;
|
||||
} else if (cli_config.cut_x > 0 || cli_config.cut_y > 0 || cli_config.cut > 0) {
|
||||
@ -162,14 +162,20 @@ main(int argc, char **argv)
|
||||
|
||||
ModelObject &upper = *out.objects[0];
|
||||
ModelObject &lower = *out.objects[1];
|
||||
|
||||
// Use the input name and trim off the extension.
|
||||
std::string outfile = cli_config.output.value;
|
||||
if (outfile.empty()) outfile = model.objects.front()->input_file;
|
||||
outfile = outfile.substr(0, outfile.find_last_of('.'));
|
||||
std::cerr << outfile << "\n";
|
||||
|
||||
if (upper.facets_count() > 0) {
|
||||
TriangleMesh m = upper.mesh();
|
||||
IO::STL::write(m, upper.input_file + "_upper.stl");
|
||||
IO::STL::write(m, outfile + "_upper.stl");
|
||||
}
|
||||
if (lower.facets_count() > 0) {
|
||||
TriangleMesh m = lower.mesh();
|
||||
IO::STL::write(m, lower.input_file + "_lower.stl");
|
||||
IO::STL::write(m, outfile + "_lower.stl");
|
||||
}
|
||||
}
|
||||
} else if (cli_config.cut_grid.value.x > 0 && cli_config.cut_grid.value.y > 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user