mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-23 00:31:11 -06:00
AMF and 3MF export - Export of print config customizable by user in the select file dialog
This commit is contained in:
parent
4173628a31
commit
4b8bd48663
9 changed files with 87 additions and 25 deletions
|
@ -1443,10 +1443,10 @@ namespace Slic3r {
|
|||
IdToObjectDataMap m_objects_data;
|
||||
|
||||
public:
|
||||
bool save_model_to_file(const std::string& filename, Model& model, const Print& print);
|
||||
bool save_model_to_file(const std::string& filename, Model& model, const Print& print, bool export_print_config);
|
||||
|
||||
private:
|
||||
bool _save_model_to_file(const std::string& filename, Model& model, const Print& print);
|
||||
bool _save_model_to_file(const std::string& filename, Model& model, const Print& print, bool export_print_config);
|
||||
bool _add_content_types_file_to_archive(mz_zip_archive& archive);
|
||||
bool _add_relationships_file_to_archive(mz_zip_archive& archive);
|
||||
bool _add_model_file_to_archive(mz_zip_archive& archive, Model& model);
|
||||
|
@ -1457,13 +1457,13 @@ namespace Slic3r {
|
|||
bool _add_model_config_file_to_archive(mz_zip_archive& archive, const Model& model);
|
||||
};
|
||||
|
||||
bool _3MF_Exporter::save_model_to_file(const std::string& filename, Model& model, const Print& print)
|
||||
bool _3MF_Exporter::save_model_to_file(const std::string& filename, Model& model, const Print& print, bool export_print_config)
|
||||
{
|
||||
clear_errors();
|
||||
return _save_model_to_file(filename, model, print);
|
||||
return _save_model_to_file(filename, model, print, export_print_config);
|
||||
}
|
||||
|
||||
bool _3MF_Exporter::_save_model_to_file(const std::string& filename, Model& model, const Print& print)
|
||||
bool _3MF_Exporter::_save_model_to_file(const std::string& filename, Model& model, const Print& print, bool export_print_config)
|
||||
{
|
||||
mz_zip_archive archive;
|
||||
mz_zip_zero_struct(&archive);
|
||||
|
@ -1502,11 +1502,14 @@ namespace Slic3r {
|
|||
}
|
||||
|
||||
// adds slic3r print config file
|
||||
if (!_add_print_config_file_to_archive(archive, print))
|
||||
if (export_print_config)
|
||||
{
|
||||
mz_zip_writer_end(&archive);
|
||||
boost::filesystem::remove(filename);
|
||||
return false;
|
||||
if (!_add_print_config_file_to_archive(archive, print))
|
||||
{
|
||||
mz_zip_writer_end(&archive);
|
||||
boost::filesystem::remove(filename);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// adds slic3r model config file
|
||||
|
@ -1863,13 +1866,13 @@ namespace Slic3r {
|
|||
return res;
|
||||
}
|
||||
|
||||
bool store_3mf(const char* path, Model* model, Print* print)
|
||||
bool store_3mf(const char* path, Model* model, Print* print, bool export_print_config)
|
||||
{
|
||||
if ((path == nullptr) || (model == nullptr) || (print == nullptr))
|
||||
return false;
|
||||
|
||||
_3MF_Exporter exporter;
|
||||
bool res = exporter.save_model_to_file(path, *model, *print);
|
||||
bool res = exporter.save_model_to_file(path, *model, *print, export_print_config);
|
||||
|
||||
if (!res)
|
||||
exporter.log_errors();
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Slic3r {
|
|||
|
||||
// Save the given model and the config data contained in the given Print into a 3mf file.
|
||||
// The model could be modified during the export process if meshes are not repaired or have no shared vertices
|
||||
extern bool store_3mf(const char* path, Model* model, Print* print);
|
||||
extern bool store_3mf(const char* path, Model* model, Print* print, bool export_print_config);
|
||||
|
||||
}; // namespace Slic3r
|
||||
|
||||
|
|
|
@ -576,8 +576,7 @@ bool load_amf_archive(const char *path, PresetBundle* bundle, Model *model)
|
|||
return false;
|
||||
}
|
||||
|
||||
std::string internal_amf_filename = boost::ireplace_last_copy(boost::filesystem::path(path).filename().string(), ".zip.amf", ".amf");
|
||||
if (internal_amf_filename != stat.m_filename)
|
||||
if (!boost::iends_with(stat.m_filename, ".amf"))
|
||||
{
|
||||
printf("Found invalid internal filename\n");
|
||||
mz_zip_reader_end(&archive);
|
||||
|
@ -644,7 +643,7 @@ bool load_amf(const char *path, PresetBundle* bundle, Model *model)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool store_amf(const char *path, Model *model, Print* print)
|
||||
bool store_amf(const char *path, Model *model, Print* print, bool export_print_config)
|
||||
{
|
||||
if ((path == nullptr) || (model == nullptr) || (print == nullptr))
|
||||
return false;
|
||||
|
@ -661,9 +660,12 @@ bool store_amf(const char *path, Model *model, Print* print)
|
|||
stream << "<amf unit=\"millimeter\">\n";
|
||||
stream << "<metadata type=\"cad\">Slic3r " << SLIC3R_VERSION << "</metadata>\n";
|
||||
|
||||
std::string config = "\n";
|
||||
GCode::append_full_config(*print, config);
|
||||
stream << "<metadata type=\"" << SLIC3R_CONFIG_TYPE << "\">" << config << "</metadata>\n";
|
||||
if (export_print_config)
|
||||
{
|
||||
std::string config = "\n";
|
||||
GCode::append_full_config(*print, config);
|
||||
stream << "<metadata type=\"" << SLIC3R_CONFIG_TYPE << "\">" << config << "</metadata>\n";
|
||||
}
|
||||
|
||||
for (const auto &material : model->materials) {
|
||||
if (material.first.empty())
|
||||
|
|
|
@ -12,7 +12,7 @@ extern bool load_amf(const char *path, PresetBundle* bundle, Model *model);
|
|||
|
||||
// Save the given model and the config data contained in the given Print into an amf file.
|
||||
// The model could be modified during the export process if meshes are not repaired or have no shared vertices
|
||||
extern bool store_amf(const char *path, Model *model, Print* print);
|
||||
extern bool store_amf(const char *path, Model *model, Print* print, bool export_print_config);
|
||||
|
||||
}; // namespace Slic3r
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue