microcad_export/stl/
exporter.rs1use microcad_lang::{
7 builtin::{ExportError, Exporter, FileIoInterface},
8 model::{Model, OutputType},
9 value::Value,
10};
11
12use microcad_lang_base::Id;
13
14use crate::stl::{StlWriter, WriteStl};
15
16pub struct StlExporter;
18
19impl Exporter for StlExporter {
20 fn export(&self, model: &Model, filename: &std::path::Path) -> Result<Value, ExportError> {
21 let mut f = std::fs::File::create(filename)?;
22 let mut writer = StlWriter::new(&mut f)?;
23 model.write_stl(&mut writer)?;
24 Ok(Value::None)
25 }
26
27 fn output_type(&self) -> OutputType {
28 OutputType::Geometry3D
29 }
30}
31
32impl FileIoInterface for StlExporter {
33 fn id(&self) -> Id {
34 Id::new("stl")
35 }
36}