marlin

Command Class

class gcodeBuddy.marlin.Command(init_string)[source]

represents line of Marlin g-code

Parameters

init_string (str) – line of Marlin g-code

get_command()[source]
Returns

g-code command

Return type

str

get_param(param_char)[source]
Parameters

param_char (str) – parameter character to search for in g-code command

Returns

value of parameter character stored in g-code command

Return type

float

get_string()[source]
Returns

entire g-code command in line form

Return type

string

has_param(param_char)[source]
Parameters

param_char (str) – parameter character to search for in g-code command

Returns

whether the Command object has the given parameter

Return type

bool

set_param(param_char, param_val)[source]

sets parameter value

Parameters
  • param_char (str) – parameter character to change value

  • param_val (int, float) – parameter value to set

Examples

Basic Command Usage
# imports Command object
from gcodeBuddy.marlin import Command

# creates Command object from line of Marlin g-code
sample_command = Command("G0 X12.3 Y45.6 Z78.9")

# prints "G0"
print(sample_command.get_command())

# prints 12.3
if sample_command.has_param("X"):
    print(sample_command.get_param("X"))

# changes value of "Y" param to 0.0
sample_command.set_param("Y", 0.0)

# prints "G0 X12.3 Y0.0 Z78.9"
print(sample_command.get_string()))

command_to_arc Function

class gcodeBuddy.marlin.command_to_arc(curr_pos, command)[source]

converts G2/G3 Marlin g-code command to Arc object

Parameters
  • curr_pos (list[int, float], tuple(int, float)) – position of toolhead before given command

  • command (Command) – G2/G3 command

Returns

arc toolpath travel corresponding to given g-code command

Return type

Arc

Examples

Examples using command_to_arc() function can be found in arc module examples.

marlin_commands Function

class gcodeBuddy.marlin.marlin_commands[source]
Returns

up-to-date Marlin commands, periodically scraped from the Marlin website

Return type

tuple(str)

Examples

marlin_commands() Usage
# imports marlin_commands() function
from gcodeBuddy.marlin import marlin_commands

# prints every current Marlin command
for element in marlin_commands():
    print(element)
Result of Printing marlin_commands()
G0
G1
G2
G3
.
.
.
G91
G92
G425
M0
M1
M3
.
.
.
M997
M999
M7219
T0
T1
T2
T3
T4
T5
T6