pub fn convert(input: PathBuf, output: PathBuf, ascii: bool) -> Result<()>Expand description
Convert between 3D formats (3MF, STL, OBJ).
Auto-detects formats based on file extensions and performs the appropriate conversion.
Supported conversions:
- STL (binary or ASCII, auto-detected) → 3MF
- OBJ → 3MF
- 3MF → STL (binary by default, ASCII with
ascii = true) - 3MF → OBJ
§Arguments
input- Input file pathoutput- Output file pathascii- Whentrueand output is.stl, write ASCII STL instead of binary
§Errors
Returns an error if the format is unsupported or conversion fails.
§Example
use lib3mf_cli::commands::convert;
use std::path::PathBuf;
// Binary STL export (default)
convert(PathBuf::from("mesh.stl"), PathBuf::from("model.3mf"), false)?;
// ASCII STL export
convert(PathBuf::from("model.3mf"), PathBuf::from("mesh.stl"), true)?;