mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 15:35:56 +08:00
CLI: Fixed load of the model, when input file isn't project file
This commit is contained in:
parent
c264a216c0
commit
f51611c83e
@ -129,7 +129,7 @@ static bool process_input_files(std::vector<Model>& models, DynamicPrintConfig&
|
|||||||
|
|
||||||
Model model;
|
Model model;
|
||||||
try {
|
try {
|
||||||
if (has_full_config_from_profiles(cli)) {
|
if (has_full_config_from_profiles(cli) || !FileReader::is_project_file(file)) {
|
||||||
// we have full banch of options from profiles set
|
// we have full banch of options from profiles set
|
||||||
// so, just load a geometry
|
// so, just load a geometry
|
||||||
model = FileReader::load_model(file);
|
model = FileReader::load_model(file);
|
||||||
@ -154,7 +154,7 @@ static bool process_input_files(std::vector<Model>& models, DynamicPrintConfig&
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If model for slicing is loaded from 3mf file, then its geometry has to be used and arrange couldn't be apply for this model.
|
// If model for slicing is loaded from 3mf file, then its geometry has to be used and arrange couldn't be apply for this model.
|
||||||
if ((boost::algorithm::iends_with(file, ".3mf") || boost::algorithm::iends_with(file, ".zip")) &&
|
if (FileReader::is_project_file(file) &&
|
||||||
(!cli.transform_config.has("dont_arrange") || !cli.transform_config.opt_bool("dont_arrange"))) {
|
(!cli.transform_config.has("dont_arrange") || !cli.transform_config.opt_bool("dont_arrange"))) {
|
||||||
//So, check a state of "dont_arrange" parameter and set it to true, if its value is false.
|
//So, check a state of "dont_arrange" parameter and set it to true, if its value is false.
|
||||||
cli.transform_config.set_key_value("dont_arrange", new ConfigOptionBool(true));
|
cli.transform_config.set_key_value("dont_arrange", new ConfigOptionBool(true));
|
||||||
|
@ -30,6 +30,12 @@
|
|||||||
|
|
||||||
namespace Slic3r::FileReader
|
namespace Slic3r::FileReader
|
||||||
{
|
{
|
||||||
|
|
||||||
|
bool is_project_file(const std::string& input_file)
|
||||||
|
{
|
||||||
|
return boost::algorithm::iends_with(input_file, ".3mf") || boost::algorithm::iends_with(input_file, ".zip");
|
||||||
|
}
|
||||||
|
|
||||||
// Loading model from a file, it may be a simple geometry file as STL or OBJ, however it may be a project file as well.
|
// Loading model from a file, it may be a simple geometry file as STL or OBJ, however it may be a project file as well.
|
||||||
static Model read_model_from_file(const std::string& input_file, LoadAttributes options)
|
static Model read_model_from_file(const std::string& input_file, LoadAttributes options)
|
||||||
{
|
{
|
||||||
@ -83,15 +89,14 @@ static Model read_all_from_file(const std::string& input_file,
|
|||||||
boost::optional<Semver> &prusaslicer_generator_version,
|
boost::optional<Semver> &prusaslicer_generator_version,
|
||||||
LoadAttributes options)
|
LoadAttributes options)
|
||||||
{
|
{
|
||||||
const bool is_project_file = boost::algorithm::iends_with(input_file, ".3mf") || boost::algorithm::iends_with(input_file, ".zip");
|
assert(is_project_file(input_file));
|
||||||
assert(is_project_file);
|
|
||||||
assert(config != nullptr);
|
assert(config != nullptr);
|
||||||
assert(config_substitutions != nullptr);
|
assert(config_substitutions != nullptr);
|
||||||
|
|
||||||
Model model;
|
Model model;
|
||||||
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if (is_project_file)
|
if (is_project_file(input_file))
|
||||||
result = load_3mf(input_file.c_str(), *config, *config_substitutions, &model, options & LoadAttribute::CheckVersion, prusaslicer_generator_version);
|
result = load_3mf(input_file.c_str(), *config, *config_substitutions, &model, options & LoadAttribute::CheckVersion, prusaslicer_generator_version);
|
||||||
else
|
else
|
||||||
throw Slic3r::RuntimeError(L("Unknown file format. Input file must have .3mf extension."));
|
throw Slic3r::RuntimeError(L("Unknown file format. Input file must have .3mf extension."));
|
||||||
|
@ -35,6 +35,8 @@ namespace FileReader
|
|||||||
bool looks_like_multipart_object { false };
|
bool looks_like_multipart_object { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool is_project_file(const std::string& input_file);
|
||||||
|
|
||||||
// Load model from input file and return the its mesh.
|
// Load model from input file and return the its mesh.
|
||||||
// Throw RuntimeError if some problem was detected during model loading
|
// Throw RuntimeError if some problem was detected during model loading
|
||||||
TriangleMesh load_mesh(const std::string& input_file);
|
TriangleMesh load_mesh(const std::string& input_file);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user