layerview.gcode.commands module
G-code commands and command parsing logic.
- class layerview.gcode.commands.ArcMove(x: float | None = None, y: float | None = None, i: float | None = None, j: float | None = None, e: float | None = None, f: float | None = None, line_number: int | None = None)[source]
Bases:
MoveGeneric Arc Move.
- _abc_impl = <_abc_data object>
- e: float | None
- f: float | None
- line_number: int
- param_letters = ['x', 'y', 'i', 'j', 'e', 'f']
- x: float | None
- y: float | None
- class layerview.gcode.commands.Command(line_number: int | None = None)[source]
Bases:
ABCGeneric G-code command.
- _abc_impl = <_abc_data object>
- line_number: int
- exception layerview.gcode.commands.CommandInvalidParamError[source]
Bases:
CommandParseError- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception layerview.gcode.commands.CommandMissingParamError[source]
Bases:
CommandParseError- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception layerview.gcode.commands.CommandParseError[source]
Bases:
Exception- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class layerview.gcode.commands.CommandParser(skip_unknown: bool | None = False)[source]
Bases:
object- _get_handler(command_token: Tuple[str, str]) Callable[source]
Get factory method for G-code command.
- Parameters:
command_token (GcodeToken) – Command GcodeToken for which the factory method is to be returned.
- Returns:
Factory method for specific G-code command.
- Return type:
Callable
- static _group_tokens_by_command(tokens: List[Tuple[str, str]]) List[List[Tuple[str, str]]][source]
Groups tokens by the command they correspond to.
- Parameters:
tokens (List[GcodeToken]) – List of G-code tokens to group by the command they correspond to.
- Returns:
groups – List of lists of G-code tokens.
- Return type:
List[List[GcodeToken]]
- parse(tokens: List[Tuple[str, str]]) List[Command][source]
- Parameters:
tokens (List[GcodeToken]) – List of G-code tokens, representing G-code fields. Expecting [(param, value), (param, value)]. E.g. [(‘g’, ‘1’), (‘x’, ‘10.25’), (‘y’, ‘22’)].
- Returns:
commands – Parsed commands. May be empty if no tokens are present.
- Return type:
List[Command]
- Raises:
CommandParseError – If tokens contain unknown commands and skip_unknown is False.
- exception layerview.gcode.commands.CommandTokenError[source]
Bases:
CommandParseError- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class layerview.gcode.commands.CommandWithParams(line_number: int | None = None)[source]
Bases:
Command,ABCGeneric G-code command with params.
- _abc_impl = <_abc_data object>
- line_number: int
- abstract property param_letters: List[str]
- class layerview.gcode.commands.CommandWithoutParams(line_number: int | None = None)[source]
Bases:
CommandGeneric G-code command without params.
- _abc_impl = <_abc_data object>
- line_number: int
- class layerview.gcode.commands.G0(x: float | None = None, y: float | None = None, z: float | None = None, e: float | None = None, f: float | None = None, h: float | None = None, r: float | None = None, s: float | None = None, line_number: int | None = None)[source]
Bases:
LineMoveRapid Move.
- _abc_impl = <_abc_data object>
- e: float | None
- f: float | None
- h
- line_number: int
- param_letters = ['x', 'y', 'z', 'e', 'f', 'h', 'r', 's']
- r
- s
- x: float | None
- y: float | None
- z
- class layerview.gcode.commands.G1(x: float | None = None, y: float | None = None, z: float | None = None, e: float | None = None, f: float | None = None, h: float | None = None, r: float | None = None, s: float | None = None, line_number: int | None = None)[source]
Bases:
LineMoveLinear Move.
- _abc_impl = <_abc_data object>
- e: float | None
- f: float | None
- h
- line_number: int
- param_letters = ['x', 'y', 'z', 'e', 'f', 'h', 'r', 's']
- r
- s
- x: float | None
- y: float | None
- z
- class layerview.gcode.commands.G2(x: float | None = None, y: float | None = None, i: float | None = None, j: float | None = None, e: float | None = None, f: float | None = None, line_number: int | None = None)[source]
Bases:
ArcMoveClockwise Arc.
- _abc_impl = <_abc_data object>
- e: float | None
- f: float | None
- line_number: int
- param_letters = ['x', 'y', 'i', 'j', 'e', 'f']
- x: float | None
- y: float | None
- class layerview.gcode.commands.G20(line_number: int | None = None)[source]
Bases:
CommandWithoutParamsSet units to inches.
- _abc_impl = <_abc_data object>
- line_number: int
- class layerview.gcode.commands.G21(line_number: int | None = None)[source]
Bases:
CommandWithoutParamsSet units to millis.
- _abc_impl = <_abc_data object>
- line_number: int
- class layerview.gcode.commands.G28(x: bool, y: bool, z: bool, line_number: int | None = None)[source]
Bases:
CommandWithParamsMove to origin (home).
- _abc_impl = <_abc_data object>
- line_number: int
- param_letters = ['x', 'y', 'z']
- class layerview.gcode.commands.G3(x: float | None = None, y: float | None = None, i: float | None = None, j: float | None = None, e: float | None = None, f: float | None = None, line_number: int | None = None)[source]
Bases:
ArcMoveCounter-Clockwise Arc.
- _abc_impl = <_abc_data object>
- e: float | None
- f: float | None
- line_number: int
- param_letters = ['x', 'y', 'i', 'j', 'e', 'f']
- x: float | None
- y: float | None
- class layerview.gcode.commands.G90(line_number: int | None = None)[source]
Bases:
CommandWithoutParamsSet absolute positioning.
- _abc_impl = <_abc_data object>
- line_number: int
- class layerview.gcode.commands.G91(line_number: int | None = None)[source]
Bases:
CommandWithoutParamsSet relative positioning.
- _abc_impl = <_abc_data object>
- line_number: int
- class layerview.gcode.commands.G92(x: float | None = None, y: float | None = None, z: float | None = None, e: float | None = None, line_number: int | None = None)[source]
Bases:
CommandWithParamsSet position.
- _abc_impl = <_abc_data object>
- line_number: int
- param_letters = ['x', 'y', 'z', 'e']
- class layerview.gcode.commands.LineMove(x: float | None = None, y: float | None = None, z: float | None = None, e: float | None = None, f: float | None = None, h: float | None = None, r: float | None = None, s: float | None = None, line_number: int | None = None)[source]
Bases:
MoveGeneric Line Move
- _abc_impl = <_abc_data object>
- e: float | None
- f: float | None
- h
- line_number: int
- param_letters = ['x', 'y', 'z', 'e', 'f', 'h', 'r', 's']
- r
- s
- x: float | None
- y: float | None
- z
- class layerview.gcode.commands.M104(s: float, r: float | None = None, d: float | None = None, line_number: int | None = None)[source]
Bases:
SetTemperatureExtruderSet Extruder Temperature
- _abc_impl = <_abc_data object>
- line_number: int
- param_letters = ['s', 'r', 'd']
- class layerview.gcode.commands.M109(s: float, r: float | None = None, t: int | None = None, line_number: int | None = None)[source]
Bases:
SetTemperatureExtruderSet Extruder Temperature and Wait
- _abc_impl = <_abc_data object>
- line_number: int
- param_letters = ['s', 'r', 't']
- class layerview.gcode.commands.M82(line_number: int | None = None)[source]
Bases:
CommandWithoutParamsSet extruder absolute mode.
- _abc_impl = <_abc_data object>
- line_number: int
- class layerview.gcode.commands.M83(line_number: int | None = None)[source]
Bases:
CommandWithoutParamsSet extruder relative mode.
- _abc_impl = <_abc_data object>
- line_number: int
- class layerview.gcode.commands.Move(x: float | None = None, y: float | None = None, e: float | None = None, f: float | None = None, line_number: int | None = None)[source]
Bases:
CommandWithParams,ABCMove command base class.
- _abc_impl = <_abc_data object>
- e: float | None
- f: float | None
- line_number: int
- abstract property param_letters: List[str]
- x: float | None
- y: float | None