Custom print, printer & filament variables

supermerill/SuperSlicer#481
This commit is contained in:
supermerill 2021-11-07 04:42:02 +01:00
parent 4e266a5806
commit 9393126b4f
12 changed files with 300 additions and 34 deletions

View File

@ -94,6 +94,8 @@ group:no_title:End G-code
page:Notes:note.png page:Notes:note.png
group:label_width$0:Notes group:label_width$0:Notes
setting:full_width:height$25:filament_notes setting:full_width:height$25:filament_notes
group:label_width$0:Custom variables
setting:full_width:height$15:filament_custom_variables
page:Dependencies:wrench.png page:Dependencies:wrench.png
group:Profile dependencies group:Profile dependencies

View File

@ -384,6 +384,8 @@ group:Post-processing script
page:Notes:note page:Notes:note
group:no_title:Notes group:no_title:Notes
setting:full_width:height$25:notes setting:full_width:height$25:notes
group:no_title:Custom variables
setting:full_width:height$15:print_custom_variables
page:Dependencies:wrench page:Dependencies:wrench
group:Profile dependencies group:Profile dependencies

View File

@ -83,6 +83,8 @@ height:0
page:Notes:note.png page:Notes:note.png
group:no_title:Notes group:no_title:Notes
setting:full_width:height$25:printer_notes setting:full_width:height$25:printer_notes
group:no_title:Custom variables
setting:full_width:height$15:printer_custom_variables
page:Dependencies:wrench.png page:Dependencies:wrench.png
group:Profile dependencies group:Profile dependencies

View File

