Reference: clones-ref/BambuStudio revision da8b44e. Citations below are relative to that root. This is a source-only inspection: the reference binary was building concurrently; no binary, GUI, build directory or test was run. Unlike Rust craft engines this C++ application has no execute(id, json) -> json command registry: its command surface is argv and files (INFERRED from src/BambuStudio.cpp:8394-8464, src/libslic3r/Config.cpp:1661-1778). The permitted integration is the slicer subprocess, not a linked library.
| Finding | Evidence |
|---|---|
Non-Windows main installs an out-of-memory handler, constructs temporary CLI, returns CLI().run(argc, argv); Windows bambustu_main converts wide argv and takes the same route. run names/saves main thread before setup. | src/BambuStudio.cpp:8782-8818, src/BambuStudio.cpp:1524-1530 |
CLI owns dynamic CLI/print/extra configs, ordered action/transform vectors, input file names, and loaded Model values. setup, export helpers are private: no reusable public JSON API or persistent document handle. run is the only public method. | src/BambuStudio.hpp:114-148 |
setup locates packaged resources relative to executable (FHS alternative), calls DynamicConfig::read_cli, partitions ordered options using cli_actions_config_def and cli_transform_config_def, initializes defaults, resolves --datadir. Unknown CLI flag is refused, value parsing and repeated vector arguments happen in read_cli; -- ends option parsing. | src/BambuStudio.cpp:8394-8463; src/libslic3r/Config.cpp:1661-1778 |
With no action and no downward-check, run enters GUI_Run; --slice=0 or another action is essential to stay in CLI path. On wxGTK it still sets X11 environment and calls XInitThreads; this is not evidence of requiring a visible GUI for slicing. | src/BambuStudio.cpp:1524-1544, src/BambuStudio.cpp:1653-1705; src/libslic3r/PrintConfig.cpp:10017-10030 |
Action registry is three typed ConfigDef sets, not the 500+ craft command registry. CLI dispatch is ordered string comparisons on m_transforms, then m_actions; slice loops plates and calls Print::apply, validate, process, export_gcode. There is no control-channel/MCP dispatch here. | src/libslic3r/PrintConfig.cpp:9938-10039, src/libslic3r/PrintConfig.cpp:10118-10205; src/BambuStudio.cpp:8394-8440, src/BambuStudio.cpp:4980-5035, src/BambuStudio.cpp:6400-6518, src/BambuStudio.cpp:7063-7184 |
Slice 0 means all plates, positive index means selected plate; negative/out-of-range IDs are rejected. --export-3mf filename.3mf is a separate action, not implicitly entailed by --slice; order matters because actions retain argv order. | src/libslic3r/PrintConfig.cpp:9959-9968, src/libslic3r/PrintConfig.cpp:10017-10031; src/BambuStudio.cpp:5395-5409, src/BambuStudio.cpp:6457-6507, src/BambuStudio.cpp:8394-8440 |
A single invocation owns the models, part-plate list, per-plate Print and GCodeResult until outputs are written; all-plates mode releases large PrintObject/G-code path buffers between plates. There is no cross-request lifecycle. CLI cleans plate structures and GLFW on normal exit; flush_and_exit cleans model backups and stops Linux callback worker on errors. | src/BambuStudio.cpp:6515-6555, src/BambuStudio.cpp:7503-7525, src/BambuStudio.cpp:8280-8288, src/BambuStudio.cpp:8342-8384, src/BambuStudio.cpp:469-484 |
--slice=0|N, --export-3mf=filename.3mf, --outputdir=dir, --load-settings="machine.json;process.json", --load-filaments="f1.json;f2.json", optional --uptodate, --uptodate-settings, --uptodate-filaments, --check-preset, --normative-check, --skip-modified-gcodes, --no-check, --pipe, --mtcpp and --mstpp. Do not assume aliases use hyphens: definitions use underscore keys except explicit def->cli overrides (slice, export-png, etc.); cli_args performs spelling conversion, to be checked with built --help before freezing argv. --export-gcode is commented out. src/libslic3r/PrintConfig.cpp:9938-10113, src/libslic3r/PrintConfig.cpp:10230-10345, src/BambuStudio.cpp:8444-8461.Model::read_from_file reads input models. First .3mf includes model, config, instances and auxiliaries; later inputs load model/instances only. BBL 3MF must be first, versions newer than running CLI are refused by default (--allow-newer-file overrides). STL/OBJ and the JSON --load-assemble-list are alternate paths. src/BambuStudio.cpp:1885-1956; src/BambuStudio.hpp:17-75.--load-settings/--load-filaments > 3MF (src/BambuStudio.cpp:8473-8492). The load lambda calls DynamicPrintConfig::load_from_json, requires from system/User/user and type machine/process/filament, normalizes FDM and returns CLI errors on parse failure (src/BambuStudio.cpp:2296-2367). Machine/printer, process and filament configs merge into the full print config; embedded system presets resolve under resources_dir()/profiles/BBL/{machine_full,process_full,filament_full}/ and cli_config.json supplies limits/compatibility (src/BambuStudio.cpp:2371-2460, src/BambuStudio.cpp:2880-3200, src/BambuStudio.cpp:3700-3760). --check-preset checks filament compatible_printers against target machine (src/BambuStudio.cpp:3365-3415). INFERRED: an adapter must ship the executable with its resources, not just a standalone binary (src/BambuStudio.cpp:8410-8434).--slice emits plate_N.gcode in outputdir or a plate temporary path, via Print::export_gcode; --export-3mf combines a model/config, plate metadata and G-code with SaveStrategy::WithGcode through CLI::export_project -> store_bbs_3mf. Thus to request output.gcode.3mf, explicitly pass --export-3mf=output.gcode.3mf after --slice; the extension is a requested filename, not a hard-coded suffix. 3MF archive path is Metadata/plate_%1%.gcode. src/BambuStudio.cpp:7264-7290, src/BambuStudio.cpp:8230-8269, src/BambuStudio.cpp:8580-8608, src/libslic3r/Format/bbs_3mf.hpp:24-36.result.json is written to outputdir (otherwise cwd), including plate_index, return_code, error_string, timing, RSS, parameter summary and sliced_plates (per-plate warnings, object bbox/triangles, filament grams, estimated time). It is best-effort: record_exit_reson swallows all write exceptions, so success exit alone does not certify JSON exists. src/BambuStudio.cpp:486-545, src/BambuStudio.cpp:570-644, src/BambuStudio.cpp:638-660, src/BambuStudio.cpp:8360-8384.--pipe opens an existing named pipe, starts a Boost worker thread and sends newline-terminated JSON progress/warning objects (plate_index, plate_count, plate_percent, total_percent, message/warning). Optional: its open retries, then fails without aborting slicing. src/BambuStudio.cpp:280-327, src/BambuStudio.cpp:373-425, src/BambuStudio.cpp:1786-1803. No requirement to use progress pipe in initial adapter (INFERRED).cli_errors table: bad argv, absent files, malformed config/model, non-FFF technology, incompatible preset, geometry/arrange, invalid 3MF, validation, slicing, conflict/out-of-bed/unprintable G-code and failed 3MF export. setup failure returns CLI_INVALID_PARAMS; flush_and_exit returns exact code after cleanup; record_exit_reson writes it to JSON when possible. src/BambuStudio.cpp:126-187, src/BambuStudio.cpp:469-506, src/BambuStudio.cpp:1595-1605. Host should report numeric exit, stderr and parsed result as separate evidence; do not infer success from file presence alone (INFERRED).Print::validate maps typed exceptions to codes; Print::process and export run inside catch (const std::exception&) -> CLI_SLICING_ERROR; OOM new_handler deliberately crashes, and result.json writer's catch (...) suppresses its own failures. No guarantee every crash gives a structured result. src/BambuStudio.cpp:7063-7098, src/BambuStudio.cpp:7525-7534, src/BambuStudio.cpp:8738-8782, src/BambuStudio.cpp:638-660.--slice avoids GUI_Run, and BBL-vendor export passes null thumbnail callback; non-BBL path may initialize hidden GLFW window, request Linux OSMesa context and fall back to G-code without thumbnails on GL failure. --export-3mf may try thumbnails when missing; hidden GL is still a rendering dependency, not a guarantee of display-free 3MF generation. No runtime measurement yet. src/BambuStudio.cpp:1653-1705, src/BambuStudio.cpp:6282-6325, src/BambuStudio.cpp:7250-7284, src/BambuStudio.cpp:7580-7650.process, path outside printable area, wrapping-detect area and filament unprintable on first layer after export. They are not a dangerous-command allow/deny list; --no-check relaxes some checks, so guard it off by default (INFERRED). src/BambuStudio.cpp:7193-7235, src/BambuStudio.cpp:7288-7331, src/libslic3r/PrintConfig.cpp:10075-10085.GCodeFlavor enum but the active config values in this revision are only marlin and klipper (default MarlinLegacy; other entries commented out). Writer outputs G90/G21, M82/M83, M104/M109, M140/M190, M204, and Klipper SET_PRESSURE_ADVANCE / Marlin M900; vendor/custom start/end/filament/change/pause/layer scripts are arbitrary strings, and custom per-Z JSON CustomGCode::Item.extra carries executable G-code. Guard should inspect actual emitted G-code and custom script surfaces, not treat flavour selection as proof of safety (INFERRED). src/libslic3r/PrintConfig.hpp:38-40, src/libslic3r/PrintConfig.cpp:3797-3830, src/libslic3r/GCodeWriter.cpp:87-165, src/libslic3r/GCodeWriter.cpp:173-185, src/libslic3r/GCodeWriter.cpp:318-343, src/BambuStudio.cpp:749-785, src/libslic3r/CustomGCode.hpp:14-64.| Noun / vocabulary | Shape and evidence |
|---|---|
| Project/model, object, volume, instance | Model owns materials and object pointers; objects own instances/volumes; meshes/transforms/configs are in-memory C++, not JSON handles. src/libslic3r/Model.hpp:1670-1698, src/libslic3r/Model.hpp:655-690, src/libslic3r/Model.hpp:1051-1085 |
| Plate, filament, slice result | PlateData stores plate index, objects/instances, filament slots/maps, G-code path, thumbnails and metadata; sliced_plate_info_t holds times, objects and filament quantities. src/libslic3r/Format/bbs_3mf.hpp:72-145, src/BambuStudio.cpp:197-256 |
| Process/machine/filament preset | Typed JSON profile category; names/compatible-printer lists and installed profiles/BBL/*_full filenames are open data, not a finite enum. src/BambuStudio.cpp:2296-2460, src/BambuStudio.cpp:2880-3200 |
| CLI actions/transforms | Finite typed ConfigDef definitions; parser refuses unknown flags and explicit comparison dispatch refuses unsupported actions. Closed for this binary revision; do not substitute a catch-all command-id JSON API. src/libslic3r/PrintConfig.cpp:9938-10205, src/libslic3r/Config.cpp:1692-1711, src/BambuStudio.cpp:6430-6510 |
| Flavour, infill, print sequence, custom item type | Closed C++ enums (GCodeFlavor, InfillPattern, PrintSequence, CustomGCode::Type). Active flavour config narrower than enum. Arbitrary G-code text and configurable option keys remain open strings. src/libslic3r/PrintConfig.hpp:38-40, src/libslic3r/PrintConfig.hpp:80-91, src/libslic3r/PrintConfig.hpp:146-153, src/libslic3r/CustomGCode.hpp:14-64, src/BambuStudio.cpp:749-785 |
bambu-studio --slice=N --export-3mf=output.gcode.3mf --outputdir=... input.3mf; collect exit/stderr, result.json, plate_N.gcode and archive. Pro: matches complete native profile/plate machinery; no C++ linkage. Cons: resources and optional headless GL, temp/size/timeout/exit handling. INFERRED proposal from src/BambuStudio.cpp:1885-1956, src/BambuStudio.cpp:6457-6507, src/BambuStudio.cpp:7264-7290, src/BambuStudio.cpp:8230-8269.--load-assemble-list JSON + presets: for raw STL/OBJ assemblies requiring per-plate objects, positions, filament assignments. Pro: structured input without authoring 3MF; cons: JSON schema and preset compatibility are complex, demands --load-settings/--load-filaments. INFERRED proposal from src/BambuStudio.hpp:17-75, src/BambuStudio.cpp:804-860, src/BambuStudio.cpp:1885-1906.Model::read_from_file / Print::process / store_bbs_3mf: technically present but rejected for this addon: links C++/AGPL, bypasses CLI orchestration and shifts lifetime/GL into host; not a permitted alternative. INFERRED proposal from src/BambuStudio.cpp:1914-1934, src/BambuStudio.cpp:7063-7184, src/BambuStudio.cpp:8580-8608.Open checks for wave 2: verify actual executable --help spelling, argv order and a real fixture/exit/result.json/archive once build completes; test no-display BBL slice and 3MF thumbnail path; inspect final archive structure and dangerous G-code with a sample. No build or execution was attempted in this read-only study (src/BambuStudio.cpp:8444-8492, src/BambuStudio.cpp:6282-6325, src/libslic3r/Format/bbs_3mf.hpp:24-36).
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |