PlaceholderParser on G-code export:
1) added "num_extruders" placeholder 2) changed "is_extruder_used" vector to be always minimum 256 elements long with the non-existent extruder values set to zero. This is wasteful, but necessary until we change the PlaceholderParser handling of vector values to not substitute missing elements with the zero'th value.
This commit is contained in:
parent
f8eb152a5e
commit
8806442f55
@ -1296,8 +1296,12 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
||||
this->placeholder_parser().set("first_layer_print_min", new ConfigOptionFloats({ bbox.min.x(), bbox.min.y() }));
|
||||
this->placeholder_parser().set("first_layer_print_max", new ConfigOptionFloats({ bbox.max.x(), bbox.max.y() }));
|
||||
this->placeholder_parser().set("first_layer_print_size", new ConfigOptionFloats({ bbox.size().x(), bbox.size().y() }));
|
||||
|
||||
std::vector<unsigned char> is_extruder_used(print.config().nozzle_diameter.size(), 0);
|
||||
this->placeholder_parser().set("num_extruders", int(print.config().nozzle_diameter.values.size()));
|
||||
// PlaceholderParser currently substitues non-existent vector values with the zero'th value, which is harmful in the case of "is_extruder_used[]"
|
||||
// as Slicer may lie about availability of such non-existent extruder.
|
||||
// We rather sacrifice 256B of memory before we change the behavior of the PlaceholderParser, which should really only fill in the non-existent
|
||||
// vector elements for filament parameters.
|
||||
std::vector<unsigned char> is_extruder_used(std::max(size_t(255), print.config().nozzle_diameter.size()), 0);
|
||||
for (unsigned int extruder_id : tool_ordering.all_extruders())
|
||||
is_extruder_used[extruder_id] = true;
|
||||
this->placeholder_parser().set("is_extruder_used", new ConfigOptionBools(is_extruder_used));
|
||||
|
@ -1090,6 +1090,7 @@ namespace client
|
||||
|
||||
static void scalar_variable_assign_scalar(const MyContext *ctx, OptWithPos &lhs, const expr &rhs)
|
||||
{
|
||||
assert(! ctx->skipping());
|
||||
assert(lhs.opt->is_scalar());
|
||||
check_writable(ctx, lhs);
|
||||
ConfigOption *wropt = const_cast<ConfigOption*>(lhs.opt);
|
||||
@ -1121,6 +1122,7 @@ namespace client
|
||||
|
||||
static void vector_variable_element_assign_scalar(const MyContext *ctx, OptWithPos &lhs, const expr &rhs)
|
||||
{
|
||||
assert(! ctx->skipping());
|
||||
assert(lhs.opt->is_vector());
|
||||
check_writable(ctx, lhs);
|
||||
if (! lhs.has_index())
|
||||
@ -1158,6 +1160,7 @@ namespace client
|
||||
|
||||
static void vector_variable_assign_expr_with_count(const MyContext *ctx, OptWithPos &lhs, const expr &rhs_count, const expr &rhs_value)
|
||||
{
|
||||
assert(! ctx->skipping());
|
||||
size_t count = evaluate_count(rhs_count);
|
||||
auto *opt = const_cast<ConfigOption*>(lhs.opt);
|
||||
switch (lhs.opt->type()) {
|
||||
|
Loading…
Reference in New Issue
Block a user