Gscrib Quick Referenceο
This reference shows how familiar G-code operations map to Gscribβs Python API. Gscrib is a stateful G-code builder that tracks your machineβs state and generates appropriate G-code commands. Instead of writing raw G-code, you call Python methods that handle the details.
Key Differences from Raw G-codeο
State tracking: Gscrib remembers position, feed rates, tool status, etc.
Coordinate transforms: Like CAM software, rotate, scale, translate before output.
No G2/G3 arcs: All curves become smooth G1 segments (controlled by
set_resolution()).Safety: Built-in validation and bounds checking.
Essential Tipsο
Set units early before any movements.
Set resolution with
set_resolution()for smooth curves.Use high-level methods (
move,tool_on) instead ofwriteto maintain state.Use context managers like
with absolute_mode()for temporary changes.Add custom parameters to any command (
move(x=10, custom_param="value")).Add inline comments to any command (
move(x=10, comment="Inline comment")).Coordinates can be specified as
x=10, y=5,Point(10, 5)or[10, 5].
G-code to Gscrib Translationο
G-code param |
Meaning |
Gscrib equivalent |
|---|---|---|
X Y Z |
Position |
|
I J K |
Arc center offsets |
|
R |
Arc radius |
|
F |
Feed rate |
|
S |
Laser power |
|
S |
Spindle speed |
|
P |
Dwell time |
|
T |
Tool select |
|
π Units & Coordinate Systemsο
G-code |
Gscrib |
Notes |
|---|---|---|
G92 |
Set position without moving. |
|
G17 / G18 / G19 |
Ignored, use transforms instead |
|
G20 / G21 |
Inches or millimeters |
|
β |
For arc interpolation logic. |
|
β |
Segmentation resolution. |
|
β |
Controller specific. |
|
β |
Controller specific. |
Tips
Set units early in your program before any movements.
Lower resolution values create smoother curves but larger files.
The controller you use determines which temperature and time units apply.
Examples
set_length_units("mm") # G21
set_axis(x=0, y=0, z=5) # G92 X0 Y0 Z5
π Operation Modesο
G-code |
Gscrib |
Notes |
|---|---|---|
G90 |
Absolute positioning. |
|
G91 |
Relative positioning. |
|
G93 |
Feed as 1/time |
|
G94 |
Standard feed mode |
|
G95 |
Feed per spindle rev |
|
M82 |
Absolute filament extrusion |
|
M83 |
Relative filament extrusion |
Tips
Absolute mode is safer for precise positioning.
Relative mode is useful for incremental movements.
Use context managers for temporary mode changes.
Examples
set_distance_mode("absolute") # G90
set_feed_mode("units_per_minute") # G94
π Feeds & Speedsο
G-code |
Gscrib |
Notes |
|---|---|---|
F⦠|
Feed rate. |
|
S⦠|
Tool power/speed. |
Tips
Feed rate and tool power persist until changed.
Use
set_bounds()to enforce safe speed limits.
Examples
set_feed_rate(1500) # F1500
set_tool_power(8000) # S8000 (without M03)
π§ Tool Controlο
G-code |
Gscrib |
Notes |
|---|---|---|
S⦠M03 |
Constant-power mode. |
|
S⦠M03 |
CW spindle. |
|
S⦠M04 |
CCW spindle. |
|
T⦠M06 |
Auto tool-change. |
|
T⦠M06 |
Manual tool-change. |
|
M05 |
Stop spindle / Power off tool. |
Tips
Always turn off tool before tool changes.
Use
power_on()for lasers,tool_on()for spindles.Check
state.is_tool_activebefore operations.
Examples
tool_on("cw", 12000) # M03 S12000
power_on("constant", 80) # M03 S80 (laser)
tool_change("manual", 2) # T2 M06
tool_off() # M05
π§ Coolant Controlο
M-code |
Gscrib |
|---|---|
M07 |
|
M08 |
|
M09 |
Tips
Turn on coolant after tool start for proper flow.
Use flood coolant for heavy cutting, mist for light work.
Always turn off coolant before tool changes.
Examples
coolant_on("flood") # M08
coolant_off() # M09
π₯ Temperature Controlο
M-code |
Gscrib |
Notes |
|---|---|---|
M106 |
Range 0 to 255. |
|
M140 |
Non-blocking. |
|
M104 |
Non-blocking. |
|
M141 |
Non-blocking. |
Tips
Temperature units controlled by
set_temperature_units().Use
halt("wait-for-*")methods to block until temperature reached.Use
set_bounds()to prevent dangerous temperatures.
Examples
set_bed_temperature(60) # M140 S60
set_hotend_temperature(200) # M104 S200
set_fan_speed(255) # M106 P0 S255
π― Motion Controlο
G-code |
Gscrib |
Notes |
|---|---|---|
G0 |
Rapid move. |
|
G0 |
Absolute rapid (ignore transforms). |
|
G1 |
Linear move. |
|
G1 |
Absolute linear (ignore transforms). |
|
G28 |
Homes axes. |
Tips
Bypass coordinate transforms with
rapid_absolute()/move_absolute().Current position becomes unknown after
auto_home()if not specified.The behaviour of
auto_home()may depend on the controller.
Examples
rapid(z=5) # G0 Z5
rapid(x=10, y=5) # G0 X10 Y5
move(x=20, y=10, F=1500) # G1 X20 Y10 F1500
auto_home(x=0, y=0, z=0) # G28 X0 Y0 Z0
π Path Interpolationο
G-code |
Gscrib |
Notes |
|---|---|---|
G2/G3 (simulated) |
Uses I/J/K-like geometry. |
|
G2/G3 (simulated) |
Radius-mode arcs. |
|
β |
Full circle. |
|
β |
Cubic spline. |
|
β |
Helical path. |
|
β |
Thread-like helix. |
|
β |
Spiral pattern. |
|
β |
Linked G1 moves. |
|
β |
Arbitrary parametric curve. |
Tips
All arc/curve methods emit G1 segments; never G2/G3.
Interpolated paths ignore the active plane, use coordinate transforms instead.
Use
set_resolution()for smoother arcs/splines (smaller = smoother).Use
set_direction()to control arc direction globally.
Examples
set_resolution(0.1) # Fine resolution
set_direction("cw") # Clockwise arcs
trace.arc((10, 10), center=(5, 0)) # G2-like: X10 Y10 I5 J0
trace.arc_radius((20, 10), radius=30) # G2-like with R30
trace.circle(center=(0, 0), radius=5) # Full circle
trace.spline([(0,0), (5,10), (10,0)]) # Smooth curve
π§ Coordinate Transformsο
Gscrib |
Notes |
|---|---|
Set rotation/scale center |
|
Mirror across plane |
|
Reflect across normal |
|
Rotate in degrees |
|
Scale factors |
|
Move origin |
|
Save transform stack |
|
Restore saved state |
|
Delete saved state |
Tips
Set pivot before rotating or scaling.
Use
current_transform()context manager for temporary changes.Transforms stack like CAM operations, not G-code offsets.
Transforms affect all subsequent moves until changed.
Examples
transform.save_state("original") # Save current state
transform.translate(x=10, y=5) # Move coordinate system
transform.set_pivot(point=(5, 5)) # Set rotation center
transform.rotate(45, axis="z") # Rotate 45Β°
move(x=10, y=0) # Move in rotated system
transform.restore_state("original") # Back to start state
β±οΈ Timing & Synchronizationο
G/M-code |
Gscrib |
Notes |
|---|---|---|
G04 P⦠|
Dwell. |
|
M00 / M01 |
Required/optional pause. |
|
M02 / M30 |
End with/without reset. |
|
M400 |
Wait for motion to finish. |
Tips
Time units controlled by
set_time_units().Temperature units controlled by
set_temperature_units().
Examples
wait() # M400
sleep(2) # G04 P2
β Halt Operationsο
M-code |
Gscrib |
Notes |
|---|---|---|
M00 |
Alias |
|
M01 |
Alias |
|
M02 |
Alias |
|
M30 |
Alias |
|
M60 |
Pallet exchange. |
|
M109 |
Wait to reach temperature. |
|
M190 |
Wait to reach temperature. |
|
M191 |
Wait to reach temperature. |
Tips
Use the aliased methods unless you have a specific reason not to.
Use
emergency_halt()for a complete safety shutdown sequence.
π‘ Probingο
G-code |
Gscrib |
|---|---|
G38.2 |
|
G38.3 |
|
G38.4 |
|
G38.5 |
Tips
Use slow feed rates for accurate probing.
Probe sets current position to unknown (actual stop depends on sensor).
Examples
probe("towards", z=-10) # G38.2 Z-10
π Queries & Statusο
M-code |
Gscrib |
|---|---|
M105 |
|
M114 |
|
? |
Tips
Only works in direct write mode with connected device.
Read sensor values with
writer.get_parameter()
Examples
query("position") # M114
query("temperature") # M105
z = writer.get_parameter("Z")
t = writer.get_parameter("B")
β οΈ Raw G-codeο
G-code |
Gscrib |
Notes |
|---|---|---|
Raw G-code |
Bypasses state tracking |
Tips
Raw
write("G1 Xβ¦")does not update internal position.Prefer high-level methods to maintain state consistency.
Only use for unsupported commands or special cases.
π Comments & Annotationsο
G-code
Gscrib
Notes
; comment
comment("β¦")Uses formatter syntax
; @set key=value
annotate(key, value)Structured annotation
Tips
Use
format.set_comment_symbols()to change comment style.Annotations create machine-readable metadata.
Examples