Fix model size calculation during GCODE analysis
* Properly handle G0/G1 with no X, Y, Z coordinates in relative mode
instead of duplicating coordinates - should fix #1675
* Only take move commands with X, Y, Z coordinates into account for
model size calculation - this makes our internal GCODE analysis behave
like the GCODE viewer's analysis and produce the same model size. The
downside is that extrusions on the origin are no longer taken into account
for checking if a model is within bounds of the print bed, but that should
hopefully not produce any issues in the real world.
This commit is contained in:
parent
63c588fce9
commit
6e474d9096
1 changed files with 21 additions and 7 deletions
|
|
@ -294,15 +294,28 @@ class gcode(object):
|
|||
e = getCodeFloat(line, 'E')
|
||||
f = getCodeFloat(line, 'F')
|
||||
|
||||
if x is not None or y is not None or z is not None:
|
||||
# this is a move
|
||||
move = True
|
||||
else:
|
||||
# print head stays on position
|
||||
move = False
|
||||
|
||||
oldPos = pos
|
||||
newPos = Vector3D(x if x is not None else pos.x,
|
||||
y if y is not None else pos.y,
|
||||
z if z is not None else pos.z)
|
||||
|
||||
# Use new coordinates if provided. If not provided, use prior coordinates in absolute
|
||||
# and 0.0 in relative mode.
|
||||
newPos = Vector3D(x if x is not None else (pos.x if posAbs else 0.0),
|
||||
y if y is not None else (pos.y if posAbs else 0.0),
|
||||
z if z is not None else (pos.z if posAbs else 0.0))
|
||||
|
||||
if posAbs:
|
||||
# Absolute mode: scale coordinates and apply offsets
|
||||
pos = newPos * scale + posOffset
|
||||
else:
|
||||
# Relative mode: scale and add to current position
|
||||
pos += newPos * scale
|
||||
|
||||
if f is not None and f != 0:
|
||||
feedrate = f
|
||||
|
||||
|
|
@ -310,10 +323,12 @@ class gcode(object):
|
|||
if absoluteE:
|
||||
# make sure e is relative
|
||||
e -= currentE[currentExtruder]
|
||||
# If move includes extrusion, calculate new min/max coordinates of model
|
||||
if e > 0.0:
|
||||
# extrusion -> relevant for print area & dimensions
|
||||
|
||||
# If move with extrusion, calculate new min/max coordinates of model
|
||||
if e > 0.0 and move:
|
||||
# extrusion and move -> relevant for print area & dimensions
|
||||
self._minMax.record(pos)
|
||||
|
||||
totalExtrusion[currentExtruder] += e
|
||||
currentE[currentExtruder] += e
|
||||
maxExtrusion[currentExtruder] = max(maxExtrusion[currentExtruder],
|
||||
|
|
@ -417,7 +432,6 @@ class gcode(object):
|
|||
|
||||
if throttle is not None:
|
||||
throttle()
|
||||
|
||||
if self.progressCallback is not None:
|
||||
self.progressCallback(100.0)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue