kittycad_modeling_cmds/format/
stl.rs1use parse_display::{Display, FromStr};
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5use crate::{coord, format::Selection, units::UnitLength};
6
7pub mod import {
9 use super::*;
10
11 #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)]
13 #[display("coords: {coords}, units: {units}")]
14 #[serde(rename = "StlImportOptions")]
15 #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
16 #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
17 #[cfg_attr(
18 feature = "python",
19 pyo3_stub_gen::derive::gen_stub_pyclass,
20 pyo3::pyclass(name = "StlImportOptions")
21 )]
22 pub struct Options {
23 pub coords: coord::System,
29 pub units: UnitLength,
36 }
37
38 impl Default for Options {
39 fn default() -> Self {
40 Self {
41 coords: *coord::KITTYCAD,
42 units: UnitLength::Millimeters,
43 }
44 }
45 }
46}
47
48pub mod export {
50
51 use super::*;
52
53 #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)]
55 #[display("coords: {coords}, selection: {selection}, storage: {storage}, units: {units}")]
56 #[serde(rename = "StlExportOptions")]
57 #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
58 #[cfg_attr(
59 feature = "python",
60 pyo3_stub_gen::derive::gen_stub_pyclass,
61 pyo3::pyclass(name = "StlExportOptions")
62 )]
63 #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
64 pub struct Options {
65 pub coords: coord::System,
71
72 pub selection: Selection,
74
75 pub storage: Storage,
77
78 pub units: UnitLength,
82 }
83
84 #[cfg(feature = "python")]
85 #[pyo3_stub_gen::derive::gen_stub_pymethods]
86 #[pyo3::pymethods]
87 impl Options {
88 #[new]
89 pub fn new() -> Self {
91 Default::default()
92 }
93 }
94
95 impl Default for Options {
96 fn default() -> Self {
97 Self {
98 coords: *coord::KITTYCAD,
99 selection: Default::default(),
100 storage: Default::default(),
101 units: UnitLength::Millimeters,
102 }
103 }
104 }
105
106 #[derive(
108 Clone, Copy, Debug, Default, Deserialize, Display, Eq, FromStr, Hash, JsonSchema, PartialEq, Serialize,
109 )]
110 #[display(style = "snake_case")]
111 #[serde(rename = "StlStorage", rename_all = "snake_case")]
112 #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
113 #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
114 #[cfg_attr(
115 feature = "python",
116 pyo3_stub_gen::derive::gen_stub_pyclass_enum,
117 pyo3::pyclass(name = "StlStorage")
118 )]
119 pub enum Storage {
120 Ascii,
122
123 #[default]
127 Binary,
128 }
129}