mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-08-30 05:17:19 +00:00
FIX: backend get the extruder id based on filament_map
Change-Id: Ib7679c0fc67336e462467dab9f5b4d4684d6eb19 (cherry picked from commit dcd9fd501354da33baea2adc0f645fabe8880cf1)
This commit is contained in:
@@ -20,7 +20,11 @@ Extruder::Extruder(unsigned int id, GCodeConfig *config, bool share_extruder) :
|
|||||||
|
|
||||||
unsigned int Extruder::extruder_id() const
|
unsigned int Extruder::extruder_id() const
|
||||||
{
|
{
|
||||||
return get_extruder_index(m_id);
|
assert(m_config);
|
||||||
|
if (m_id < m_config->filament_map.size()) {
|
||||||
|
return m_config->filament_map.get_at(m_id);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Extruder::extrude(double dE)
|
double Extruder::extrude(double dE)
|
||||||
|
|||||||
@@ -435,7 +435,7 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
|||||||
if (new_filament_id != -1 && new_filament_id != tcr.new_tool)
|
if (new_filament_id != -1 && new_filament_id != tcr.new_tool)
|
||||||
throw Slic3r::InvalidArgument("Error: WipeTowerIntegration::append_tcr was asked to do a toolchange it didn't expect.");
|
throw Slic3r::InvalidArgument("Error: WipeTowerIntegration::append_tcr was asked to do a toolchange it didn't expect.");
|
||||||
|
|
||||||
int new_extruder_id = get_extruder_index(new_filament_id);
|
int new_extruder_id = get_extruder_index(*m_print_config, new_filament_id);
|
||||||
std::string gcode;
|
std::string gcode;
|
||||||
|
|
||||||
// Toolchangeresult.gcode assumes the wipe tower corner is at the origin (except for priming lines)
|
// Toolchangeresult.gcode assumes the wipe tower corner is at the origin (except for priming lines)
|
||||||
@@ -1821,6 +1821,8 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
|||||||
{
|
{
|
||||||
PROFILE_FUNC();
|
PROFILE_FUNC();
|
||||||
|
|
||||||
|
m_print = &print;
|
||||||
|
|
||||||
// modifies m_silent_time_estimator_enabled
|
// modifies m_silent_time_estimator_enabled
|
||||||
DoExport::init_gcode_processor(print.config(), m_processor, m_silent_time_estimator_enabled);
|
DoExport::init_gcode_processor(print.config(), m_processor, m_silent_time_estimator_enabled);
|
||||||
const bool is_bbl_printers = print.is_BBL_printer();
|
const bool is_bbl_printers = print.is_BBL_printer();
|
||||||
@@ -2155,7 +2157,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
|||||||
m_cooling_buffer = make_unique<CoolingBuffer>(*this);
|
m_cooling_buffer = make_unique<CoolingBuffer>(*this);
|
||||||
m_cooling_buffer->set_current_extruder(initial_extruder_id);
|
m_cooling_buffer->set_current_extruder(initial_extruder_id);
|
||||||
|
|
||||||
int extruder_id = get_extruder_index(initial_extruder_id);
|
int extruder_id = get_extruder_id(initial_extruder_id);
|
||||||
|
|
||||||
// Orca: Initialise AdaptivePA processor filter
|
// Orca: Initialise AdaptivePA processor filter
|
||||||
m_pa_processor = std::make_unique<AdaptivePAProcessor>(*this, tool_ordering.all_extruders());
|
m_pa_processor = std::make_unique<AdaptivePAProcessor>(*this, tool_ordering.all_extruders());
|
||||||
@@ -2741,6 +2743,18 @@ void GCode::check_placeholder_parser_failed()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t GCode::get_extruder_id(unsigned int filament_id) const
|
||||||
|
{
|
||||||
|
if (m_print) {
|
||||||
|
std::vector<int> filament_maps = m_print->get_filament_maps();
|
||||||
|
if (filament_id < filament_maps.size()) {
|
||||||
|
return filament_maps[filament_id];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Process all layers of all objects (non-sequential mode) with a parallel pipeline:
|
// Process all layers of all objects (non-sequential mode) with a parallel pipeline:
|
||||||
// Generate G-code, run the filters (vase mode, cooling buffer), run the G-code analyser
|
// Generate G-code, run the filters (vase mode, cooling buffer), run the G-code analyser
|
||||||
// and export G-code into file.
|
// and export G-code into file.
|
||||||
@@ -6370,7 +6384,7 @@ std::string GCode::retract(bool toolchange, bool is_last_retraction, LiftType li
|
|||||||
|
|
||||||
std::string GCode::set_extruder(unsigned int filament_id, double print_z, bool by_object)
|
std::string GCode::set_extruder(unsigned int filament_id, double print_z, bool by_object)
|
||||||
{
|
{
|
||||||
int extruder_id = get_extruder_index(filament_id);
|
int extruder_id = get_extruder_id(filament_id);
|
||||||
if (!m_writer.need_toolchange(filament_id))
|
if (!m_writer.need_toolchange(filament_id))
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ public:
|
|||||||
m_plate_origin(plate_origin),
|
m_plate_origin(plate_origin),
|
||||||
m_single_extruder_multi_material(print_config.single_extruder_multi_material),
|
m_single_extruder_multi_material(print_config.single_extruder_multi_material),
|
||||||
m_enable_timelapse_print(print_config.timelapse_type.value == TimelapseType::tlSmooth),
|
m_enable_timelapse_print(print_config.timelapse_type.value == TimelapseType::tlSmooth),
|
||||||
m_is_first_print(true)
|
m_is_first_print(true),
|
||||||
|
m_print_config(&print_config)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
std::string prime(GCode &gcodegen);
|
std::string prime(GCode &gcodegen);
|
||||||
@@ -136,6 +137,7 @@ private:
|
|||||||
bool m_single_extruder_multi_material;
|
bool m_single_extruder_multi_material;
|
||||||
bool m_enable_timelapse_print;
|
bool m_enable_timelapse_print;
|
||||||
bool m_is_first_print;
|
bool m_is_first_print;
|
||||||
|
const PrintConfig * m_print_config;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ColorPrintColors
|
class ColorPrintColors
|
||||||
@@ -352,6 +354,7 @@ private:
|
|||||||
|
|
||||||
//BBS
|
//BBS
|
||||||
void check_placeholder_parser_failed();
|
void check_placeholder_parser_failed();
|
||||||
|
size_t get_extruder_id(unsigned int filament_id) const;
|
||||||
|
|
||||||
void set_last_pos(const Point &pos) { m_last_pos = pos; m_last_pos_defined = true; }
|
void set_last_pos(const Point &pos) { m_last_pos = pos; m_last_pos_defined = true; }
|
||||||
bool last_pos_defined() const { return m_last_pos_defined; }
|
bool last_pos_defined() const { return m_last_pos_defined; }
|
||||||
@@ -584,6 +587,8 @@ private:
|
|||||||
|
|
||||||
bool m_silent_time_estimator_enabled;
|
bool m_silent_time_estimator_enabled;
|
||||||
|
|
||||||
|
Print *m_print{nullptr};
|
||||||
|
|
||||||
// Processor
|
// Processor
|
||||||
GCodeProcessor m_processor;
|
GCodeProcessor m_processor;
|
||||||
|
|
||||||
|
|||||||
@@ -1057,7 +1057,11 @@ void ToolOrdering::reorder_extruders_for_minimum_flush_volume()
|
|||||||
size_t nozzle_nums = print_config->nozzle_diameter.values.size();
|
size_t nozzle_nums = print_config->nozzle_diameter.values.size();
|
||||||
if (nozzle_nums > 1) {
|
if (nozzle_nums > 1) {
|
||||||
std::vector<int> filament_maps = get_recommended_filament_maps();
|
std::vector<int> filament_maps = get_recommended_filament_maps();
|
||||||
|
if (filament_maps.empty()) // multi-extruder and one-color
|
||||||
|
return;
|
||||||
|
|
||||||
reorder_extruders_for_minimum_flush_volume_multi_extruder(filament_maps);
|
reorder_extruders_for_minimum_flush_volume_multi_extruder(filament_maps);
|
||||||
|
m_print->update_filament_maps_to_config(filament_maps);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -422,6 +422,15 @@ coordf_t Layer::get_sparse_infill_max_void_area()
|
|||||||
return max_void_area;
|
return max_void_area;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t Layer::get_extruder_id(unsigned int filament_id) const
|
||||||
|
{
|
||||||
|
std::vector<int> filament_map = m_object->print()->get_filament_maps();
|
||||||
|
if (filament_id < filament_map.size()) {
|
||||||
|
return filament_map[filament_id];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
BoundingBox get_extents(const LayerRegion &layer_region)
|
BoundingBox get_extents(const LayerRegion &layer_region)
|
||||||
{
|
{
|
||||||
BoundingBox bbox;
|
BoundingBox bbox;
|
||||||
|
|||||||
@@ -241,6 +241,8 @@ public:
|
|||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t get_extruder_id(unsigned int filament_id) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class PrintObject;
|
friend class PrintObject;
|
||||||
friend std::vector<Layer*> new_layers(PrintObject*, const std::vector<coordf_t>&);
|
friend std::vector<Layer*> new_layers(PrintObject*, const std::vector<coordf_t>&);
|
||||||
|
|||||||
@@ -794,7 +794,7 @@ namespace client
|
|||||||
mutable DynamicConfig *config_outputs = nullptr;
|
mutable DynamicConfig *config_outputs = nullptr;
|
||||||
// Local variables, read / write
|
// Local variables, read / write
|
||||||
mutable DynamicConfig config_local;
|
mutable DynamicConfig config_local;
|
||||||
size_t current_extruder_id = 0;
|
size_t current_extruder_id = 0; // This is filament_id actually
|
||||||
// Random number generator and optionally global variables.
|
// Random number generator and optionally global variables.
|
||||||
PlaceholderParser::ContextData *context_data = nullptr;
|
PlaceholderParser::ContextData *context_data = nullptr;
|
||||||
// If false, the macro_processor will evaluate a full macro.
|
// If false, the macro_processor will evaluate a full macro.
|
||||||
@@ -805,7 +805,14 @@ namespace client
|
|||||||
// Table to translate symbol tag to a human readable error message.
|
// Table to translate symbol tag to a human readable error message.
|
||||||
static std::map<std::string, std::string> tag_to_error_message;
|
static std::map<std::string, std::string> tag_to_error_message;
|
||||||
|
|
||||||
// Should the parser consider the parsed string to be a macro or a boolean expression?
|
size_t get_extruder_id() const {
|
||||||
|
const ConfigOptionInts * filament_map_opt = external_config->option<ConfigOptionInts>("filament_map");
|
||||||
|
if (filament_map_opt && current_extruder_id < filament_map_opt->values.size()) {
|
||||||
|
return filament_map_opt->values[current_extruder_id];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static bool evaluate_full_macro(const MyContext *ctx) { return ! ctx->just_boolean_expression; }
|
static bool evaluate_full_macro(const MyContext *ctx) { return ! ctx->just_boolean_expression; }
|
||||||
|
|
||||||
// Entering a conditional block.
|
// Entering a conditional block.
|
||||||
|
|||||||
@@ -2603,6 +2603,15 @@ std::vector<int> Print::get_filament_maps() const
|
|||||||
return m_config.filament_map.values;
|
return m_config.filament_map.values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t Print::get_extruder_id(unsigned int filament_id) const
|
||||||
|
{
|
||||||
|
std::vector<int> filament_map = get_filament_maps();
|
||||||
|
if (filament_id < filament_map.size()) {
|
||||||
|
return filament_map[filament_id];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Wipe tower support.
|
// Wipe tower support.
|
||||||
bool Print::has_wipe_tower() const
|
bool Print::has_wipe_tower() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -936,6 +936,7 @@ public:
|
|||||||
|
|
||||||
void update_filament_maps_to_config(std::vector<int> f_maps);
|
void update_filament_maps_to_config(std::vector<int> f_maps);
|
||||||
std::vector<int> get_filament_maps() const;
|
std::vector<int> get_filament_maps() const;
|
||||||
|
size_t get_extruder_id(unsigned int filament_id) const;
|
||||||
|
|
||||||
bool enable_timelapse_print() const;
|
bool enable_timelapse_print() const;
|
||||||
|
|
||||||
|
|||||||
@@ -53,9 +53,11 @@ namespace Slic3r {
|
|||||||
#define L(s) (s)
|
#define L(s) (s)
|
||||||
#define _(s) Slic3r::I18N::translate(s)
|
#define _(s) Slic3r::I18N::translate(s)
|
||||||
|
|
||||||
size_t get_extruder_index(unsigned int filament_id)
|
size_t get_extruder_index(const GCodeConfig& config, unsigned int filament_id)
|
||||||
{
|
{
|
||||||
// todo multi_extruders:
|
if (filament_id < config.filament_map.size()) {
|
||||||
|
return config.filament_map.get_at(filament_id);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -462,7 +462,6 @@ static std::string get_bed_temp_1st_layer_key(const BedType type)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t get_extruder_index(unsigned int filament_id);
|
|
||||||
#define CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(NAME) \
|
#define CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(NAME) \
|
||||||
template<> const t_config_enum_names& ConfigOptionEnum<NAME>::get_enum_names(); \
|
template<> const t_config_enum_names& ConfigOptionEnum<NAME>::get_enum_names(); \
|
||||||
template<> const t_config_enum_values& ConfigOptionEnum<NAME>::get_enum_values();
|
template<> const t_config_enum_values& ConfigOptionEnum<NAME>::get_enum_values();
|
||||||
@@ -1969,6 +1968,8 @@ static void set_flush_volumes_matrix(std::vector<T> &out_matrix, const std::vect
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t get_extruder_index(const GCodeConfig& config, unsigned int filament_id);
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
||||||
// Serialization through the Cereal library
|
// Serialization through the Cereal library
|
||||||
|
|||||||
@@ -10,8 +10,9 @@ namespace Slic3r {
|
|||||||
float CalibPressureAdvance::find_optimal_PA_speed(const DynamicPrintConfig &config, double line_width, double layer_height, int filament_idx)
|
float CalibPressureAdvance::find_optimal_PA_speed(const DynamicPrintConfig &config, double line_width, double layer_height, int filament_idx)
|
||||||
{
|
{
|
||||||
const double general_suggested_min_speed = 100.0;
|
const double general_suggested_min_speed = 100.0;
|
||||||
double filament_max_volumetric_speed = config.option<ConfigOptionFloats>("filament_max_volumetric_speed")->get_at(0);
|
double filament_max_volumetric_speed = config.option<ConfigOptionFloats>("filament_max_volumetric_speed")->get_at(filament_idx);
|
||||||
const float nozzle_diameter = config.option<ConfigOptionFloats>("nozzle_diameter")->get_at(0);
|
// todo multi_extruders:
|
||||||
|
const float nozzle_diameter = config.option<ConfigOptionFloats>("nozzle_diameter")->get_at(0/*get_extruder_index(filament_idx)*/);
|
||||||
if (line_width <= 0.) line_width = Flow::auto_extrusion_width(frPerimeter, nozzle_diameter);
|
if (line_width <= 0.) line_width = Flow::auto_extrusion_width(frPerimeter, nozzle_diameter);
|
||||||
Flow pattern_line = Flow(line_width, layer_height, nozzle_diameter);
|
Flow pattern_line = Flow(line_width, layer_height, nozzle_diameter);
|
||||||
auto pa_speed = std::min(std::max(general_suggested_min_speed, config.option<ConfigOptionFloat>("outer_wall_speed")->value),
|
auto pa_speed = std::min(std::max(general_suggested_min_speed, config.option<ConfigOptionFloat>("outer_wall_speed")->value),
|
||||||
|
|||||||
@@ -303,6 +303,7 @@ public:
|
|||||||
Vec3d get_start_offset();
|
Vec3d get_start_offset();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
// todo multi_extruders:
|
||||||
double speed_first_layer() const { return m_config.option<ConfigOptionFloat>("initial_layer_speed")->value; };
|
double speed_first_layer() const { return m_config.option<ConfigOptionFloat>("initial_layer_speed")->value; };
|
||||||
double speed_perimeter() const { return m_config.option<ConfigOptionFloat>("outer_wall_speed")->value; };
|
double speed_perimeter() const { return m_config.option<ConfigOptionFloat>("outer_wall_speed")->value; };
|
||||||
double accel_perimeter() const { return m_config.option<ConfigOptionFloat>("outer_wall_acceleration")->value; }
|
double accel_perimeter() const { return m_config.option<ConfigOptionFloat>("outer_wall_acceleration")->value; }
|
||||||
|
|||||||
@@ -48,12 +48,14 @@ int get_extruder_idx(const DynamicPrintConfig& config, const std::string &opt_ke
|
|||||||
NozzleVolumeType nozzle_volume_type = (NozzleVolumeType) (opt_nozzle_volume_type->get_at(cur_extruder_id));
|
NozzleVolumeType nozzle_volume_type = (NozzleVolumeType) (opt_nozzle_volume_type->get_at(cur_extruder_id));
|
||||||
|
|
||||||
std::string id_name, variant_name;
|
std::string id_name, variant_name;
|
||||||
|
unsigned int stride = 1;
|
||||||
if (printer_options_with_variant_1.count(opt_key) > 0) { // printer parameter
|
if (printer_options_with_variant_1.count(opt_key) > 0) { // printer parameter
|
||||||
id_name = "printer_extruder_id";
|
id_name = "printer_extruder_id";
|
||||||
variant_name = "printer_extruder_variant";
|
variant_name = "printer_extruder_variant";
|
||||||
} else if (printer_options_with_variant_2.count(opt_key) > 0) {
|
} else if (printer_options_with_variant_2.count(opt_key) > 0) {
|
||||||
id_name = "printer_extruder_id";
|
id_name = "printer_extruder_id";
|
||||||
variant_name = "printer_extruder_variant";
|
variant_name = "printer_extruder_variant";
|
||||||
|
stride = 2;
|
||||||
} else if (filament_options_with_variant.count(opt_key) > 0) {
|
} else if (filament_options_with_variant.count(opt_key) > 0) {
|
||||||
//filament don't use id anymore
|
//filament don't use id anymore
|
||||||
//id_name = "filament_extruder_id";
|
//id_name = "filament_extruder_id";
|
||||||
@@ -66,7 +68,7 @@ int get_extruder_idx(const DynamicPrintConfig& config, const std::string &opt_ke
|
|||||||
}
|
}
|
||||||
|
|
||||||
// variant index
|
// variant index
|
||||||
int variant_index = config.get_index_for_extruder(cur_extruder_id + 1, id_name, extruder_type, nozzle_volume_type, variant_name);
|
int variant_index = config.get_index_for_extruder(cur_extruder_id + 1, id_name, extruder_type, nozzle_volume_type, variant_name, stride);
|
||||||
if (variant_index < 0) {
|
if (variant_index < 0) {
|
||||||
assert(false);
|
assert(false);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user