Commit 1877d2cc authored by Guillaume Seguin's avatar Guillaume Seguin

Correctly handle G92 in hosts

parent fd89ad28
......@@ -87,7 +87,8 @@ class Layer(list):
self.z = z
def _preprocess(self, current_x, current_y, current_z,
offset_x, offset_y, offset_z, ignore_noe = False):
offset_x, offset_y, offset_z,
ignore_noe = False, host_mode = True):
xmin = float("inf")
ymin = float("inf")
zmin = 0
......@@ -136,6 +137,11 @@ class Layer(list):
if line.z: current_z = 0
elif line.command == "G92":
if host_mode:
current_x = line.x or current_x
current_y = line.y or current_y
current_z = line.z or current_z
else:
if line.x: offset_x = current_x - line.x
if line.y: offset_y = current_y - line.y
if line.z: offset_z = current_z - line.z
......@@ -175,14 +181,14 @@ class GCode(object):
est_layer_height = None
def __init__(self, data):
def __init__(self, data, host_mode = True):
self.lines = [Line(l2) for l2 in
(l.strip() for l in data)
if l2]
self._preprocess_lines()
self.filament_length = self._preprocess_extrusion()
self._create_layers()
self._preprocess_layers()
self._preprocess_layers(host_mode = host_mode)
def __len__(self):
return len(self.line_idxs)
......@@ -359,7 +365,7 @@ class GCode(object):
def num_layers(self):
return len(self.layers)
def _preprocess_layers(self):
def _preprocess_layers(self, host_mode = True):
xmin = float("inf")
ymin = float("inf")
zmin = 0
......@@ -379,7 +385,7 @@ class GCode(object):
for l in self.all_layers:
meta = l._preprocess(current_x, current_y, current_z,
offset_x, offset_y, offset_z,
ignore_noe)
ignore_noe, host_mode)
current_x, current_y, current_z = meta[0]
offset_x, offset_y, offset_z = meta[1]
(xm, xM), (ym, yM), (zm, zM) = meta[2:]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment