mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
CURA-4577 Adding relative positioning to GCodeReader
This commit is contained in:
parent
720b9ebdfa
commit
b868f913c4
1 changed files with 12 additions and 1 deletions
|
@ -54,6 +54,7 @@ class GCodeReader(MeshReader):
|
||||||
self._previous_z = 0
|
self._previous_z = 0
|
||||||
self._layer_data_builder = LayerDataBuilder.LayerDataBuilder()
|
self._layer_data_builder = LayerDataBuilder.LayerDataBuilder()
|
||||||
self._center_is_zero = False
|
self._center_is_zero = False
|
||||||
|
self._is_absolute_positioning = True # It can be absolute (G90) or relative (G91)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _getValue(line, code):
|
def _getValue(line, code):
|
||||||
|
@ -166,6 +167,16 @@ class GCodeReader(MeshReader):
|
||||||
0,
|
0,
|
||||||
position.e)
|
position.e)
|
||||||
|
|
||||||
|
## Set the absolute positioning
|
||||||
|
def _gCode90(self, position, params, path):
|
||||||
|
self._is_absolute_positioning = True
|
||||||
|
return position
|
||||||
|
|
||||||
|
## Set the relative positioning
|
||||||
|
def _gCode91(self, position, params, path):
|
||||||
|
self._is_absolute_positioning = False
|
||||||
|
return position
|
||||||
|
|
||||||
## Reset the current position to the values specified.
|
## Reset the current position to the values specified.
|
||||||
# For example: G92 X10 will set the X to 10 without any physical motion.
|
# For example: G92 X10 will set the X to 10 without any physical motion.
|
||||||
def _gCode92(self, position, params, path):
|
def _gCode92(self, position, params, path):
|
||||||
|
@ -196,7 +207,7 @@ class GCodeReader(MeshReader):
|
||||||
z = float(item[1:])
|
z = float(item[1:])
|
||||||
if item[0] == "E":
|
if item[0] == "E":
|
||||||
e = float(item[1:])
|
e = float(item[1:])
|
||||||
if (x is not None and x < 0) or (y is not None and y < 0):
|
if self._is_absolute_positioning and ((x is not None and x < 0) or (y is not None and y < 0)):
|
||||||
self._center_is_zero = True
|
self._center_is_zero = True
|
||||||
params = self._position(x, y, z, e)
|
params = self._position(x, y, z, e)
|
||||||
return func(position, params, path)
|
return func(position, params, path)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue