mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 18:15:53 +08:00
fix export_to_prusa for object & modifer settings that need the full config as reference
supermerill/SuperSlicer#1503
This commit is contained in:
parent
55fdc665ca
commit
92f9b734e6
@ -2109,8 +2109,8 @@ namespace Slic3r {
|
||||
bool _add_sla_support_points_file_to_archive(mz_zip_archive& archive, Model& model);
|
||||
bool _add_sla_drain_holes_file_to_archive(mz_zip_archive& archive, Model& model);
|
||||
bool _add_print_config_file_to_archive(mz_zip_archive& archive, const DynamicPrintConfig &config, const std::string &file_path);
|
||||
bool _add_model_config_file_to_archive(mz_zip_archive& archive, const Model& model, const IdToObjectDataMap &objects_data, const std::string &file_path);
|
||||
bool _add_custom_gcode_per_print_z_file_to_archive(mz_zip_archive& archive, Model& model, const DynamicPrintConfig* config);
|
||||
bool _add_model_config_file_to_archive(mz_zip_archive& archive, const Model& model, const DynamicPrintConfig& print_config, const IdToObjectDataMap &objects_data, const std::string &file_path);
|
||||
bool _add_custom_gcode_per_print_z_file_to_archive(mz_zip_archive& archive, Model& model, const DynamicPrintConfig& config);
|
||||
};
|
||||
|
||||
bool _3MF_Exporter::save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config, bool fullpath_sources, const ThumbnailData* thumbnail_data)
|
||||
@ -2211,7 +2211,7 @@ namespace Slic3r {
|
||||
|
||||
// Adds custom gcode per height file ("Metadata/Prusa_Slicer_custom_gcode_per_print_z.xml").
|
||||
// All custom gcode per height of whole Model are stored here
|
||||
if (!_add_custom_gcode_per_print_z_file_to_archive(archive, model, config))
|
||||
if (!_add_custom_gcode_per_print_z_file_to_archive(archive, model, *config))
|
||||
{
|
||||
close_zip_writer(&archive);
|
||||
boost::filesystem::remove(filename);
|
||||
@ -2238,21 +2238,21 @@ namespace Slic3r {
|
||||
// This file contains all the attributes of all ModelObjects and their ModelVolumes (names, parameter overrides).
|
||||
// As there is just a single Indexed Triangle Set data stored per ModelObject, offsets of volumes into their respective Indexed Triangle Set data
|
||||
// is stored here as well.
|
||||
if (!_add_model_config_file_to_archive(archive, model, objects_data, MODEL_CONFIG_FILE))
|
||||
if (!_add_model_config_file_to_archive(archive, model, *config, objects_data, MODEL_CONFIG_FILE))
|
||||
{
|
||||
close_zip_writer(&archive);
|
||||
boost::filesystem::remove(filename);
|
||||
return false;
|
||||
}
|
||||
// also add prusa
|
||||
if (!_add_model_config_file_to_archive(archive, model, objects_data, MODEL_PRUSA_CONFIG_FILE))
|
||||
if (!_add_model_config_file_to_archive(archive, model, *config, objects_data, MODEL_PRUSA_CONFIG_FILE))
|
||||
{
|
||||
close_zip_writer(&archive);
|
||||
boost::filesystem::remove(filename);
|
||||
return false;
|
||||
}
|
||||
// also superslicer for backward comp, just for some version from 2.3.56
|
||||
if (!_add_model_config_file_to_archive(archive, model, objects_data, MODEL_SUPER_CONFIG_FILE))
|
||||
if (!_add_model_config_file_to_archive(archive, model, *config, objects_data, MODEL_SUPER_CONFIG_FILE))
|
||||
{
|
||||
close_zip_writer(&archive);
|
||||
boost::filesystem::remove(filename);
|
||||
@ -2787,7 +2787,7 @@ namespace Slic3r {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _3MF_Exporter::_add_model_config_file_to_archive(mz_zip_archive& archive, const Model& model, const IdToObjectDataMap &objects_data, const std::string &file_path)
|
||||
bool _3MF_Exporter::_add_model_config_file_to_archive(mz_zip_archive& archive, const Model& model, const DynamicPrintConfig& print_config, const IdToObjectDataMap &objects_data, const std::string &file_path)
|
||||
{
|
||||
std::stringstream stream;
|
||||
// Store mesh transformation in full precision, as the volumes are stored transformed and they need to be transformed back
|
||||
@ -2802,6 +2802,7 @@ namespace Slic3r {
|
||||
const ModelObject* obj = obj_metadata.second.object;
|
||||
if (obj != nullptr)
|
||||
{
|
||||
DynamicPrintConfig obj_config_wparent; // part of the chain of config, used as reference to convert configs to prusa config
|
||||
// Output of instances count added because of github #3435, currently not used by PrusaSlicer
|
||||
stream << " <" << OBJECT_TAG << " " << ID_ATTR << "=\"" << obj_metadata.first << "\" " << INSTANCESCOUNT_ATTR << "=\"" << obj->instances.size() << "\">\n";
|
||||
|
||||
@ -2812,10 +2813,13 @@ namespace Slic3r {
|
||||
|
||||
// stores object's config data
|
||||
if (file_path == MODEL_PRUSA_CONFIG_FILE) {
|
||||
assert(obj->config.get().parent == nullptr);
|
||||
obj_config_wparent = obj->config.get();
|
||||
obj_config_wparent.parent = &print_config;
|
||||
for (std::string key : obj->config.keys()) {
|
||||
// convert to prusa config
|
||||
std::string value = obj->config.opt_serialize(key);
|
||||
obj->config.to_prusa(key, value);
|
||||
obj_config_wparent.to_prusa(key, value);
|
||||
if (!key.empty())
|
||||
stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << OBJECT_TYPE << "\" " << KEY_ATTR << "=\"" << key << "\" " << VALUE_ATTR << "=\"" << value << "\"/>\n";
|
||||
}
|
||||
@ -2884,10 +2888,13 @@ namespace Slic3r {
|
||||
|
||||
// stores volume's config data
|
||||
if (file_path == MODEL_PRUSA_CONFIG_FILE) {
|
||||
assert(volume->config.get().parent == nullptr);
|
||||
DynamicPrintConfig copy_config = volume->config.get();
|
||||
copy_config.parent = &obj_config_wparent;
|
||||
for (std::string key : volume->config.keys()) {
|
||||
// convert to prusa config
|
||||
std::string value = volume->config.opt_serialize(key);
|
||||
volume->config.to_prusa(key, value);
|
||||
copy_config.to_prusa(key, value);
|
||||
if (!key.empty())
|
||||
stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << VOLUME_TYPE << "\" " << KEY_ATTR << "=\"" << key << "\" " << VALUE_ATTR << "=\"" << value << "\"/>\n";
|
||||
}
|
||||
@ -2918,7 +2925,7 @@ namespace Slic3r {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _3MF_Exporter::_add_custom_gcode_per_print_z_file_to_archive( mz_zip_archive& archive, Model& model, const DynamicPrintConfig* config)
|
||||
bool _3MF_Exporter::_add_custom_gcode_per_print_z_file_to_archive( mz_zip_archive& archive, Model& model, const DynamicPrintConfig& config)
|
||||
{
|
||||
std::string out = "";
|
||||
|
||||
@ -2940,9 +2947,9 @@ bool _3MF_Exporter::_add_custom_gcode_per_print_z_file_to_archive( mz_zip_archiv
|
||||
code_tree.put("<xmlattr>.extra" , code.extra );
|
||||
|
||||
// add gcode field data for the old version of the PrusaSlicer
|
||||
std::string gcode = code.type == CustomGCode::ColorChange ? config->opt_string("color_change_gcode") :
|
||||
code.type == CustomGCode::PausePrint ? config->opt_string("pause_print_gcode") :
|
||||
code.type == CustomGCode::Template ? config->opt_string("template_custom_gcode") :
|
||||
std::string gcode = code.type == CustomGCode::ColorChange ? config.opt_string("color_change_gcode") :
|
||||
code.type == CustomGCode::PausePrint ? config.opt_string("pause_print_gcode") :
|
||||
code.type == CustomGCode::Template ? config.opt_string("template_custom_gcode") :
|
||||
code.type == CustomGCode::ToolChange ? "tool_change" : code.extra;
|
||||
code_tree.put("<xmlattr>.gcode" , gcode );
|
||||
}
|
||||
|
@ -5497,101 +5497,123 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
|
||||
}
|
||||
}
|
||||
|
||||
void PrintConfigDef::to_prusa(t_config_option_key& opt_key, std::string& value, const DynamicConfig& all_conf) {
|
||||
|
||||
std::unordered_set<std::string> to_remove_keys = {
|
||||
"thumbnails_color",
|
||||
"thumbnails_custom_color",
|
||||
"thumbnails_with_bed",
|
||||
"thumbnails_with_support",
|
||||
std::unordered_set<std::string> prusa_export_to_remove_keys = {
|
||||
"allow_empty_layers",
|
||||
"avoid_crossing_not_first_layer",
|
||||
"top_fan_speed",
|
||||
"over_bridge_flow_ratio",
|
||||
"bridge_internal_fan_speed",
|
||||
"bridge_overlap",
|
||||
"bridge_speed_internal",
|
||||
"brim_inside_holes",
|
||||
"brim_width_interior",
|
||||
"brim_ears",
|
||||
"bridged_infill_margin",
|
||||
"brim_ears_detection_length",
|
||||
"brim_ears_max_angle",
|
||||
"brim_ears_pattern",
|
||||
"brim_ears",
|
||||
"brim_inside_holes",
|
||||
"brim_offset",
|
||||
"brim_width_interior",
|
||||
"chamber_temperature",
|
||||
"complete_objects_one_skirt",
|
||||
"complete_objects_one_brim",
|
||||
"complete_objects_one_skirt",
|
||||
"complete_objects_sort",
|
||||
"solid_fill_pattern",
|
||||
"curve_smoothing_angle_concave",
|
||||
"curve_smoothing_angle_convex",
|
||||
"curve_smoothing_cutoff_dist",
|
||||
"curve_smoothing_precision",
|
||||
"enforce_full_fill_volume",
|
||||
"exact_last_layer_height",
|
||||
"external_infill_margin",
|
||||
"bridged_infill_margin",
|
||||
"external_perimeter_cut_corners",
|
||||
"external_perimeter_extrusion_spacing",
|
||||
"external_perimeter_fan_speed",
|
||||
"external_perimeter_overlap",
|
||||
"perimeter_overlap",
|
||||
"perimeter_bonding",
|
||||
"external_perimeters_vase",
|
||||
"external_perimeters_nothole",
|
||||
"external_perimeters_hole",
|
||||
"perimeter_loop",
|
||||
"perimeter_loop_seam",
|
||||
"extra_perimeters_overhangs",
|
||||
"external_perimeters_nothole",
|
||||
"external_perimeters_vase",
|
||||
"extra_perimeters_odd_layers",
|
||||
"only_one_perimeter_top",
|
||||
"only_one_perimeter_top_other_algo",
|
||||
"extruder_temperature_offset",
|
||||
"extra_perimeters_overhangs",
|
||||
"extruder_fan_offset",
|
||||
"print_extrusion_multiplier",
|
||||
"extruder_temperature_offset",
|
||||
"extrusion_spacing",
|
||||
"fan_kickstart",
|
||||
"fan_percentage",
|
||||
"fan_speedup_overhangs",
|
||||
"fan_speedup_time",
|
||||
"feature_gcode",
|
||||
"filament_cooling_zone_pause",
|
||||
"filament_dip_extraction_speed",
|
||||
"filament_dip_insertion_speed",
|
||||
"filament_enable_toolchange_part_fan",
|
||||
"filament_enable_toolchange_temp",
|
||||
"filament_max_speed",
|
||||
"filament_max_wipe_tower_speed",
|
||||
"filament_enable_toolchange_temp",
|
||||
"filament_use_fast_skinnydip",
|
||||
"filament_enable_toolchange_part_fan",
|
||||
"filament_toolchange_part_fan_speed",
|
||||
"filament_use_skinnydip",
|
||||
"filament_melt_zone_pause",
|
||||
"filament_cooling_zone_pause",
|
||||
"filament_dip_insertion_speed",
|
||||
"filament_dip_extraction_speed",
|
||||
"filament_toolchange_temp",
|
||||
"filament_skinnydip_distance",
|
||||
"filament_shrink",
|
||||
"filament_skinnydip_distance",
|
||||
"filament_toolchange_part_fan_speed",
|
||||
"filament_toolchange_temp",
|
||||
"filament_use_fast_skinnydip",
|
||||
"filament_use_skinnydip",
|
||||
"filament_wipe_advanced_pigment",
|
||||
"fill_angle_increment",
|
||||
"fill_top_flow_ratio",
|
||||
"fill_top_flow_ratio",
|
||||
"first_layer_flow_ratio",
|
||||
"fill_smooth_width",
|
||||
"fill_smooth_distribution",
|
||||
"fill_smooth_width",
|
||||
"fill_top_flow_ratio",
|
||||
"fill_top_flow_ratio",
|
||||
"first_layer_extrusion_spacing",
|
||||
"first_layer_flow_ratio",
|
||||
"first_layer_infill_speed",
|
||||
"first_layer_min_speed",
|
||||
"gap_fill",
|
||||
"first_layer_size_compensation_layers",
|
||||
"gap_fill_infill",
|
||||
"gap_fill_min_area",
|
||||
"gap_fill_overlap",
|
||||
"gap_fill_infill",
|
||||
"infill_dense",
|
||||
"gap_fill",
|
||||
"hole_size_compensation",
|
||||
"hole_size_threshold",
|
||||
"hole_to_polyhole_threshold",
|
||||
"hole_to_polyhole_twisted",
|
||||
"hole_to_polyhole",
|
||||
"infill_connection",
|
||||
"infill_dense_algo",
|
||||
"feature_gcode",
|
||||
"exact_last_layer_height",
|
||||
"fan_speedup_time",
|
||||
"fan_speedup_overhangs",
|
||||
"fan_percentage",
|
||||
"fan_kickstart",
|
||||
"infill_dense",
|
||||
"infill_extrusion_spacing",
|
||||
"machine_max_acceleration_travel",
|
||||
"max_speed_reduction",
|
||||
"milling_after_z",
|
||||
"milling_cutter",
|
||||
"milling_diameter",
|
||||
"milling_extra_size",
|
||||
"milling_offset",
|
||||
"milling_post_process",
|
||||
"milling_speed",
|
||||
"milling_toolchange_end_gcode",
|
||||
"milling_toolchange_start_gcode",
|
||||
"milling_z_lift",
|
||||
"milling_z_offset",
|
||||
"min_length",
|
||||
"min_width_top_surface",
|
||||
"printhost_apikey",
|
||||
"printhost_cafile",
|
||||
"print_host",
|
||||
"model_precision",
|
||||
"no_perimeter_unsupported_algo",
|
||||
"only_one_perimeter_top_other_algo",
|
||||
"only_one_perimeter_top",
|
||||
"over_bridge_flow_ratio",
|
||||
"overhangs_reverse_threshold",
|
||||
"overhangs_reverse",
|
||||
"overhangs_speed",
|
||||
"overhangs_width_speed",
|
||||
"overhangs_reverse",
|
||||
"overhangs_reverse_threshold",
|
||||
"no_perimeter_unsupported_algo",
|
||||
"support_material_solid_first_layer",
|
||||
"perimeter_bonding",
|
||||
"perimeter_extrusion_spacing",
|
||||
"perimeter_loop_seam",
|
||||
"perimeter_loop",
|
||||
"perimeter_overlap",
|
||||
"perimeter_round_corners",
|
||||
"print_extrusion_multiplier",
|
||||
"print_host",
|
||||
"print_retract_length",
|
||||
"print_retract_lift",
|
||||
"print_temperature",
|
||||
"printhost_apikey",
|
||||
"printhost_cafile",
|
||||
"retract_lift_first_layer",
|
||||
"retract_lift_top",
|
||||
"seam_angle_cost",
|
||||
@ -5599,66 +5621,45 @@ void PrintConfigDef::to_prusa(t_config_option_key& opt_key, std::string& value,
|
||||
"skirt_brim",
|
||||
"skirt_distance_from_brim",
|
||||
"skirt_extrusion_width",
|
||||
"small_perimeter_min_length",
|
||||
"small_perimeter_max_length",
|
||||
"curve_smoothing_angle_convex",
|
||||
"curve_smoothing_angle_concave",
|
||||
"curve_smoothing_precision",
|
||||
"curve_smoothing_cutoff_dist",
|
||||
"model_precision",
|
||||
"support_material_contact_distance_type",
|
||||
"small_perimeter_min_length",
|
||||
"solid_fill_pattern",
|
||||
"solid_infill_extrusion_spacing",
|
||||
"start_gcode_manual",
|
||||
"support_material_contact_distance_bottom",
|
||||
"support_material_contact_distance_type",
|
||||
"support_material_interface_pattern",
|
||||
"print_temperature",
|
||||
"print_retract_lift",
|
||||
"thin_perimeters",
|
||||
"support_material_solid_first_layer",
|
||||
"thin_perimeters_all",
|
||||
"thin_perimeters",
|
||||
"thin_walls_merge",
|
||||
"thin_walls_min_width",
|
||||
"thin_walls_overlap",
|
||||
"thin_walls_merge",
|
||||
"thin_walls_speed",
|
||||
"thumbnails_color",
|
||||
"thumbnails_custom_color",
|
||||
"thumbnails_with_bed",
|
||||
"thumbnails_with_support",
|
||||
"time_estimation_compensation",
|
||||
"tool_name",
|
||||
"wipe_advanced",
|
||||
"wipe_advanced_nozzle_melted_volume",
|
||||
"filament_wipe_advanced_pigment",
|
||||
"wipe_advanced_multiplier",
|
||||
"wipe_advanced_algo",
|
||||
"wipe_tower_brim",
|
||||
"wipe_extra_perimeter",
|
||||
"xy_inner_size_compensation",
|
||||
"hole_size_compensation",
|
||||
"hole_size_threshold",
|
||||
"hole_to_polyhole",
|
||||
"hole_to_polyhole_threshold",
|
||||
"hole_to_polyhole_twisted",
|
||||
"z_step",
|
||||
"milling_cutter",
|
||||
"milling_diameter",
|
||||
"milling_offset",
|
||||
"milling_z_offset",
|
||||
"milling_z_lift",
|
||||
"milling_toolchange_start_gcode",
|
||||
"milling_toolchange_end_gcode",
|
||||
"milling_post_process",
|
||||
"milling_extra_size",
|
||||
"milling_after_z",
|
||||
"milling_speed",
|
||||
"extrusion_spacing",
|
||||
"first_layer_extrusion_spacing",
|
||||
"perimeter_extrusion_spacing",
|
||||
"external_perimeter_extrusion_spacing",
|
||||
"infill_extrusion_spacing",
|
||||
"solid_infill_extrusion_spacing",
|
||||
"top_fan_speed",
|
||||
"top_infill_extrusion_spacing",
|
||||
"start_gcode_manual",
|
||||
"perimeter_round_corners",
|
||||
"travel_speed_z",
|
||||
"first_layer_size_compensation_layers",
|
||||
"travel_acceleration",
|
||||
};
|
||||
"travel_speed_z",
|
||||
"wipe_advanced_algo",
|
||||
"wipe_advanced_multiplier",
|
||||
"wipe_advanced_nozzle_melted_volume",
|
||||
"wipe_advanced",
|
||||
"wipe_extra_perimeter",
|
||||
"wipe_tower_brim",
|
||||
"xy_inner_size_compensation",
|
||||
"z_step",
|
||||
};
|
||||
|
||||
void PrintConfigDef::to_prusa(t_config_option_key& opt_key, std::string& value, const DynamicConfig& all_conf) {
|
||||
|
||||
//looks if it's to be removed, or have to be transformed
|
||||
if (to_remove_keys.find(opt_key) != to_remove_keys.end()) {
|
||||
if (prusa_export_to_remove_keys.find(opt_key) != prusa_export_to_remove_keys.end()) {
|
||||
opt_key = "";
|
||||
value = "";
|
||||
} else if (opt_key.find("_pattern") != std::string::npos) {
|
||||
|
@ -1958,8 +1958,6 @@ public:
|
||||
// Not thread safe! Should not be called from other than the main thread!
|
||||
void touch() { m_timestamp = ++ s_last_timestamp; }
|
||||
|
||||
void to_prusa(t_config_option_key& opt_key, std::string& value) const
|
||||
{ m_data.to_prusa(opt_key, value); }
|
||||
private:
|
||||
friend class cereal::access;
|
||||
template<class Archive> void serialize(Archive& ar) { ar(m_timestamp); ar(m_data); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user