gcode
GitHub使用 OrcaSlicer 将 3D 模型切片生成 G-code,支持命令行无头模式或打开应用手动操作。涵盖安装、预设配置、切片命令及打印前检查,不直接连接打印机。
Trigger Scenarios
Install
npx skills add earthtojake/text-to-cad --skill gcode -g -y
SKILL.md
Frontmatter
{
"name": "gcode",
"license": "MIT",
"metadata": {
"repository": "earthtojake\/text-to-cad"
},
"description": "Slice 3D models into printer-ready G-code with OrcaSlicer, the open-source slicer with built-in profiles for most FDM printers (Prusa, Bambu Lab, Creality, Voron and more). Use when the user wants an `.stl`, `.3mf` or `.obj` model sliced for their printer, as a sliced `.gcode.3mf` or plain `.gcode`, headless with OrcaSlicer's command line or by opening the model in OrcaSlicer. Never contacts a printer."
}
G-code
Slice with OrcaSlicer, headless (below) or by opening the model in the
OrcaSlicer app for the user. The agent never contacts a printer: for a Bambu
Lab printer, the result is sent through Bambu Connect; for any other printer,
give the user the .gcode.
Install OrcaSlicer
- macOS:
brew install --cask orcaslicer. The command line is/Applications/OrcaSlicer.app/Contents/MacOS/OrcaSlicer. - Windows and Linux: install a release from
https://github.com/OrcaSlicer/OrcaSlicer/releases. The command is
orca-slicer; on Linux, run it from the AppImage or Flatpak.
Below, <orca> is that command.
Slice headless
OrcaSlicer's command line (https://www.orcaslicer.com/wiki/cli/cli_mode) needs
complete presets: it doesn't fill in a preset's parent settings, and it slices
only with a process whose compatible printers name the printer.
scripts/orca_presets.py (Python 3, no dependencies) writes them from
OrcaSlicer's presets, searching the user's own first, then OrcaSlicer's
built-in profiles.
-
Find the user's printer, process and filament presets. Prefer the presets the user prints with; never invent one, since a wrong bed size or temperature can damage the printer.
python scripts/orca_presets.py --list machine --match "MK4S" python scripts/orca_presets.py --list process --match "@MK4S 0.4" python scripts/orca_presets.py --list filament --match "PLA @MK4S" -
Write the complete presets:
python scripts/orca_presets.py --printer "Prusa MK4S 0.4 nozzle" \ --process "0.20mm SPEED @MK4S 0.4" --filament "Prusa Generic PLA @MK4S" \ --out presets -
Slice. Give
--outputdiran absolute path:<orca> model.stl \ --load-settings "presets/process.json;presets/printer.json" \ --load-filaments presets/filament-1.json \ --arrange 1 --slice 0 \ --outputdir /absolute/path/to/out --export-3mf model.gcode.3mfThis writes
plate_1.gcode, the plain G-code, andmodel.gcode.3mf, the sliced 3MF, into that folder. The command line reads.stl,.3mf,.objand.amf; export STEP to STL or 3MF first (for a text-to-cad model,cad export <id> part.3mf, orcad export part.step part.3mf). Override one setting with--<setting>=<value>, using the setting's key with hyphens for underscores, such as--layer-height=0.16.
Open in OrcaSlicer
When the user would rather pick presets and slice themselves, or no preset can
be found, open the model in the app: open -a OrcaSlicer model.stl on macOS,
Start-Process model.stl on Windows when OrcaSlicer opens that file type, or
orca-slicer model.stl on Linux. The app also reads STEP.
Check before printing
-
<orca> model.stl --infoprints the model's size; it has to fit the bed. -
Check the slice's settings, which OrcaSlicer writes at the end of the G-code:
grep -E '^; (printer_model|nozzle_diameter|filament_type|nozzle_temperature|hot_plate_temp|bed_temperature) =|printing time' out/plate_1.gcodeConfirm they match the user's printer and material before anyone prints it.
Hand off
- A Bambu Lab printer: Bambu Connect, with the
.gcode.3mf. - Any other printer: the user prints the
.gcodefrom their printer's app, its web interface (PrusaLink, OctoPrint, Mainsail, Fluidd) or an SD card.
Version History
- 5efa85a Current 2026-11-02 19:24
-
284827c
2026-10-19 02:43
重构了工作流,从通用的 gcode_tool.py 迁移至基于 OrcaSlicer CLI 的具体实现,增加了预设管理和安全检查步骤。
- d0e4cb6 2026-09-09 02:39
-
0.4.28
2026-08-27 16:55
修复了gcode技能中指向错误cad导出命令的问题,更正为正确的export CLI路径,并更新了相关文档和依赖。
- 0.4.12 2026-08-16 02:06
-
0.3.13
2026-08-02 21:21
修复了拒绝非网格输入时的错误处理:使用结构化修复映射替代扁平扩展名集合,明确命名转换技能并提供具体的下一步建议,优化了inspect和slice入口点的错误反馈。
- 0.3.9 2026-07-24 11:54