@ -664,6 +664,15 @@ bool ConfigBase::set_deserialize_raw(const t_config_option_key &opt_key_src, con
return success; return success;
} }
const ConfigOptionDef* ConfigBase::get_option_def(const t_config_option_key& opt_key) const {
// Get option definition.
const ConfigDef* def = this->def();
if (def == nullptr)
throw NoDefinitionException(opt_key);
const ConfigOptionDef* opt_def = def->get(opt_key);
return opt_def;
}
// Return an absolute value of a possibly relative config variable. // Return an absolute value of a possibly relative config variable.
// For example, return absolute infill extrusion width, either from an absolute value, or relative to the layer height. // For example, return absolute infill extrusion width, either from an absolute value, or relative to the layer height.
double ConfigBase::get_computed_value(const t_config_option_key &opt_key, int extruder_id) const double ConfigBase::get_computed_value(const t_config_option_key &opt_key, int extruder_id) const
@ -674,12 +683,6 @@ double ConfigBase::get_computed_value(const t_config_option_key &opt_key, int ex
std::stringstream ss; ss << "You can't define an option that need " << opt_key << " without defining it!"; std::stringstream ss; ss << "You can't define an option that need " << opt_key << " without defining it!";
throw std::runtime_error(ss.str()); throw std::runtime_error(ss.str());
} }
// Get option definition.
const ConfigDef* def = this->def();
if (def == nullptr)
throw NoDefinitionException(opt_key);
const ConfigOptionDef* opt_def = def->get(opt_key);
assert(opt_def != nullptr);
if (!raw_opt->is_vector()) { if (!raw_opt->is_vector()) {
if (raw_opt->type() == coFloat) if (raw_opt->type() == coFloat)
@ -697,19 +700,20 @@ double ConfigBase::get_computed_value(const t_config_option_key &opt_key, int ex
if (raw_opt->type() == coPercent) { if (raw_opt->type() == coPercent) {
cast_opt = static_cast<const ConfigOptionPercent*>(raw_opt); cast_opt = static_cast<const ConfigOptionPercent*>(raw_opt);
} }
if (opt_def != nullptr) { const ConfigOptionDef* opt_def = get_option_def(opt_key);
//if over no other key, it's most probably a simple % if (opt_def == nullptr) // maybe a placeholder?
if (opt_def->ratio_over == "") return cast_opt->get_abs_value(1);
return cast_opt->get_abs_value(1); //if over no other key, it's most probably a simple %
// Compute absolute value over the absolute value of the base option. if (opt_def->ratio_over == "")
//FIXME there are some ratio_over chains, which end with empty ratio_with. return cast_opt->get_abs_value(1);
// For example, XXX_extrusion_width parameters are not handled by get_abs_value correctly. // Compute absolute value over the absolute value of the base option.
if (!opt_def->ratio_over.empty() && opt_def->ratio_over != "depends") //FIXME there are some ratio_over chains, which end with empty ratio_with.
return cast_opt->get_abs_value(this->get_computed_value(opt_def->ratio_over)); // For example, XXX_extrusion_width parameters are not handled by get_abs_value correctly.
if (!opt_def->ratio_over.empty() && opt_def->ratio_over != "depends")
return cast_opt->get_abs_value(this->get_computed_value(opt_def->ratio_over));
std::stringstream ss; ss << "ConfigBase::get_abs_value(): " << opt_key << " has no valid ratio_over to compute of"; std::stringstream ss; ss << "ConfigBase::get_abs_value(): " << opt_key << " has no valid ratio_over to compute of";
throw ConfigurationError(ss.str()); throw ConfigurationError(ss.str());
}
} else { } else {
// check if it's an extruder_id array // check if it's an extruder_id array
const ConfigOptionVectorBase* vector_opt = static_cast<const ConfigOptionVectorBase*>(raw_opt); const ConfigOptionVectorBase* vector_opt = static_cast<const ConfigOptionVectorBase*>(raw_opt);
@ -741,6 +745,9 @@ double ConfigBase::get_computed_value(const t_config_option_key &opt_key, int ex
if (!opt_fl_per->values[idx].percent) if (!opt_fl_per->values[idx].percent)
return opt_fl_per->values[idx].value; return opt_fl_per->values[idx].value;
const ConfigOptionDef* opt_def = get_option_def(opt_key);
if (opt_def == nullptr) // maybe a placeholder?
return opt_fl_per->get_abs_value(extruder_id, 1);
if (opt_def->ratio_over.empty()) if (opt_def->ratio_over.empty())
return opt_fl_per->get_abs_value(idx, 1); return opt_fl_per->get_abs_value(idx, 1);
if (opt_def->ratio_over != "depends") if (opt_def->ratio_over != "depends")
@ -750,6 +757,9 @@ double ConfigBase::get_computed_value(const t_config_option_key &opt_key, int ex
} }
if (raw_opt->type() == coPercents) { if (raw_opt->type() == coPercents) {
const ConfigOptionPercents* opt_per = static_cast<const ConfigOptionPercents*>(raw_opt); const ConfigOptionPercents* opt_per = static_cast<const ConfigOptionPercents*>(raw_opt);
const ConfigOptionDef* opt_def = get_option_def(opt_key);
if (opt_def == nullptr) // maybe a placeholder?
return opt_per->get_abs_value(extruder_id, 1);
if (opt_def->ratio_over.empty()) if (opt_def->ratio_over.empty())
return opt_per->get_abs_value(idx, 1); return opt_per->get_abs_value(idx, 1);
if (opt_def->ratio_over != "depends") if (opt_def->ratio_over != "depends")

View File

@ -2084,6 +2084,7 @@ public:
void set_deserialize_strict(std::initializer_list<SetDeserializeItem> items) void set_deserialize_strict(std::initializer_list<SetDeserializeItem> items)
{ ConfigSubstitutionContext ctxt{ ForwardCompatibilitySubstitutionRule::Disable }; this->set_deserialize(items, ctxt); } { ConfigSubstitutionContext ctxt{ ForwardCompatibilitySubstitutionRule::Disable }; this->set_deserialize(items, ctxt); }
const ConfigOptionDef* get_option_def(const t_config_option_key& opt_key) const;
double get_computed_value(const t_config_option_key &opt_key, int extruder_id = -1) const; double get_computed_value(const t_config_option_key &opt_key, int extruder_id = -1) const;
double get_abs_value(const t_config_option_key &opt_key, double ratio_over) const; double get_abs_value(const t_config_option_key &opt_key, double ratio_over) const;
void setenv_() const; void setenv_() const;

View File

@ -18,6 +18,7 @@
#include <cstdlib> #include <cstdlib>
#include <math.h> #include <math.h>
#include <string_view> #include <string_view>
#include <map>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/find.hpp> #include <boost/algorithm/string/find.hpp>
@ -1107,7 +1108,6 @@ void GCode::_init_multiextruders(FILE *file, Print &print, GCodeWriter & writer,
} }
} }
void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thumbnail_cb) void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thumbnail_cb)
{ {
PROFILE_FUNC(); PROFILE_FUNC();
@ -1359,6 +1359,10 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu
// Emit machine envelope limits for the Marlin firmware. // Emit machine envelope limits for the Marlin firmware.
this->print_machine_envelope(file, print); this->print_machine_envelope(file, print);
//add variables from filament_custom_variables
m_placeholder_parser.parse_custom_variables(m_config.print_custom_variables);
m_placeholder_parser.parse_custom_variables(m_config.printer_custom_variables);
m_placeholder_parser.parse_custom_variables(m_config.filament_custom_variables);
// Let the start-up script prime the 1st printing tool. // Let the start-up script prime the 1st printing tool.
m_placeholder_parser.set("initial_tool", initial_extruder_id); m_placeholder_parser.set("initial_tool", initial_extruder_id);

View File

@ -836,9 +836,10 @@ namespace client
expr<Iterator> &output) expr<Iterator> &output)
{ {
std::string opt_key(opt.it_range.begin(), opt.it_range.end()); std::string opt_key(opt.it_range.begin(), opt.it_range.end());
const ConfigOptionVectorBase* vector_opt = nullptr;
if (opt.opt->is_vector()) { if (opt.opt->is_vector()) {
const ConfigOptionDef* opt_def = print_config_def.get(opt_key); vector_opt = static_cast<const ConfigOptionVectorBase*>(opt.opt);
if (!opt_def->is_vector_extruder) if (!vector_opt->is_extruder_size())
ctx->throw_exception("Referencing a vector variable when scalar is expected", opt.it_range); ctx->throw_exception("Referencing a vector variable when scalar is expected", opt.it_range);
} }
const ConfigOptionDef* opt_def; const ConfigOptionDef* opt_def;
@ -898,29 +899,29 @@ namespace client
ctx->throw_exception("Unknown scalar variable type", opt.it_range); ctx->throw_exception("Unknown scalar variable type", opt.it_range);
case coFloats: case coFloats:
case coPercents: case coPercents:
opt_def = print_config_def.get(opt_key); vector_opt = static_cast<const ConfigOptionVectorBase*>(opt.opt);
if (opt_def->is_vector_extruder) { if (vector_opt->is_extruder_size()) {
output.set_d(((ConfigOptionVectorBase*)opt.opt)->getFloat(ctx->current_extruder_id)); output.set_d(((ConfigOptionVectorBase*)opt.opt)->getFloat(ctx->current_extruder_id));
break; break;
} else } else
ctx->throw_exception("Unknown scalar variable type", opt.it_range); ctx->throw_exception("Unknown scalar variable type", opt.it_range);
case coFloatsOrPercents: case coFloatsOrPercents:
opt_def = print_config_def.get(opt_key); vector_opt = static_cast<const ConfigOptionVectorBase*>(opt.opt);
if (opt_def->is_vector_extruder) { if (vector_opt->is_extruder_size()) {
output.set_d(ctx->get_computed_value(opt_key)); output.set_d(ctx->get_computed_value(opt_key));
break; break;
} else } else
ctx->throw_exception("Unknown scalar variable type", opt.it_range); ctx->throw_exception("Unknown scalar variable type", opt.it_range);
case coStrings: case coStrings:
opt_def = print_config_def.get(opt_key); vector_opt = static_cast<const ConfigOptionVectorBase*>(opt.opt);
if (opt_def->is_vector_extruder) { if (vector_opt->is_extruder_size()) {
output.set_s(((ConfigOptionStrings*)opt.opt)->values[ctx->current_extruder_id]); output.set_s(((ConfigOptionStrings*)opt.opt)->values[ctx->current_extruder_id]);
break; break;
} else } else
ctx->throw_exception("Unknown scalar variable type", opt.it_range); ctx->throw_exception("Unknown scalar variable type", opt.it_range);
case coPoints: case coPoints:
opt_def = print_config_def.get(opt_key); vector_opt = static_cast<const ConfigOptionVectorBase*>(opt.opt);
if (opt_def->is_vector_extruder) { if (vector_opt->is_extruder_size()) {
output.set_s(to_string(((ConfigOptionPoints*)opt.opt)->values[ctx->current_extruder_id])); output.set_s(to_string(((ConfigOptionPoints*)opt.opt)->values[ctx->current_extruder_id]));
break; break;
}else }else
@ -1493,4 +1494,166 @@ bool PlaceholderParser::evaluate_boolean_expression(const std::string &templ, co
return process_macro(templ, context) == "true"; return process_macro(templ, context) == "true";
} }
void PlaceholderParser::append_custom_variables(std::map<std::string, std::vector<std::string>> name2var_array, int nb_extruders) {
std::regex is_a_name("[a-zA-Z_]+");
for (const auto& entry : name2var_array) {
if (entry.first.empty())
continue;
if (!std::regex_match(entry.first, is_a_name))
continue;
const std::vector<std::string>& values = entry.second;
//check if all values are empty
bool is_not_string = false;
for (int extruder_id = 0; extruder_id < nb_extruders; ++extruder_id) {
if (!values[extruder_id].empty()) {
is_not_string = true;
break;
}
}
std::vector<std::string> string_values;
//check if all values are strings
if (is_not_string) {
is_not_string = false;
for (int extruder_id = 0; extruder_id < nb_extruders; ++extruder_id) {
if (!values[extruder_id].empty()) {
if (values[extruder_id].front() != '\"' && values[extruder_id].back() != '\"') {
is_not_string = true;
break;
}
string_values.push_back(values[extruder_id].substr(1, values[extruder_id].size() - 2));
} else {
string_values.push_back("");
}
}
}
//check if all values are bools
bool is_not_bool = !is_not_string;
std::vector<unsigned char> bool_values;
if (!is_not_bool) {
for (int extruder_id = 0; extruder_id < nb_extruders; ++extruder_id) {
if (!values[extruder_id].empty()) {
if (boost::algorithm::to_lower_copy(values[extruder_id]) == "true") {
bool_values.push_back(true);
} else if (boost::algorithm::to_lower_copy(values[extruder_id]) == "false") {
bool_values.push_back(false);
} else {
is_not_bool = true;
break;
}
} else {
bool_values.push_back(false);
}
}
}
//check if all values are numeric
bool is_not_numeric = !is_not_string || !is_not_bool;
std::vector<double> double_values;
//std::regex("\\s*[+-]?([0-9]+\\.[0-9]*([Ee][+-]?[0-9]+)?|\\.[0-9]+([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)");
if (!is_not_numeric) {
for (int extruder_id = 0; extruder_id < nb_extruders; ++extruder_id) {
if (!values[extruder_id].empty()) {
try {
double_values.push_back(boost::lexical_cast<float>(values[extruder_id]));
}
catch (boost::bad_lexical_cast&) {
is_not_numeric = true;
break;
}
} else {
double_values.push_back(0);
}
}
}
//if nothing, then it's strings
if (is_not_string && is_not_numeric && is_not_bool) {
string_values = values;
is_not_string = false;
}
if (!is_not_numeric) {
std::stringstream log;
log << "Parsing NUM custom variable '" << entry.first << "' : ";
for (auto s : double_values) log << ", " << s;
BOOST_LOG_TRIVIAL(trace) << log.str();
ConfigOptionFloats* conf = new ConfigOptionFloats(double_values);
conf->set_is_extruder_size(true);
this->set(entry.first, conf);
} else if (!is_not_bool) {
std::stringstream log;
log << "Parsing BOOL custom variable '" << entry.first << "' : ";
for (auto s : bool_values) log << ", " << s;
BOOST_LOG_TRIVIAL(trace) << log.str();
ConfigOptionBools* conf = new ConfigOptionBools(bool_values);
conf->set_is_extruder_size(true);
this->set(entry.first, conf);
} else {
for (std::string& s : string_values)
boost::replace_all(s, "\\n", "\n");
std::stringstream log;
log << "Parsing STR custom variable '" << entry.first << "' : ";
for (auto s : string_values) log << ", " << s;
BOOST_LOG_TRIVIAL(trace) << log.str();
ConfigOptionStrings* conf = new ConfigOptionStrings(string_values);
conf->set_is_extruder_size(true);
this->set(entry.first, conf);
}
}
}
void PlaceholderParser::parse_custom_variables(const ConfigOptionString& custom_variables) {
std::map<std::string, std::vector<std::string>> name2var_array;
std::string raw_text = custom_variables.value;
boost::erase_all(raw_text, "\r");
std::vector<std::string> lines;
boost::algorithm::split(lines, raw_text, boost::is_any_of("\n"));
for (const std::string& line : lines) {
int equal_pos = line.find_first_of('=');
if (equal_pos != std::string::npos) {
std::string name = line.substr(0, equal_pos);
std::string value = line.substr(equal_pos + 1);
boost::algorithm::trim(name);
boost::algorithm::trim(value);
if (name2var_array.find(name) == name2var_array.end()) {
name2var_array.emplace(name, std::vector<std::string>{ 1, value });
} else
name2var_array[name][0] = value;
}
}
append_custom_variables(name2var_array, 1);
}
void PlaceholderParser::parse_custom_variables(const ConfigOptionStrings& filament_custom_variables)
{
std::map<std::string, std::vector<std::string>> name2var_array;
const std::vector<std::string> empty_array(filament_custom_variables.values.size());
for (int extruder_id = 0; extruder_id < filament_custom_variables.values.size(); ++extruder_id)
{
std::string raw_text = filament_custom_variables.values[extruder_id];
boost::erase_all(raw_text, "\r");
std::vector<std::string> lines;
boost::algorithm::split(lines, raw_text, boost::is_any_of("\n"));
for (const std::string& line : lines) {
int equal_pos = line.find_first_of('=');
if (equal_pos != std::string::npos) {
std::string name = line.substr(0, equal_pos);
std::string value = line.substr(equal_pos + 1);
boost::algorithm::trim(name);
boost::algorithm::trim(value);
if (name2var_array.find(name) == name2var_array.end()) {
name2var_array.emplace(name, empty_array);
}
name2var_array[name][extruder_id] = value;
}
}
}
append_custom_variables(name2var_array, filament_custom_variables.values.size());
}
} }

