Skip to content

octoprint.util.gcodeInterpreter#

regex_command = re.compile('^\\s*((?P<codeGM>[GM]\\d+)(\\.(?P<subcode>\\d+))?|(?P<codeT>T)(?P<tool>\\d+))') module-attribute #

Regex for a GCODE command.

MinMax3D(min_x = None, min_y = None, min_z = None, max_x = None, max_y = None, max_z = None) #

Tracks minimum and maximum of recorded values

Examples:

minmax = MinMax3D() minmax.record(Vector3D(2.0, 2.0, 2.0)) minmax.min.x == 2.0 == minmax.max.x and minmax.min.y == 2.0 == minmax.max.y and minmax.min.z == 2.0 == minmax.max.z True minmax.record(Vector3D(1.0, 2.0, 3.0)) minmax.min.x == 1.0 and minmax.min.y == 2.0 and minmax.min.z == 2.0 True minmax.max.x == 2.0 and minmax.max.y == 2.0 and minmax.max.z == 3.0 True minmax.size == Vector3D(1.0, 0.0, 1.0) True empty = MinMax3D() empty.size == Vector3D(0.0, 0.0, 0.0) True weird = MinMax3D(min_z=-1.0) weird.record(Vector3D(2.0, 2.0, 2.0)) weird.record(Vector3D(1.0, 2.0, 3.0)) weird.min.z == -1.0 True weird.size == Vector3D(1.0, 0.0, 4.0) True

record(coordinate) #

Records the coordinate, storing the min and max values.

The input vector components must not be None.

Vector3D(*args) #

3D vector value

Supports addition, subtraction and multiplication with a scalar value (float, int) as well as calculating the length of the vector.

Examples:

a = Vector3D(1.0, 1.0, 1.0) b = Vector3D(4.0, 4.0, 4.0) a + b == Vector3D(5.0, 5.0, 5.0) True b - a == Vector3D(3.0, 3.0, 3.0) True abs(a - b) == Vector3D(3.0, 3.0, 3.0) True a * 2 == Vector3D(2.0, 2.0, 2.0) True a * 2 == 2 * a True a.length == math.sqrt(a.x ** 2 + a.y ** 2 + a.z ** 2) True copied_a = Vector3D(a) a == copied_a True copied_a.x == a.x and copied_a.y == a.y and copied_a.z == a.z True