Fixed a regression issue to PrusaSlicer 2.1.1

Custom printer with center of bed at 0,0 results in "toolpath outside print area" #3510
The G92 A0 B0 was incorrectly considered to be equal to just G92
to reset all axes.
This commit is contained in:
bubnikv 2020-03-21 10:09:33 +01:00
parent 1cbb822dd7
commit 046f0dbfa2
4 changed files with 22 additions and 5 deletions

View file

@ -444,8 +444,10 @@ void GCodeAnalyzer::_processG92(const GCodeReader::GCodeLine& line)
anyFound = true;
}
if (!anyFound)
if (!anyFound && ! line.has_unknown_axis())
{
// The G92 may be called for axes that PrusaSlicer does not recognize, for example see GH issue #3510,
// where G92 A0 B0 is called although the extruder axis is till E.
for (unsigned char a = X; a < Num_Axis; ++a)
{
_set_axis_origin((EAxis)a, _get_axis_position((EAxis)a));

View file

@ -40,7 +40,7 @@ const char* GCodeReader::parse_line_internal(const char *ptr, GCodeLine &gline,
if (is_end_of_gcode_line(*c))
break;
// Check the name of the axis.
Axis axis = NUM_AXES;
Axis axis = NUM_AXES_WITH_UNKNOWN;
switch (*c) {
case 'X': axis = X; break;
case 'Y': axis = Y; break;
@ -49,15 +49,19 @@ const char* GCodeReader::parse_line_internal(const char *ptr, GCodeLine &gline,
default:
if (*c == m_extrusion_axis)
axis = E;
else if (*c >= 'A' && *c <= 'Z')
// Unknown axis, but we still want to remember that such a axis was seen.
axis = UNKNOWN_AXIS;
break;
}
if (axis != NUM_AXES) {
if (axis != NUM_AXES_WITH_UNKNOWN) {
// Try to parse the numeric value.
char *pend = nullptr;
double v = strtod(++ c, &pend);
if (pend != nullptr && is_end_of_word(*pend)) {
// The axis value has been parsed correctly.
gline.m_axis[int(axis)] = float(v);
if (axis != UNKNOWN_AXIS)
gline.m_axis[int(axis)] = float(v);
gline.m_mask |= 1 << int(axis);
c = pend;
} else

View file

@ -58,6 +58,7 @@ public:
bool has_z() const { return this->has(Z); }
bool has_e() const { return this->has(E); }
bool has_f() const { return this->has(F); }
bool has_unknown_axis() const { return this->has(UNKNOWN_AXIS); }
float x() const { return m_axis[X]; }
float y() const { return m_axis[Y]; }
float z() const { return m_axis[Z]; }

View file

@ -98,7 +98,17 @@ extern Semver SEMVER;
template<typename T, typename Q>
inline T unscale(Q v) { return T(v) * T(SCALING_FACTOR); }
enum Axis { X=0, Y, Z, E, F, NUM_AXES };
enum Axis {
X=0,
Y,
Z,
E,
F,
NUM_AXES,
// For the GCodeReader to mark a parsed axis, which is not in "XYZEF", it was parsed correctly.
UNKNOWN_AXIS = NUM_AXES,
NUM_AXES_WITH_UNKNOWN,
};
template <class T>
inline void append_to(std::vector<T> &dst, const std::vector<T> &src)