View File

@ -62,7 +62,14 @@ public:
// Update timestamp, year, month, day, hour, minute, second variables at m_config. // Update timestamp, year, month, day, hour, minute, second variables at m_config.
void update_timestamp() { update_timestamp(m_config); } void update_timestamp() { update_timestamp(m_config); }
// set custom variables
void parse_custom_variables(const ConfigOptionString& custom_variables);
void parse_custom_variables(const ConfigOptionStrings& filament_custom_variables);
private: private:
void append_custom_variables(std::map<std::string, std::vector<std::string>> name2var_array, int nb_extruders);
// config has a higher priority than external_config when looking up a symbol. // config has a higher priority than external_config when looking up a symbol.
DynamicConfig m_config; DynamicConfig m_config;
const DynamicConfig *m_external_config; const DynamicConfig *m_external_config;

View File

@ -555,7 +555,10 @@ const std::vector<std::string>& Preset::print_options()
"support_material_contact_distance_type", "support_material_contact_distance_type",
"support_material_contact_distance_top", "support_material_contact_distance_top",
"support_material_contact_distance_bottom", "support_material_contact_distance_bottom",
"support_material_buildplate_only", "dont_support_bridges", "notes", "support_material_buildplate_only", "dont_support_bridges",
// miscellaneous
"notes",
"print_custom_variables",
"complete_objects", "complete_objects",
"complete_objects_one_skirt", "complete_objects_one_skirt",
"complete_objects_one_brim", "complete_objects_one_brim",
@ -650,7 +653,9 @@ const std::vector<std::string>& Preset::print_options()
const std::vector<std::string>& Preset::filament_options() const std::vector<std::string>& Preset::filament_options()
{ {
static std::vector<std::string> s_opts { static std::vector<std::string> s_opts {
"filament_colour", "filament_diameter", "filament_type", "filament_soluble", "filament_notes", "filament_colour",
"filament_custom_variables",
"filament_diameter", "filament_type", "filament_soluble", "filament_notes",
"filament_max_speed", "filament_max_speed",
"filament_max_volumetric_speed", "filament_max_volumetric_speed",
"filament_max_wipe_tower_speed", "filament_max_wipe_tower_speed",
@ -741,14 +746,23 @@ const std::vector<std::string>& Preset::printer_options()
//FIXME the print host keys are left here just for conversion from the Printer preset to Physical Printer preset. //FIXME the print host keys are left here just for conversion from the Printer preset to Physical Printer preset.
"host_type", "print_host", "printhost_apikey", "printhost_cafile", "printhost_port", "host_type", "print_host", "printhost_apikey", "printhost_cafile", "printhost_port",
"single_extruder_multi_material", "single_extruder_multi_material",
// custom gcode
"start_gcode", "start_gcode",
"start_gcode_manual", "start_gcode_manual",
"end_gcode", "end_gcode",
"before_layer_gcode", "before_layer_gcode",
"layer_gcode", "layer_gcode",
"toolchange_gcode", "toolchange_gcode",
"color_change_gcode", "pause_print_gcode", "template_custom_gcode", "feature_gcode", "color_change_gcode", "pause_print_gcode", "template_custom_gcode","feature_gcode",
"between_objects_gcode", "printer_vendor", "printer_model", "printer_variant", "printer_notes", "cooling_tube_retraction", "between_objects_gcode",
//printer fields
"printer_custom_variables",
"printer_vendor",
"printer_model",
"printer_variant",
"printer_notes",
// mmu
"cooling_tube_retraction",
"cooling_tube_length", "high_current_on_filament_swap", "parking_pos_retraction", "extra_loading_move", "max_print_height", "cooling_tube_length", "high_current_on_filament_swap", "parking_pos_retraction", "extra_loading_move", "max_print_height",
"default_print_profile", "inherits", "default_print_profile", "inherits",
"remaining_times", "remaining_times",
@ -884,7 +898,7 @@ const std::vector<std::string>& Preset::sla_printer_options()
"min_initial_exposure_time", "max_initial_exposure_time", "min_initial_exposure_time", "max_initial_exposure_time",
//FIXME the print host keys are left here just for conversion from the Printer preset to Physical Printer preset. //FIXME the print host keys are left here just for conversion from the Printer preset to Physical Printer preset.
"print_host", "printhost_apikey", "printhost_cafile", "printhost_port", "print_host", "printhost_apikey", "printhost_cafile", "printhost_port",
"printer_notes", "printer_custom_variables",
"inherits", "inherits",
"thumbnails", "thumbnails",
"thumbnails_color", "thumbnails_color",

View File

@ -108,6 +108,7 @@ bool Print::invalidate_state_by_config_options(const std::vector<t_config_option
"fan_speedup_time", "fan_speedup_time",
"fan_percentage", "fan_percentage",
"filament_colour", "filament_colour",
"filament_custom_variables",
"filament_diameter", "filament_diameter",
"filament_density", "filament_density",
"filament_notes", "filament_notes",

View File

@ -1305,6 +1305,26 @@ void PrintConfigDef::init_fff_params()
def->is_vector_extruder = true; def->is_vector_extruder = true;
def->set_default_value(new ConfigOptionStrings{ "#29B2B2" }); def->set_default_value(new ConfigOptionStrings{ "#29B2B2" });
def = this->add("filament_custom_variables", coStrings);
def->label = L("Custom variables");
def->full_label = L("Filament custom variables");
def->category = OptionCategory::filament;
def->tooltip = L("You can add data accessible to custom-gcode macros."
"\nEach line can define one variable."
"\nThe format is 'variable_name=value'. the variabel name should only have [a-zA-Z] characters or '_'."
"\nA value that can be parsed as a int or float will be avaible as a numeric value."
"\nA value that is enclosed by double-quotes will be available as a string (without the quotes)"
"\nA value that only takes values as 'true' or 'false' will be a boolean)"
"\nEvery other value will be parsed as a string as-is."
"\nThese varibles will be available as an array in the custom gcode (one item per extruder), don't forget to use them with the [current_extruder] index to get the current value."
" If a filament has a typo on the variable that change its type, then the parser will convert evrything to strings.");
def->multiline = true;
def->full_width = true;
def->height = 13;
def->mode = comAdvanced;
def->is_vector_extruder = true;
def->set_default_value(new ConfigOptionStrings{ "" });
def = this->add("filament_notes", coStrings); def = this->add("filament_notes", coStrings);
def->label = L("Filament notes"); def->label = L("Filament notes");
def->category = OptionCategory::notes; def->category = OptionCategory::notes;
@ -2982,6 +3002,23 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionString("")); def->set_default_value(new ConfigOptionString(""));
def = this->add("print_custom_variables", coString);
def->label = L("Custom variables");
def->full_label = L("Print custom variables");
def->category = OptionCategory::filament;
def->tooltip = L("You can add data accessible to custom-gcode macros."
"\nEach line can define one variable."
"\nThe format is 'variable_name=value'. the variabel name should only have [a-zA-Z] characters or '_'."
"\nA value that can be parsed as a int or float will be avaible as a numeric value."
"\nA value that is enclosed by double-quotes will be available as a string (without the quotes)"
"\nA value that only takes values as 'true' or 'false' will be a boolean)"
"\nEvery other value will be parsed as a string as-is.");
def->multiline = true;
def->full_width = true;
def->height = 13;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionString{ "" });
def = this->add("print_host", coString); def = this->add("print_host", coString);
def->label = L("Hostname, IP or URL"); def->label = L("Hostname, IP or URL");
def->category = OptionCategory::general; def->category = OptionCategory::general;
@ -3223,6 +3260,23 @@ void PrintConfigDef::init_fff_params()
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionStrings()); def->set_default_value(new ConfigOptionStrings());
def = this->add("printer_custom_variables", coString);
def->label = L("Custom variables");
def->full_label = L("Printer custom variables");
def->category = OptionCategory::filament;
def->tooltip = L("You can add data accessible to custom-gcode macros."
"\nEach line can define one variable."
"\nThe format is 'variable_name=value'. the variabel name should only have [a-zA-Z] characters or '_'."
"\nA value that can be parsed as a int or float will be avaible as a numeric value."
"\nA value that is enclosed by double-quotes will be available as a string (without the quotes)"
"\nA value that only takes values as 'true' or 'false' will be a boolean)"
"\nEvery other value will be parsed as a string as-is.");
def->multiline = true;
def->full_width = true;
def->height = 13;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionString{ "" });
def = this->add("printer_model", coString); def = this->add("printer_model", coString);
def->label = L("Printer type"); def->label = L("Printer type");
def->tooltip = L("Type of the printer."); def->tooltip = L("Type of the printer.");

View File

@ -1330,6 +1330,7 @@ public:
ConfigOptionBools fan_always_on; ConfigOptionBools fan_always_on;
ConfigOptionInts fan_below_layer_time; ConfigOptionInts fan_below_layer_time;
ConfigOptionStrings filament_colour; ConfigOptionStrings filament_colour;
ConfigOptionStrings filament_custom_variables;
ConfigOptionStrings filament_notes; ConfigOptionStrings filament_notes;
ConfigOptionPercents filament_max_overlap; ConfigOptionPercents filament_max_overlap;
ConfigOptionPercents filament_shrink; ConfigOptionPercents filament_shrink;
@ -1363,6 +1364,8 @@ public:
ConfigOptionString output_filename_format; ConfigOptionString output_filename_format;
ConfigOptionFloatOrPercent perimeter_acceleration; ConfigOptionFloatOrPercent perimeter_acceleration;
ConfigOptionStrings post_process; ConfigOptionStrings post_process;
ConfigOptionString print_custom_variables;
ConfigOptionString printer_custom_variables;
ConfigOptionString printer_model; ConfigOptionString printer_model;
ConfigOptionString printer_notes; ConfigOptionString printer_notes;
ConfigOptionFloat resolution; ConfigOptionFloat resolution;
@ -1435,6 +1438,7 @@ protected:
OPT_PTR(fan_always_on); OPT_PTR(fan_always_on);
OPT_PTR(fan_below_layer_time); OPT_PTR(fan_below_layer_time);
OPT_PTR(filament_colour); OPT_PTR(filament_colour);
OPT_PTR(filament_custom_variables);
OPT_PTR(filament_notes); OPT_PTR(filament_notes);
OPT_PTR(filament_max_overlap); OPT_PTR(filament_max_overlap);
OPT_PTR(filament_shrink); OPT_PTR(filament_shrink);
@ -1468,6 +1472,8 @@ protected:
OPT_PTR(output_filename_format); OPT_PTR(output_filename_format);
OPT_PTR(perimeter_acceleration); OPT_PTR(perimeter_acceleration);
OPT_PTR(post_process); OPT_PTR(post_process);
OPT_PTR(print_custom_variables);
OPT_PTR(printer_custom_variables);
OPT_PTR(printer_model); OPT_PTR(printer_model);
OPT_PTR(printer_notes); OPT_PTR(printer_notes);
OPT_PTR(resolution); OPT_PTR(resolution);