kittycad_modeling_cmds/format/
step.rs1use bon::Builder;
2use parse_display::{Display, FromStr};
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6use crate::coord;
7
8pub mod import {
10 use super::*;
11
12 #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
14 #[serde(default, rename = "StepImportOptions")]
15 #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
16 #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
17 #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
18 #[cfg_attr(
19 feature = "python",
20 pyo3_stub_gen::derive::gen_stub_pyclass,
21 pyo3::pyclass(name = "StepImportOptions")
22 )]
23 #[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
24 pub struct Options {
25 #[builder(default = *coord::KITTYCAD)]
31 pub coords: coord::System,
32
33 #[builder(default)]
37 pub split_closed_faces: bool,
38 }
39
40 #[cfg(feature = "python")]
41 #[pyo3_stub_gen::derive::gen_stub_pymethods]
42 #[pyo3::pymethods]
43 impl Options {
44 #[new]
45 pub fn new() -> Self {
47 Default::default()
48 }
49 }
50
51 impl Default for Options {
52 fn default() -> Self {
53 Self {
54 coords: *coord::KITTYCAD,
55 split_closed_faces: false,
56 }
57 }
58 }
59}
60
61pub mod export {
63 use super::*;
64 use crate::units::UnitLength;
65
66 #[derive(
68 Default, Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr,
69 )]
70 #[display(style = "snake_case")]
71 #[serde(rename = "StepPresentation", rename_all = "snake_case")]
72 #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
73 #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
74 #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
75 #[cfg_attr(
76 feature = "python",
77 pyo3_stub_gen::derive::gen_stub_pyclass_enum,
78 pyo3::pyclass(name = "StepPresentation")
79 )]
80 #[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
81 pub enum Presentation {
82 Compact,
84
85 #[default]
89 Pretty,
90 }
91
92 #[derive(Clone, Debug, Deserialize, Eq, Hash, JsonSchema, PartialEq, Serialize, Builder)]
94 #[serde(default, rename = "StepExportOptions")]
95 #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
96 #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
97 #[cfg_attr(
98 feature = "python",
99 pyo3_stub_gen::derive::gen_stub_pyclass,
100 pyo3::pyclass(name = "StepExportOptions")
101 )]
102 #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
103 #[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
104 pub struct Options {
105 #[builder(default = default_coords())]
111 pub coords: coord::System,
112
113 pub created: Option<chrono::DateTime<chrono::Utc>>,
115
116 #[builder(default = default_units())]
120 pub units: UnitLength,
121
122 #[builder(default = default_presentation())]
124 pub presentation: Presentation,
125 }
126
127 #[cfg(feature = "python")]
128 #[pyo3_stub_gen::derive::gen_stub_pymethods]
129 #[pyo3::pymethods]
130 impl Options {
131 #[new]
132 pub fn new() -> Self {
134 Default::default()
135 }
136 }
137
138 impl Default for Options {
139 fn default() -> Self {
140 Self {
141 coords: default_coords(),
142 created: None,
143 units: default_units(),
144 presentation: default_presentation(),
145 }
146 }
147 }
148
149 const fn default_presentation() -> Presentation {
150 Presentation::Pretty
151 }
152
153 const fn default_coords() -> coord::System {
154 *coord::KITTYCAD
155 }
156
157 const fn default_units() -> UnitLength {
158 UnitLength::Meters
159 }
160}