mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-09 07:56:24 -06:00
layer count issue fixed
This commit is contained in:
parent
644742133e
commit
a89a354c31
7 changed files with 52 additions and 24 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "Anycubic",
|
"name": "Anycubic",
|
||||||
"version": "01.02.00.03",
|
"version": "01.02.00.04",
|
||||||
"force_update": "0",
|
"force_update": "0",
|
||||||
"description": "Anycubic configurations",
|
"description": "Anycubic configurations",
|
||||||
"machine_model_list": [
|
"machine_model_list": [
|
||||||
|
|
|
@ -130,7 +130,7 @@
|
||||||
"single_extruder_multi_material": "1",
|
"single_extruder_multi_material": "1",
|
||||||
"change_filament_gcode": "",
|
"change_filament_gcode": "",
|
||||||
"before_layer_change_gcode": ";BEFORE_LAYER_CHANGE\n;[layer_z]\nG92 E0\n",
|
"before_layer_change_gcode": ";BEFORE_LAYER_CHANGE\n;[layer_z]\nG92 E0\n",
|
||||||
"layer_change_gcode": "",
|
"layer_change_gcode": ";AFTER_LAYER_CHANGE\n;[layer_z]",
|
||||||
"machine_pause_gcode": "M400 U1\n",
|
"machine_pause_gcode": "M400 U1\n",
|
||||||
"wipe": [
|
"wipe": [
|
||||||
"1"
|
"1"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "Voron",
|
"name": "Voron",
|
||||||
"version": "01.02.01.03",
|
"version": "01.02.01.04",
|
||||||
"force_update": "0",
|
"force_update": "0",
|
||||||
"description": "Voron configurations",
|
"description": "Voron configurations",
|
||||||
"machine_model_list": [
|
"machine_model_list": [
|
||||||
|
|
|
@ -133,7 +133,7 @@
|
||||||
],
|
],
|
||||||
"machine_start_gcode": ";M190 S0\n;M104 S0\nPRINT_START EXTRUDER=[nozzle_temperature_initial_layer] BED=[bed_temperature_initial_layer_single]\n; You can use following code instead if your PRINT_START macro support Chamber and print area bedmesh\n; PRINT_START EXTRUDER=[nozzle_temperature_initial_layer] BED=[bed_temperature_initial_layer_single] Chamber=[chamber_temperature] PRINT_MIN={first_layer_print_min[0]},{first_layer_print_min[1]} PRINT_MAX={first_layer_print_max[0]},{first_layer_print_max[1]}",
|
"machine_start_gcode": ";M190 S0\n;M104 S0\nPRINT_START EXTRUDER=[nozzle_temperature_initial_layer] BED=[bed_temperature_initial_layer_single]\n; You can use following code instead if your PRINT_START macro support Chamber and print area bedmesh\n; PRINT_START EXTRUDER=[nozzle_temperature_initial_layer] BED=[bed_temperature_initial_layer_single] Chamber=[chamber_temperature] PRINT_MIN={first_layer_print_min[0]},{first_layer_print_min[1]} PRINT_MAX={first_layer_print_max[0]},{first_layer_print_max[1]}",
|
||||||
"machine_end_gcode": "PRINT_END",
|
"machine_end_gcode": "PRINT_END",
|
||||||
"layer_change_gcode": "",
|
"layer_change_gcode": ";AFTER_LAYER_CHANGE\n;[layer_z]",
|
||||||
"before_layer_change_gcode": ";BEFORE_LAYER_CHANGE\n;[layer_z]\nG92 E0\n",
|
"before_layer_change_gcode": ";BEFORE_LAYER_CHANGE\n;[layer_z]\nG92 E0\n",
|
||||||
"scan_first_layer": "0",
|
"scan_first_layer": "0",
|
||||||
"nozzle_type": "undefine",
|
"nozzle_type": "undefine",
|
||||||
|
|
|
@ -913,6 +913,8 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
|
||||||
else
|
else
|
||||||
gcode_label_objects = true;
|
gcode_label_objects = true;
|
||||||
|
|
||||||
|
GCodeProcessor::s_IsBBLPrinter = print->is_BBL_printer();
|
||||||
|
|
||||||
// check if any custom gcode contains keywords used by the gcode processor to
|
// check if any custom gcode contains keywords used by the gcode processor to
|
||||||
// produce time estimation and gcode toolpaths
|
// produce time estimation and gcode toolpaths
|
||||||
std::vector<std::pair<std::string, std::string>> validation_res = DoExport::validate_custom_gcode(*print);
|
std::vector<std::pair<std::string, std::string>> validation_res = DoExport::validate_custom_gcode(*print);
|
||||||
|
@ -1857,6 +1859,19 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
||||||
// Modifies
|
// Modifies
|
||||||
print.m_print_statistics));
|
print.m_print_statistics));
|
||||||
if (!is_bbl_printers) {
|
if (!is_bbl_printers) {
|
||||||
|
file.write_format("; total filament used [g] = %.2lf\n",
|
||||||
|
print.m_print_statistics.total_weight);
|
||||||
|
file.write_format("; total filament cost = %.2lf\n",
|
||||||
|
print.m_print_statistics.total_cost);
|
||||||
|
if (print.m_print_statistics.total_toolchanges > 0)
|
||||||
|
file.write_format("; total filament change = %i\n",
|
||||||
|
print.m_print_statistics.total_toolchanges);
|
||||||
|
file.write_format("; total layers count = %i\n", m_layer_count);
|
||||||
|
file.write_format(
|
||||||
|
";%s\n",
|
||||||
|
GCodeProcessor::reserved_tag(
|
||||||
|
GCodeProcessor::ETags::Estimated_Printing_Time_Placeholder)
|
||||||
|
.c_str());
|
||||||
file.write("\n");
|
file.write("\n");
|
||||||
file.write("; CONFIG_BLOCK_START\n");
|
file.write("; CONFIG_BLOCK_START\n");
|
||||||
std::string full_config;
|
std::string full_config;
|
||||||
|
@ -1873,21 +1888,11 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
||||||
file.write_format(
|
file.write_format(
|
||||||
"; first_layer_temperature = %d\n",
|
"; first_layer_temperature = %d\n",
|
||||||
print.config().nozzle_temperature_initial_layer.get_at(0));
|
print.config().nozzle_temperature_initial_layer.get_at(0));
|
||||||
file.write("; CONFIG_BLOCK_END\n\n");
|
|
||||||
file.write_format("; total filament used [g] = %.2lf\n",
|
|
||||||
print.m_print_statistics.total_weight);
|
|
||||||
file.write_format("; total filament cost = %.2lf\n",
|
|
||||||
print.m_print_statistics.total_cost);
|
|
||||||
if (print.m_print_statistics.total_toolchanges > 0)
|
|
||||||
file.write_format("; total filament change = %i\n",
|
|
||||||
print.m_print_statistics.total_toolchanges);
|
|
||||||
|
|
||||||
file.write_format("; total layers count = %i\n", m_layer_count);
|
|
||||||
file.write_format(
|
file.write_format(
|
||||||
";%s\n",
|
"; first_layer_height = %.3f\n",
|
||||||
GCodeProcessor::reserved_tag(
|
print.config().initial_layer_print_height.value);
|
||||||
GCodeProcessor::ETags::Estimated_Printing_Time_Placeholder)
|
|
||||||
.c_str());
|
file.write("; CONFIG_BLOCK_END\n\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
file.write("\n");
|
file.write("\n");
|
||||||
|
@ -2544,7 +2549,7 @@ GCode::LayerResult GCode::process_layer(
|
||||||
gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Layer_Change) + "\n";
|
gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Layer_Change) + "\n";
|
||||||
// export layer z
|
// export layer z
|
||||||
char buf[64];
|
char buf[64];
|
||||||
sprintf(buf, "; Z_HEIGHT: %g\n", print_z);
|
sprintf(buf, print.is_BBL_printer() ? "; Z_HEIGHT: %g\n" : ";Z:%g\n", print_z);
|
||||||
gcode += buf;
|
gcode += buf;
|
||||||
// export layer height
|
// export layer height
|
||||||
float height = first_layer ? static_cast<float>(print_z) : static_cast<float>(print_z) - m_last_layer_z;
|
float height = first_layer ? static_cast<float>(print_z) : static_cast<float>(print_z) - m_last_layer_z;
|
||||||
|
|
|
@ -56,12 +56,30 @@ const std::vector<std::string> GCodeProcessor::Reserved_Tags = {
|
||||||
"_GP_ESTIMATED_PRINTING_TIME_PLACEHOLDER"
|
"_GP_ESTIMATED_PRINTING_TIME_PLACEHOLDER"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const std::vector<std::string> GCodeProcessor::Reserved_Tags_compatible = {
|
||||||
|
"TYPE:",
|
||||||
|
"WIPE_START",
|
||||||
|
"WIPE_END",
|
||||||
|
"HEIGHT:",
|
||||||
|
"WIDTH:",
|
||||||
|
"LAYER_CHANGE",
|
||||||
|
"COLOR_CHANGE",
|
||||||
|
"PAUSE_PRINT",
|
||||||
|
"CUSTOM_GCODE",
|
||||||
|
"_GP_FIRST_LINE_M73_PLACEHOLDER",
|
||||||
|
"_GP_LAST_LINE_M73_PLACEHOLDER",
|
||||||
|
"_GP_ESTIMATED_PRINTING_TIME_PLACEHOLDER"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const std::string GCodeProcessor::Flush_Start_Tag = " FLUSH_START";
|
const std::string GCodeProcessor::Flush_Start_Tag = " FLUSH_START";
|
||||||
const std::string GCodeProcessor::Flush_End_Tag = " FLUSH_END";
|
const std::string GCodeProcessor::Flush_End_Tag = " FLUSH_END";
|
||||||
|
|
||||||
const float GCodeProcessor::Wipe_Width = 0.05f;
|
const float GCodeProcessor::Wipe_Width = 0.05f;
|
||||||
const float GCodeProcessor::Wipe_Height = 0.05f;
|
const float GCodeProcessor::Wipe_Height = 0.05f;
|
||||||
|
|
||||||
|
bool GCodeProcessor::s_IsBBLPrinter = true;
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||||
const std::string GCodeProcessor::Mm3_Per_Mm_Tag = "MM3_PER_MM:";
|
const std::string GCodeProcessor::Mm3_Per_Mm_Tag = "MM3_PER_MM:";
|
||||||
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
|
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||||
|
@ -808,11 +826,12 @@ bool GCodeProcessor::contains_reserved_tag(const std::string& gcode, std::string
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
GCodeReader parser;
|
GCodeReader parser;
|
||||||
parser.parse_buffer(gcode, [&ret, &found_tag](GCodeReader& parser, const GCodeReader::GCodeLine& line) {
|
auto& _tags = s_IsBBLPrinter ? Reserved_Tags : Reserved_Tags_compatible;
|
||||||
|
parser.parse_buffer(gcode, [&ret, &found_tag, _tags](GCodeReader& parser, const GCodeReader::GCodeLine& line) {
|
||||||
std::string comment = line.raw();
|
std::string comment = line.raw();
|
||||||
if (comment.length() > 2 && comment.front() == ';') {
|
if (comment.length() > 2 && comment.front() == ';') {
|
||||||
comment = comment.substr(1);
|
comment = comment.substr(1);
|
||||||
for (const std::string& s : Reserved_Tags) {
|
for (const std::string& s : _tags) {
|
||||||
if (boost::starts_with(comment, s)) {
|
if (boost::starts_with(comment, s)) {
|
||||||
ret = true;
|
ret = true;
|
||||||
found_tag = comment;
|
found_tag = comment;
|
||||||
|
@ -835,11 +854,12 @@ bool GCodeProcessor::contains_reserved_tags(const std::string& gcode, unsigned i
|
||||||
CNumericLocalesSetter locales_setter;
|
CNumericLocalesSetter locales_setter;
|
||||||
|
|
||||||
GCodeReader parser;
|
GCodeReader parser;
|
||||||
parser.parse_buffer(gcode, [&ret, &found_tag, max_count](GCodeReader& parser, const GCodeReader::GCodeLine& line) {
|
auto& _tags = s_IsBBLPrinter ? Reserved_Tags : Reserved_Tags_compatible;
|
||||||
|
parser.parse_buffer(gcode, [&ret, &found_tag, max_count, _tags](GCodeReader& parser, const GCodeReader::GCodeLine& line) {
|
||||||
std::string comment = line.raw();
|
std::string comment = line.raw();
|
||||||
if (comment.length() > 2 && comment.front() == ';') {
|
if (comment.length() > 2 && comment.front() == ';') {
|
||||||
comment = comment.substr(1);
|
comment = comment.substr(1);
|
||||||
for (const std::string& s : Reserved_Tags) {
|
for (const std::string& s : _tags) {
|
||||||
if (boost::starts_with(comment, s)) {
|
if (boost::starts_with(comment, s)) {
|
||||||
ret = true;
|
ret = true;
|
||||||
found_tag.push_back(comment);
|
found_tag.push_back(comment);
|
||||||
|
|
|
@ -197,6 +197,7 @@ namespace Slic3r {
|
||||||
class GCodeProcessor
|
class GCodeProcessor
|
||||||
{
|
{
|
||||||
static const std::vector<std::string> Reserved_Tags;
|
static const std::vector<std::string> Reserved_Tags;
|
||||||
|
static const std::vector<std::string> Reserved_Tags_compatible;
|
||||||
static const std::string Flush_Start_Tag;
|
static const std::string Flush_Start_Tag;
|
||||||
static const std::string Flush_End_Tag;
|
static const std::string Flush_End_Tag;
|
||||||
|
|
||||||
|
@ -217,7 +218,7 @@ namespace Slic3r {
|
||||||
Estimated_Printing_Time_Placeholder
|
Estimated_Printing_Time_Placeholder
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::string& reserved_tag(ETags tag) { return Reserved_Tags[static_cast<unsigned char>(tag)]; }
|
static const std::string& reserved_tag(ETags tag) { return s_IsBBLPrinter ? Reserved_Tags[static_cast<unsigned char>(tag)] : Reserved_Tags_compatible[static_cast<unsigned char>(tag)]; }
|
||||||
// checks the given gcode for reserved tags and returns true when finding the 1st (which is returned into found_tag)
|
// checks the given gcode for reserved tags and returns true when finding the 1st (which is returned into found_tag)
|
||||||
static bool contains_reserved_tag(const std::string& gcode, std::string& found_tag);
|
static bool contains_reserved_tag(const std::string& gcode, std::string& found_tag);
|
||||||
// checks the given gcode for reserved tags and returns true when finding any
|
// checks the given gcode for reserved tags and returns true when finding any
|
||||||
|
@ -227,6 +228,8 @@ namespace Slic3r {
|
||||||
static const float Wipe_Width;
|
static const float Wipe_Width;
|
||||||
static const float Wipe_Height;
|
static const float Wipe_Height;
|
||||||
|
|
||||||
|
static bool s_IsBBLPrinter;
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||||
static const std::string Mm3_Per_Mm_Tag;
|
static const std::string Mm3_Per_Mm_Tag;
|
||||||
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
|
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue