mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 17:36:08 +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;
|
std::string outfile = cli_config.output.value;
|
||||||
if (outfile.empty()) outfile = model.objects.front()->input_file;
|
if (outfile.empty()) outfile = model.objects.front()->input_file;
|
||||||
// Check if the file is already a 3mf.
|
// Check if the file is already a 3mf.
|
||||||
if(outfile.substr(outfile.find_first_of('.'), outfile.length()) == ".3mf")
|
if(outfile.substr(outfile.find_last_of('.'), outfile.length()) == ".3mf")
|
||||||
outfile = outfile.substr(0, outfile.find_first_of('.')) + "_2" + ".3mf";
|
outfile = outfile.substr(0, outfile.find_last_of('.')) + "_2" + ".3mf";
|
||||||
else
|
else
|
||||||
// Remove the previous extension and add .3mf extention.
|
// 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);
|
IO::TMF::write(model, outfile);
|
||||||
boost::nowide::cout << "File file exported to " << outfile << std::endl;
|
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) {
|
} else if (cli_config.cut_x > 0 || cli_config.cut_y > 0 || cli_config.cut > 0) {
|
||||||
@ -163,13 +163,19 @@ main(int argc, char **argv)
|
|||||||
ModelObject &upper = *out.objects[0];
|
ModelObject &upper = *out.objects[0];
|
||||||
ModelObject &lower = *out.objects[1];
|
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) {
|
if (upper.facets_count() > 0) {
|
||||||
TriangleMesh m = upper.mesh();
|
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) {
|
if (lower.facets_count() > 0) {
|
||||||
TriangleMesh m = lower.mesh();
|
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) {
|
} 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