generate_gcode
Start G-code generation for an uploaded file and wait for the result. Most jobs finish within the wait, so the answer usually already carries the part dimensions and hole diameters - no polling needed. Only if it says the job is still running, call get_job_status once after a few seconds. Free - only the download is charged.
BEFORE CALLING THIS, ask the user about the settings you cannot infer from the file. Two of them change the result substantially and are wrong by default more often than not:
material: drives spindle speed, feed rates and depth per pass. Aluminium cut with wood settings breaks cutters.
holding_tabs: without them a cut-out part comes loose on the last pass and can be thrown off the machine. Recommend them for any part cut all the way through. Also worth asking when the geometry suggests it: pockets and holes (STEP files carry that depth information), and whether the job is milling or laser work.
IMAGES (PNG, JPG, WebP ...) are always laser raster engraving. Ask for the engraving width in mm, photo or logo (image_mode), the controller (GRBL or Marlin) and its S maximum (laser_max_s), and tell the user to test power and speed on a scrap piece first.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"file_id": "<file_id>"
},
"name": "generate_gcode"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| depth | No | Cutting depth in mm; omit to take it from the model geometry (STEP) | |
| holes | No | Drill or mill the holes found in the geometry | |
| laser | No | Laser job instead of milling | |
| file_id | Yes | file_id from check_upload or upload_file_content | |
| pockets | No | Mill pockets found in the geometry (STEP) | |
| material | No | Workpiece material. Sets spindle speed, feed rates and depth per pass. Ask the user - the default assumes softwood. | |
| origin_z | No | Z zero on the stock surface (top) or on the spoilboard. Default top. | |
| feed_rate | No | Horizontal feed in mm/min. Same rule: only for materials outside the presets. | |
| origin_xy | No | Workpiece origin in XY. Default TL. | |
| step_down | No | Depth per pass in mm. Rule of thumb: up to 1x cutter diameter in softwood, far less in metal. | |
| controller | No | Laser G-code dialect. GRBL (default) or Marlin (3D printers with a laser module, MPCNC/LowRider and other Marlin machines). | |
| image_mode | No | Images only. Line by line (raster): dither for photos (default), threshold for logos and text, grayscale for power per dot. Along lines (vector, much faster): outline traces the edges of dark areas, centerline follows the middle of strokes (line art, handwriting), edges turns a photo into a line drawing. | |
| ramp_entry | No | Enter the material on a ramp instead of plunging straight down | |
| laser_max_s | No | Highest S value of the machine: $30 on GRBL (usually 1000), 255 on most Marlin machines. Ask the user - a wrong value burns at the wrong power. | |
| laser_power | No | Laser power in % (laser jobs). For images the default is 30 %. | |
| laser_speed | No | Laser speed in mm/min (laser jobs). For images the default is 2000. | |
| plunge_rate | No | Plunge feed in mm/min, for materials outside the presets. | |
| bit_diameter | No | Cutter diameter in mm, e.g. 6. Leave it out and step2gcode picks the largest whole millimetre that still fits through the smallest hole in the part. | |
| holding_tabs | No | Leave small bridges so a part cut all the way through stays in the stock. Strongly recommended for through cuts. | |
| spindle_speed | No | Spindle speed in rpm. Only set this when the material is not covered by the presets - otherwise the preset value is used. | |
| image_width_mm | No | Images only: engraving width in mm; the height follows from the aspect ratio. Default 100. | |
| inner_contours | No | Cut inner contours and cut-outs |