kittycad_modeling_cmds/
def_enum.rs

1use kittycad_modeling_cmds_macros::define_modeling_cmd_enum;
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5pub use self::each_cmd::*;
6use crate::{self as kittycad_modeling_cmds};
7
8define_modeling_cmd_enum! {
9    pub mod each_cmd {
10        use std::collections::HashSet;
11
12        use crate::{self as kittycad_modeling_cmds};
13        use kittycad_modeling_cmds_macros::{ModelingCmdVariant};
14        use parse_display_derive::{Display, FromStr};
15        use schemars::JsonSchema;
16        use serde::{Deserialize, Serialize};
17        use uuid::Uuid;
18        use crate::shared::CameraViewState;
19
20        use crate::{
21            format::{OutputFormat2d, OutputFormat3d},
22            id::ModelingCmdId,
23            length_unit::LengthUnit,
24            shared::{
25                Angle,
26                BodyType,
27                ComponentTransform,
28                RelativeTo,
29                CutType, CutTypeV2,
30                CutStrategy,
31                CameraMovement,
32                ExtrudedFaceInfo, ExtrudeMethod,
33                AnnotationOptions, AnnotationType, CameraDragInteractionType, Color, DistanceType, EntityType,
34                PathComponentConstraintBound, PathComponentConstraintType, PathSegment, PerspectiveCameraParameters,
35                Point2d, Point3d, ExtrudeReference, SceneSelectionType, SceneToolType, Opposite,
36            },
37            units,
38        };
39
40        /// Mike says this usually looks nice.
41        fn default_animation_seconds() -> f64 {
42            0.4
43        }
44
45        /// Default empty uuid vector.
46        fn default_uuid_vector() -> Vec<Uuid> {
47            Vec::new()
48        }
49
50        /// Evaluates the position of a path in one shot (engine utility for kcl executor)
51        #[derive(
52            Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant,
53        )]
54        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
55        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
56        pub struct EngineUtilEvaluatePath {
57            /// The path in json form (the serialized result of the kcl Sketch/Path object
58            pub path_json: String,
59
60            /// The evaluation parameter (path curve parameter in the normalized domain [0, 1])
61            pub t: f64,
62        }
63
64        /// Start a new path.
65        #[derive(
66            Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant,
67        )]
68        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
69        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
70        pub struct StartPath {}
71
72        /// Move the path's "pen".
73        /// If you're in sketch mode, these coordinates are in the local coordinate system,
74        /// not the world's coordinate system.
75        /// For example, say you're sketching on the plane {x: (1,0,0), y: (0,1,0), origin: (0, 0, 50)}.
76        /// In other words, the plane 50 units above the default XY plane. Then, moving the pen
77        /// to (1, 1, 0) with this command uses local coordinates. So, it would move the pen to
78        /// (1, 1, 50) in global coordinates.
79        #[derive(
80            Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant,
81        )]
82        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
83        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
84        pub struct MovePathPen {
85            /// The ID of the command which created the path.
86            pub path: ModelingCmdId,
87            /// Where the path's pen should be.
88            pub to: Point3d<LengthUnit>,
89        }
90
91        /// Extend a path by adding a new segment which starts at the path's "pen".
92        /// If no "pen" location has been set before (via `MovePen`), then the pen is at the origin.
93        #[derive(
94            Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant,
95        )]
96        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
97        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
98        pub struct ExtendPath {
99            /// The ID of the command which created the path.
100            pub path: ModelingCmdId,
101            /// Segment to append to the path.
102            /// This segment will implicitly begin at the current "pen" location.
103            pub segment: PathSegment,
104            /// Optional label to associate with the new path segment.
105            #[serde(default, skip_serializing_if = "Option::is_none")]
106            pub label: Option<String>,
107        }
108
109        /// Command for extruding a solid 2d.
110        #[derive(
111            Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant,
112        )]
113        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
114        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
115        pub struct Extrude {
116            /// Which sketch to extrude.
117            /// Must be a closed 2D solid.
118            pub target: ModelingCmdId,
119            /// How far off the plane to extrude
120            pub distance: LengthUnit,
121            /// Which IDs should the new faces have?
122            /// If this isn't given, the engine will generate IDs.
123            #[serde(default)]
124            pub faces: Option<ExtrudedFaceInfo>,
125            /// Should the extrusion also extrude in the opposite direction?
126            /// If so, this specifies its distance.
127            #[serde(default)]
128            pub opposite: Opposite<LengthUnit>,
129            /// Should the extrusion create a new object or be part of the existing object.
130            #[serde(default)]
131            pub extrude_method: ExtrudeMethod,
132            /// Should this extrude create a solid body or a surface?
133            #[serde(default)]
134            pub body_type: BodyType,
135        }
136
137        /// Command for extruding a solid 2d to a reference geometry.
138        #[derive(
139            Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant,
140        )]
141        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
142        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
143        pub struct ExtrudeToReference {
144            /// Which sketch to extrude.
145            /// Must be a closed 2D solid.
146            pub target: ModelingCmdId,
147            /// Reference to extrude to.
148            /// Extrusion occurs along the target's normal until it is as close to the reference as possible.
149            pub reference: ExtrudeReference,
150            /// Which IDs should the new faces have?
151            /// If this isn't given, the engine will generate IDs.
152            #[serde(default)]
153            pub faces: Option<ExtrudedFaceInfo>,
154            /// Should the extrusion create a new object or be part of the existing object.
155            #[serde(default)]
156            pub extrude_method: ExtrudeMethod,
157            /// Should this extrude create a solid body or a surface?
158            #[serde(default)]
159            pub body_type: BodyType,
160        }
161
162        fn default_twist_extrude_section_interval() -> Angle {
163            Angle::from_degrees(15.0)
164        }
165
166        /// Command for twist extruding a solid 2d.
167        #[derive(
168            Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant,
169        )]
170        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
171        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
172        pub struct TwistExtrude {
173            /// Which sketch to extrude.
174            /// Must be a closed 2D solid.
175            pub target: ModelingCmdId,
176            /// How far off the plane to extrude
177            pub distance: LengthUnit,
178            /// Which IDs should the new faces have?
179            /// If this isn't given, the engine will generate IDs.
180            #[serde(default)]
181            pub faces: Option<ExtrudedFaceInfo>,
182            /// Center to twist about (relative to 2D sketch)
183            #[serde(default)]
184            pub center_2d: Point2d<f64>,
185            /// Total rotation of the section
186            pub total_rotation_angle: Angle,
187            ///Angle step interval (converted to whole number degrees and bounded between 4° and 90°)
188            #[serde(default = "default_twist_extrude_section_interval")]
189            pub angle_step_size: Angle,
190            ///The twisted surface loft tolerance
191            pub tolerance: LengthUnit,
192            /// Should this extrude create a solid body or a surface?
193            #[serde(default)]
194            pub body_type: BodyType,
195        }
196
197        /// Extrude the object along a path.
198        #[derive(
199            Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant,
200        )]
201        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
202        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
203        pub struct Sweep {
204            /// Which sketch to sweep.
205            /// Must be a closed 2D solid.
206            pub target: ModelingCmdId,
207            /// Path along which to sweep.
208            pub trajectory: ModelingCmdId,
209            /// If true, the sweep will be broken up into sub-sweeps (extrusions, revolves, sweeps) based on the trajectory path components.
210            pub sectional: bool,
211            /// The maximum acceptable surface gap computed between the revolution surface joints. Must be positive (i.e. greater than zero).
212            pub tolerance: LengthUnit,
213            /// What is this sweep relative to?
214            #[serde(default)]
215            pub relative_to: RelativeTo,
216        }
217
218        /// Command for revolving a solid 2d.
219        #[derive(
220            Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant,
221        )]
222        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
223        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
224        pub struct Revolve {
225            /// Which sketch to revolve.
226            /// Must be a closed 2D solid.
227            pub target: ModelingCmdId,
228            /// The origin of the extrusion axis
229            pub origin: Point3d<LengthUnit>,
230            /// The axis of the extrusion (taken from the origin)
231            pub axis: Point3d<f64>,
232            /// If true, the axis is interpreted within the 2D space of the solid 2D's plane
233            pub axis_is_2d: bool,
234            /// The signed angle of revolution (in degrees, must be <= 360 in either direction)
235            pub angle: Angle,
236            /// The maximum acceptable surface gap computed between the revolution surface joints. Must be positive (i.e. greater than zero).
237            pub tolerance: LengthUnit,
238            /// Should the revolution also revolve in the opposite direction along the given axis?
239            /// If so, this specifies its angle.
240            #[serde(default)]
241            pub opposite: Opposite<Angle>,
242            /// Should this extrude create a solid body or a surface?
243            #[serde(default)]
244            pub body_type: BodyType,
245        }
246
247        /// Command for shelling a solid3d face
248        #[derive(
249            Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant,
250        )]
251        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
252        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
253        pub struct Solid3dShellFace {
254            /// Which Solid3D is being shelled.
255            pub object_id: Uuid,
256            /// Which faces to remove, leaving only the shell.
257            pub face_ids: Vec<Uuid>,
258            /// How thick the shell should be.
259            /// Smaller values mean a thinner shell.
260            pub shell_thickness: LengthUnit,
261            /// If true, the Solid3D is made hollow instead of removing the selected faces
262            #[serde(default)]
263            pub hollow: bool,
264        }
265
266        /// Command for revolving a solid 2d about a brep edge
267        #[derive(
268            Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant,
269        )]
270        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
271        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
272        pub struct RevolveAboutEdge {
273            /// Which sketch to revolve.
274            /// Must be a closed 2D solid.
275            pub target: ModelingCmdId,
276            /// The edge to use as the axis of revolution, must be linear and lie in the plane of the solid
277            pub edge_id: Uuid,
278            /// The signed angle of revolution (in degrees, must be <= 360 in either direction)
279            pub angle: Angle,
280            /// The maximum acceptable surface gap computed between the revolution surface joints. Must be positive (i.e. greater than zero).
281            pub tolerance: LengthUnit,
282            /// Should the revolution also revolve in the opposite direction along the given axis?
283            /// If so, this specifies its angle.
284            #[serde(default)]
285            pub opposite: Opposite<Angle>,
286            /// Should this extrude create a solid body or a surface?
287            #[serde(default)]
288            pub body_type: BodyType,
289        }
290
291        /// Command for lofting sections to create a solid
292        #[derive(
293            Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant
294        )]
295        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
296        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
297        pub struct Loft {
298            /// The closed section curves to create a lofted solid from.
299            /// Currently, these must be Solid2Ds
300            pub section_ids: Vec<Uuid>,
301            /// Degree of the interpolation. Must be greater than zero.
302            /// For example, use 2 for quadratic, or 3 for cubic interpolation in the V direction.
303            pub v_degree: std::num::NonZeroU32,
304            /// Attempt to approximate rational curves (such as arcs) using a bezier.
305            /// This will remove banding around interpolations between arcs and non-arcs.  It may produce errors in other scenarios
306            /// Over time, this field won't be necessary.
307            pub bez_approximate_rational: bool,
308            /// This can be set to override the automatically determined topological base curve, which is usually the first section encountered.
309            pub base_curve_index: Option<u32>,
310            /// Tolerance
311            pub tolerance: LengthUnit,
312        }
313
314
315        /// Closes a path, converting it to a 2D solid.
316        #[derive(
317            Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant,
318        )]
319        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
320        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
321        pub struct ClosePath {
322            /// Which path to close.
323            pub path_id: Uuid,
324        }
325
326        /// Camera drag started.
327        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
328        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
329        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
330        pub struct CameraDragStart {
331            /// The type of camera drag interaction.
332            pub interaction: CameraDragInteractionType,
333            /// The initial mouse position.
334            pub window: Point2d,
335        }
336
337        /// Camera drag continued.
338        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
339        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
340        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
341        pub struct CameraDragMove {
342            /// The type of camera drag interaction.
343            pub interaction: CameraDragInteractionType,
344            /// The current mouse position.
345            pub window: Point2d,
346            /// Logical timestamp. The client should increment this
347            /// with every event in the current mouse drag. That way, if the
348            /// events are being sent over an unordered channel, the API
349            /// can ignore the older events.
350            pub sequence: Option<u32>,
351        }
352
353        /// Camera drag ended
354        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
355        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
356        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
357        pub struct CameraDragEnd {
358            /// The type of camera drag interaction.
359            pub interaction: CameraDragInteractionType,
360            /// The final mouse position.
361            pub window: Point2d,
362        }
363
364        /// Gets the default camera's camera settings
365        #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
366        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
367        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
368        pub struct DefaultCameraGetSettings {}
369
370        /// Gets the default camera's view state
371        #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
372        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
373        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
374        pub struct DefaultCameraGetView {}
375
376        /// Sets the default camera's view state
377        #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
378        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
379        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
380        pub struct DefaultCameraSetView {
381            /// Camera view state
382            pub view: CameraViewState,
383        }
384
385        /// Change what the default camera is looking at.
386        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
387        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
388        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
389        pub struct DefaultCameraLookAt {
390            /// Where the camera is positioned
391            pub vantage: Point3d,
392            /// What the camera is looking at. Center of the camera's field of vision
393            pub center: Point3d,
394            /// Which way is "up", from the camera's point of view.
395            pub up: Point3d,
396            /// Logical timestamp. The client should increment this
397            /// with every event in the current mouse drag. That way, if the
398            /// events are being sent over an unordered channel, the API
399            /// can ignore the older events.
400            pub sequence: Option<u32>,
401        }
402
403        /// Change what the default camera is looking at.
404        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
405        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
406        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
407        pub struct DefaultCameraPerspectiveSettings {
408            /// Where the camera is positioned
409            pub vantage: Point3d,
410            /// What the camera is looking at. Center of the camera's field of vision
411            pub center: Point3d,
412            /// Which way is "up", from the camera's point of view.
413            pub up: Point3d,
414            /// The field of view angle in the y direction, in degrees.
415            pub fov_y: Option<f32>,
416            /// The distance to the near clipping plane.
417            pub z_near: Option<f32>,
418            /// The distance to the far clipping plane.
419            pub z_far: Option<f32>,
420            /// Logical timestamp. The client should increment this
421            /// with every event in the current mouse drag. That way, if the
422            /// events are being sent over an unordered channel, the API
423            /// can ignore the older events.
424            pub sequence: Option<u32>,
425        }
426
427        /// Adjust zoom of the default camera.
428        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
429        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
430        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
431        pub struct DefaultCameraZoom {
432            /// Move the camera forward along the vector it's looking at,
433            /// by this magnitudedefaultCameraZoom.
434            /// Basically, how much should the camera move forward by.
435            pub magnitude: f32,
436        }
437
438        /// Export a sketch to a file.
439        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
440        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
441        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
442        pub struct Export2d {
443            /// IDs of the entities to be exported.
444            pub entity_ids: Vec<Uuid>,
445            /// The file format to export to.
446            pub format: OutputFormat2d,
447        }
448
449        /// Export the scene to a file.
450        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
451        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
452        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
453        pub struct Export3d {
454            /// IDs of the entities to be exported. If this is empty, then all entities are exported.
455            pub entity_ids: Vec<Uuid>,
456            /// The file format to export to.
457            pub format: OutputFormat3d,
458        }
459
460        /// Export the scene to a file.
461        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
462        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
463        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
464        pub struct Export {
465            /// IDs of the entities to be exported. If this is empty, then all entities are exported.
466            pub entity_ids: Vec<Uuid>,
467            /// The file format to export to.
468            pub format: OutputFormat3d,
469        }
470
471        /// What is this entity's parent?
472        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
473        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
474        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
475        pub struct EntityGetParentId {
476            /// ID of the entity being queried.
477            pub entity_id: Uuid,
478        }
479
480        /// How many children does the entity have?
481        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
482        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
483        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
484        pub struct EntityGetNumChildren {
485            /// ID of the entity being queried.
486            pub entity_id: Uuid,
487        }
488
489        /// What is the UUID of this entity's n-th child?
490        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
491        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
492        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
493        pub struct EntityGetChildUuid {
494            /// ID of the entity being queried.
495            pub entity_id: Uuid,
496            /// Index into the entity's list of children.
497            pub child_index: u32,
498        }
499
500        /// What are all UUIDs of this entity's children?
501        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
502        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
503        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
504        pub struct EntityGetAllChildUuids {
505            /// ID of the entity being queried.
506            pub entity_id: Uuid,
507        }
508
509        /// What are all UUIDs of all the paths sketched on top of this entity?
510        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
511        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
512        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
513        pub struct EntityGetSketchPaths {
514            /// ID of the entity being queried.
515            pub entity_id: Uuid,
516        }
517
518        /// What is the distance between these two entities?
519        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
520        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
521        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
522        pub struct EntityGetDistance {
523            /// ID of the first entity being queried.
524            pub entity_id1: Uuid,
525            /// ID of the second entity being queried.
526            pub entity_id2: Uuid,
527            /// Type of distance to be measured.
528            pub distance_type: DistanceType,
529        }
530
531        /// Create a pattern using this entity by specifying the transform for each desired repetition.
532        /// Transformations are performed in the following order (first applied to last applied): scale, rotate, translate.
533        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
534        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
535        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
536        pub struct EntityClone {
537            /// ID of the entity being cloned.
538            pub entity_id: Uuid,
539        }
540
541        /// Create a pattern using this entity by specifying the transform for each desired repetition.
542        /// Transformations are performed in the following order (first applied to last applied): scale, rotate, translate.
543        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
544        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
545        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
546        pub struct EntityLinearPatternTransform {
547            /// ID of the entity being copied.
548            pub entity_id: Uuid,
549            /// How to transform each repeated solid.
550            /// The 0th transform will create the first copy of the entity.
551            /// The total number of (optional) repetitions equals the size of this list.
552            #[serde(default)]
553            pub transform: Vec<crate::shared::Transform>,
554            /// Alternatively, you could set this key instead.
555            /// If you want to use multiple transforms per item.
556            /// If this is non-empty then the `transform` key must be empty, and vice-versa.
557            #[serde(default)]
558            pub transforms: Vec<Vec<crate::shared::Transform>>,
559        }
560
561        /// Create a linear pattern using this entity.
562        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
563        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
564        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
565        pub struct EntityLinearPattern {
566            /// ID of the entity being copied.
567            pub entity_id: Uuid,
568            /// Axis along which to make the copies.
569            /// For Solid2d patterns, the z component is ignored.
570            pub axis: Point3d<f64>,
571            /// Number of repetitions to make.
572            pub num_repetitions: u32,
573            /// Spacing between repetitions.
574            pub spacing: LengthUnit,
575        }
576        /// Create a circular pattern using this entity.
577        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
578        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
579        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
580        pub struct EntityCircularPattern {
581            /// ID of the entity being copied.
582            pub entity_id: Uuid,
583            /// Axis around which to make the copies.
584            /// For Solid2d patterns, this is ignored.
585            pub axis: Point3d<f64>,
586            /// Point around which to make the copies.
587            /// For Solid2d patterns, the z component is ignored.
588            pub center: Point3d<LengthUnit>,
589            /// Number of repetitions to make.
590            pub num_repetitions: u32,
591            /// Arc angle (in degrees) to place repetitions along.
592            pub arc_degrees: f64,
593            /// Whether or not to rotate the objects as they are copied.
594            pub rotate_duplicates: bool,
595        }
596
597        /// Create a helix using the input cylinder and other specified parameters.
598        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
599        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
600        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
601        pub struct EntityMakeHelix {
602            /// ID of the cylinder.
603            pub cylinder_id: Uuid,
604            /// Number of revolutions.
605            pub revolutions: f64,
606            /// Start angle.
607            #[serde(default)]
608            pub start_angle: Angle,
609            /// Is the helix rotation clockwise?
610            pub is_clockwise: bool,
611            /// Length of the helix. If None, the length of the cylinder will be used instead.
612            pub length: Option<LengthUnit>,
613        }
614
615        /// Create a helix using the specified parameters.
616        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
617        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
618        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
619        pub struct EntityMakeHelixFromParams {
620            /// Radius of the helix.
621            pub radius: LengthUnit,
622            /// Length of the helix.
623            pub length: LengthUnit,
624            /// Number of revolutions.
625            pub revolutions: f64,
626            /// Start angle.
627            #[serde(default)]
628            pub start_angle: Angle,
629            /// Is the helix rotation clockwise?
630            pub is_clockwise: bool,
631            /// Center of the helix at the base of the helix.
632            pub center: Point3d<LengthUnit>,
633            /// Axis of the helix. The helix will be created around and in the direction of this axis.
634            pub axis: Point3d<f64>,
635        }
636
637        /// Create a helix using the specified parameters.
638        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
639        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
640        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
641        pub struct EntityMakeHelixFromEdge {
642            /// Radius of the helix.
643            pub radius: LengthUnit,
644            /// Length of the helix. If None, the length of the edge will be used instead.
645            pub length: Option<LengthUnit>,
646            /// Number of revolutions.
647            pub revolutions: f64,
648            /// Start angle.
649            #[serde(default)]
650            pub start_angle: Angle,
651            /// Is the helix rotation clockwise?
652            pub is_clockwise: bool,
653            /// Edge about which to make the helix.
654            pub edge_id: Uuid,
655        }
656
657        /// Mirror the input entities over the specified axis. (Currently only supports sketches)
658        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
659        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
660        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
661        pub struct EntityMirror {
662            /// ID of the mirror entities.
663            pub ids: Vec<Uuid>,
664            /// Axis to use as mirror.
665            pub axis: Point3d<f64>,
666            /// Point through which the mirror axis passes.
667            pub point: Point3d<LengthUnit>,
668        }
669
670        /// Mirror the input entities over the specified edge. (Currently only supports sketches)
671        #[derive(
672            Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant,
673        )]
674        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
675        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
676        pub struct EntityMirrorAcrossEdge {
677            /// ID of the mirror entities.
678            pub ids: Vec<Uuid>,
679            /// The edge to use as the mirror axis, must be linear and lie in the plane of the solid
680            pub edge_id: Uuid,
681        }
682
683        /// Modifies the selection by simulating a "mouse click" at the given x,y window coordinate
684        /// Returns ID of whatever was selected.
685        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
686        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
687        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
688        pub struct SelectWithPoint {
689            /// Where in the window was selected
690            pub selected_at_window: Point2d,
691            /// What entity was selected?
692            pub selection_type: SceneSelectionType,
693        }
694
695        /// Adds one or more entities (by UUID) to the selection.
696        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
697        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
698        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
699        pub struct SelectAdd {
700            /// Which entities to select
701            pub entities: Vec<Uuid>,
702        }
703
704        /// Removes one or more entities (by UUID) from the selection.
705        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
706        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
707        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
708        pub struct SelectRemove {
709            /// Which entities to unselect
710            pub entities: Vec<Uuid>,
711        }
712
713        /// Removes all of the Objects in the scene
714        #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
715        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
716        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
717        pub struct SceneClearAll {}
718
719        /// Replaces current selection with these entities (by UUID).
720        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
721        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
722        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
723        pub struct SelectReplace {
724            /// Which entities to select
725            pub entities: Vec<Uuid>,
726        }
727
728        /// Changes the current highlighted entity to whichever one is at the given window coordinate.
729        /// If there's no entity at this location, clears the highlight.
730        #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
731        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
732        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
733        pub struct HighlightSetEntity {
734            /// Coordinates of the window being clicked
735            pub selected_at_window: Point2d,
736            /// Logical timestamp. The client should increment this
737            /// with every event in the current mouse drag. That way, if the
738            /// events are being sent over an unordered channel, the API
739            /// can ignore the older events.
740            pub sequence: Option<u32>,
741        }
742
743        /// Changes the current highlighted entity to these entities.
744        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
745        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
746        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
747        pub struct HighlightSetEntities {
748            /// Highlight these entities.
749            pub entities: Vec<Uuid>,
750        }
751
752        /// Create a new annotation
753        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
754        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
755        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
756        pub struct NewAnnotation {
757            /// What should the annotation contain?
758            pub options: AnnotationOptions,
759            /// If true, any existing drawables within the obj will be replaced (the object will be reset)
760            pub clobber: bool,
761            /// What type of annotation to create.
762            pub annotation_type: AnnotationType,
763        }
764
765        /// Update an annotation
766        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
767        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
768        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
769        pub struct UpdateAnnotation {
770            /// Which annotation to update
771            pub annotation_id: Uuid,
772            /// If any of these fields are set, they will overwrite the previous options for the
773            /// annotation.
774            pub options: AnnotationOptions,
775        }
776
777        /// Changes visibility of scene-wide edge lines on brep solids
778        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
779        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
780        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
781        pub struct EdgeLinesVisible {
782            /// Whether or not the edge lines should be hidden.
783            pub hidden: bool,
784        }
785
786        /// Hide or show an object
787        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
788        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
789        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
790        pub struct ObjectVisible {
791            /// Which object to change
792            pub object_id: Uuid,
793            /// Whether or not the object should be hidden.
794            pub hidden: bool,
795        }
796
797        /// Bring an object to the front of the scene
798        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
799        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
800        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
801        pub struct ObjectBringToFront {
802            /// Which object to change
803            pub object_id: Uuid,
804        }
805
806        /// Set the material properties of an object
807        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
808        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
809        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
810        pub struct ObjectSetMaterialParamsPbr {
811            /// Which object to change
812            pub object_id: Uuid,
813            /// Color of the new material
814            pub color: Color,
815            /// Metalness of the new material
816            pub metalness: f32,
817            /// Roughness of the new material
818            pub roughness: f32,
819            /// Ambient Occlusion of the new material
820            pub ambient_occlusion: f32,
821            /// Color of the backface
822            #[serde(default, skip_serializing_if = "Option::is_none")]
823            pub backface_color: Option<Color>,
824        }
825        /// What type of entity is this?
826        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
827        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
828        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
829        pub struct GetEntityType {
830            /// ID of the entity being queried.
831            pub entity_id: Uuid,
832        }
833
834        /// Gets all faces which use the given edge.
835        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
836        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
837        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
838        pub struct Solid3dGetAllEdgeFaces {
839            /// Which object is being queried.
840            pub object_id: Uuid,
841            /// Which edge you want the faces of.
842            pub edge_id: Uuid,
843        }
844
845        /// Add a hole to a Solid2d object before extruding it.
846        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
847        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
848        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
849        pub struct Solid2dAddHole {
850            /// Which object to add the hole to.
851            pub object_id: Uuid,
852            /// The id of the path to use as the inner profile (hole).
853            pub hole_id: Uuid,
854        }
855
856        /// Gets all edges which are opposite the given edge, across all possible faces.
857        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
858        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
859        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
860        pub struct Solid3dGetAllOppositeEdges {
861            /// Which object is being queried.
862            pub object_id: Uuid,
863            /// Which edge you want the opposites of.
864            pub edge_id: Uuid,
865            /// If given, only faces parallel to this vector will be considered.
866            pub along_vector: Option<Point3d<f64>>,
867        }
868
869        /// Gets the edge opposite the given edge, along the given face.
870        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
871        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
872        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
873        pub struct Solid3dGetOppositeEdge {
874            /// Which object is being queried.
875            pub object_id: Uuid,
876            /// Which edge you want the opposite of.
877            pub edge_id: Uuid,
878            /// Which face is used to figure out the opposite edge?
879            pub face_id: Uuid,
880        }
881
882        /// Gets the next adjacent edge for the given edge, along the given face.
883        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
884        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
885        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
886        pub struct Solid3dGetNextAdjacentEdge {
887            /// Which object is being queried.
888            pub object_id: Uuid,
889            /// Which edge you want the opposite of.
890            pub edge_id: Uuid,
891            /// Which face is used to figure out the opposite edge?
892            pub face_id: Uuid,
893        }
894
895        /// Gets the previous adjacent edge for the given edge, along the given face.
896        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
897        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
898        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
899        pub struct Solid3dGetPrevAdjacentEdge {
900            /// Which object is being queried.
901            pub object_id: Uuid,
902            /// Which edge you want the opposite of.
903            pub edge_id: Uuid,
904            /// Which face is used to figure out the opposite edge?
905            pub face_id: Uuid,
906        }
907
908        /// Gets the shared edge between these two faces if it exists
909        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
910        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
911        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
912        pub struct Solid3dGetCommonEdge {
913            /// Which object is being queried.
914            pub object_id: Uuid,
915            /// The faces being queried
916            pub face_ids: [Uuid; 2]
917        }
918
919        /// Fillets the given edge with the specified radius.
920        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
921        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
922        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
923        pub struct Solid3dFilletEdge {
924            /// Which object is being filletted.
925            pub object_id: Uuid,
926            /// Which edge you want to fillet.
927            #[serde(default)]
928            pub edge_id: Option<Uuid>,
929            /// Which edges you want to fillet.
930            #[serde(default)]
931            pub edge_ids: Vec<Uuid>,
932            /// The radius of the fillet. Measured in length (using the same units that the current sketch uses). Must be positive (i.e. greater than zero).
933            pub radius: LengthUnit,
934            /// The maximum acceptable surface gap computed between the filleted surfaces. Must be positive (i.e. greater than zero).
935            pub tolerance: LengthUnit,
936            /// How to apply the cut.
937            #[serde(default)]
938            pub cut_type: CutType,
939            /// Which cutting algorithm to use.
940            #[serde(default)]
941            pub strategy: CutStrategy,
942            /// What IDs should the resulting faces have?
943            /// If you've only passed one edge ID, its ID will
944            /// be the command ID used to send this command, and this
945            /// field should be empty.
946            /// If you've passed `n` IDs (to fillet `n` edges), then
947            /// this should be length `n-1`, and the first edge will use
948            /// the command ID used to send this command.
949            #[serde(default)]
950            pub extra_face_ids: Vec<Uuid>,
951        }
952
953        /// Cut the list of given edges with the given cut parameters.
954        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
955        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
956        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
957        pub struct Solid3dCutEdges {
958            /// Which object is being cut.
959            pub object_id: Uuid,
960            /// Which edges you want to cut.
961            #[serde(default)]
962            pub edge_ids: Vec<Uuid>,
963            /// The cut type and information required to perform the cut.
964            pub cut_type: CutTypeV2,
965            /// The maximum acceptable surface gap computed between the cut surfaces. Must be
966            /// positive (i.e. greater than zero).
967            pub tolerance: LengthUnit,
968            /// Which cutting algorithm to use.
969            #[serde(default)]
970            pub strategy: CutStrategy,
971            /// What IDs should the resulting faces have?
972            /// If you've only passed one edge ID, its ID will
973            /// be the command ID used to send this command, and this
974            /// field should be empty.
975            /// If you've passed `n` IDs (to cut `n` edges), then
976            /// this should be length `n-1`, and the first edge will use
977            /// the command ID used to send this command.
978            #[serde(default)]
979            pub extra_face_ids: Vec<Uuid>,
980        }
981
982        /// Determines whether a brep face is planar and returns its surface-local planar axes if so
983        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
984        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
985        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
986        pub struct FaceIsPlanar {
987            /// Which face is being queried.
988            pub object_id: Uuid,
989        }
990
991        /// Determines a position on a brep face evaluated by parameters u,v
992        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
993        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
994        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
995        pub struct FaceGetPosition {
996            /// Which face is being queried.
997            pub object_id: Uuid,
998
999            /// The 2D parameter-space u,v position to evaluate the surface at
1000            pub uv: Point2d<f64>,
1001        }
1002
1003        ///Obtains the surface "center of mass"
1004        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1005        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1006        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1007        pub struct FaceGetCenter {
1008            /// Which face is being queried.
1009            pub object_id: Uuid,
1010        }
1011
1012        /// Determines the gradient (dFdu, dFdv) + normal vector on a brep face evaluated by parameters u,v
1013        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1014        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1015        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1016        pub struct FaceGetGradient {
1017            /// Which face is being queried.
1018            pub object_id: Uuid,
1019
1020            /// The 2D parameter-space u,v position to evaluate the surface at
1021            pub uv: Point2d<f64>,
1022        }
1023
1024        /// Send object to front or back.
1025        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1026        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1027        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1028        pub struct SendObject {
1029            /// Which object is being changed.
1030            pub object_id: Uuid,
1031            /// Bring to front = true, send to back = false.
1032            pub front: bool,
1033        }
1034        /// Set opacity of the entity.
1035        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1036        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1037        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1038        pub struct EntitySetOpacity {
1039            /// Which entity is being changed.
1040            pub entity_id: Uuid,
1041            /// How transparent should it be?
1042            /// 0 or lower is totally transparent.
1043            /// 1 or greater is totally opaque.
1044            pub opacity: f32,
1045        }
1046
1047        /// Fade entity in or out.
1048        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1049        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1050        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1051        pub struct EntityFade {
1052            /// Which entity is being changed.
1053            pub entity_id: Uuid,
1054            /// Fade in = true, fade out = false.
1055            pub fade_in: bool,
1056            /// How many seconds the animation should take.
1057            #[serde(default = "default_animation_seconds")]
1058            pub duration_seconds: f64,
1059        }
1060
1061        /// Make a new plane
1062        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1063        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1064        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1065        pub struct MakePlane {
1066            /// Origin of the plane
1067            pub origin: Point3d<LengthUnit>,
1068            /// What should the plane's X axis be?
1069            pub x_axis: Point3d<f64>,
1070            /// What should the plane's Y axis be?
1071            pub y_axis: Point3d<f64>,
1072            /// What should the plane's span/extent?
1073            /// When rendered visually, this is both the
1074            /// width and height along X and Y axis respectively.
1075            pub size: LengthUnit,
1076            /// If true, any existing drawables within the obj will be replaced (the object will be reset)
1077            pub clobber: bool,
1078            /// If true, the plane will be created but hidden initially.
1079            pub hide: Option<bool>,
1080        }
1081
1082        /// Set the color of a plane.
1083        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1084        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1085        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1086        pub struct PlaneSetColor {
1087            /// Which plane is being changed.
1088            pub plane_id: Uuid,
1089            /// What color it should be.
1090            pub color: Color,
1091        }
1092
1093        /// Set the current tool.
1094        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1095        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1096        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1097        pub struct SetTool {
1098            /// What tool should be active.
1099            pub tool: SceneToolType,
1100        }
1101
1102        /// Send a mouse move event
1103        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1104        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1105        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1106        pub struct MouseMove {
1107            /// Where the mouse is
1108            pub window: Point2d,
1109            /// Logical timestamp. The client should increment this
1110            /// with every event in the current mouse drag. That way, if the
1111            /// events are being sent over an unordered channel, the API
1112            /// can ignore the older events.
1113            pub sequence: Option<u32>,
1114        }
1115
1116        /// Send a mouse click event
1117        /// Updates modified/selected entities.
1118        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1119        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1120        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1121        pub struct MouseClick {
1122            /// Where the mouse is
1123            pub window: Point2d,
1124        }
1125
1126        /// Disable sketch mode.
1127        /// If you are sketching on a face, be sure to not disable sketch mode until you have extruded.
1128        /// Otherwise, your object will not be fused with the face.
1129        #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1130        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1131        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1132        pub struct SketchModeDisable {}
1133
1134        /// Get the plane for sketch mode.
1135        #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1136        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1137        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1138        pub struct GetSketchModePlane {}
1139
1140        /// Get the plane for sketch mode.
1141        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1142        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1143        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1144        pub struct CurveSetConstraint {
1145            /// Which curve to constrain.
1146            pub object_id: Uuid,
1147            /// Which constraint to apply.
1148            pub constraint_bound: PathComponentConstraintBound,
1149            /// What part of the curve should be constrained.
1150            pub constraint_type: PathComponentConstraintType,
1151        }
1152
1153        /// Sketch on some entity (e.g. a plane, a face).
1154        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1155        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1156        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1157        pub struct EnableSketchMode {
1158            /// Which entity to sketch on.
1159            pub entity_id: Uuid,
1160            /// Should the camera use orthographic projection?
1161            /// In other words, should an object's size in the rendered image stay constant regardless of its distance from the camera.
1162            pub ortho: bool,
1163            /// Should we animate or snap for the camera transition?
1164            pub animated: bool,
1165            /// Should the camera move at all?
1166            pub adjust_camera: bool,
1167            /// If provided, ensures that the normal of the sketch plane must be aligned with this supplied normal
1168            /// (otherwise the camera position will be used to infer the normal to point towards the viewer)
1169            pub planar_normal: Option<Point3d<f64>>,
1170        }
1171
1172        /// Sets whether or not changes to the scene or its objects will be done as a "dry run"
1173        /// In a dry run, successful commands won't actually change the model.
1174        /// This is useful for catching errors before actually making the change.
1175        #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1176        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1177        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1178        pub struct EnableDryRun {}
1179
1180        /// Sets whether or not changes to the scene or its objects will be done as a "dry run"
1181        /// In a dry run, successful commands won't actually change the model.
1182        /// This is useful for catching errors before actually making the change.
1183        #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1184        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1185        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1186        pub struct DisableDryRun {}
1187
1188        /// Set the background color of the scene.
1189        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1190        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1191        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1192        pub struct SetBackgroundColor {
1193            /// The color to set the background to.
1194            pub color: Color,
1195        }
1196
1197        /// Set the properties of the tool lines for the scene.
1198        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1199        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1200        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1201        pub struct SetCurrentToolProperties {
1202            /// The color to set the tool line to.
1203            pub color: Option<Color>,
1204        }
1205
1206        /// Set the default system properties used when a specific property isn't set.
1207        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1208        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1209        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1210        pub struct SetDefaultSystemProperties {
1211            /// The default system color.
1212            #[serde(default)]
1213            pub color: Option<Color>,
1214            /// The default color to use for all backfaces
1215            #[serde(default)]
1216            pub backface_color: Option<Color>,
1217        }
1218
1219        /// Get type of the given curve.
1220        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1221        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1222        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1223        pub struct CurveGetType {
1224            /// Which curve to query.
1225            pub curve_id: Uuid,
1226        }
1227
1228        /// Get control points of the given curve.
1229        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1230        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1231        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1232        pub struct CurveGetControlPoints {
1233            /// Which curve to query.
1234            pub curve_id: Uuid,
1235        }
1236
1237        /// Project an entity on to a plane.
1238        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1239        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1240        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1241        pub struct ProjectEntityToPlane {
1242            /// Which entity to project (vertex or edge).
1243            pub entity_id: Uuid,
1244            /// Which plane to project entity_id onto.
1245            pub plane_id: Uuid,
1246            /// If true: the projected points are returned in the plane_id's coordinate system,
1247            /// else: the projected points are returned in the world coordinate system.
1248            pub use_plane_coords: bool,
1249        }
1250
1251        /// Project a list of points on to a plane.
1252        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1253        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1254        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1255        pub struct ProjectPointsToPlane {
1256            /// The id of the plane used for the projection.
1257            pub plane_id: Uuid,
1258            /// The list of points that will be projected.
1259            pub points: Vec<Point3d<f64>>,
1260            /// If true: the projected points are returned in the plane_id's coordinate sysetm.
1261            /// else: the projected points are returned in the world coordinate system.
1262            pub use_plane_coords: bool,
1263        }
1264
1265        /// Enum containing the variety of image formats snapshots may be exported to.
1266        #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, FromStr, Display)]
1267        #[serde(rename_all = "snake_case")]
1268        #[display(style = "snake_case")]
1269        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1270        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1271        #[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass_enum)]
1272        pub enum ImageFormat {
1273            /// .png format
1274            Png,
1275            /// .jpeg format
1276            Jpeg,
1277        }
1278
1279        /// Take a snapshot of the current view.
1280        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1281        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1282        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1283        pub struct TakeSnapshot {
1284            /// What image format to return.
1285            pub format: ImageFormat,
1286        }
1287
1288        /// Add a gizmo showing the axes.
1289        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1290        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1291        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1292        pub struct MakeAxesGizmo {
1293            /// If true, axes gizmo will be placed in the corner of the screen.
1294            /// If false, it will be placed at the origin of the scene.
1295            pub gizmo_mode: bool,
1296            /// If true, any existing drawables within the obj will be replaced (the object will be reset)
1297            pub clobber: bool,
1298        }
1299
1300        /// Query the given path.
1301        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1302        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1303        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1304        pub struct PathGetInfo {
1305            /// Which path to query
1306            pub path_id: Uuid,
1307        }
1308
1309        /// Obtain curve ids for vertex ids
1310        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1311        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1312        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1313        pub struct PathGetCurveUuidsForVertices {
1314            /// Which path to query
1315            pub path_id: Uuid,
1316
1317            /// IDs of the vertices for which to obtain curve ids from
1318            pub vertex_ids: Vec<Uuid>,
1319        }
1320
1321        /// Obtain curve id by index
1322        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1323        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1324        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1325        pub struct PathGetCurveUuid {
1326            /// Which path to query
1327            pub path_id: Uuid,
1328
1329            /// IDs of the vertices for which to obtain curve ids from
1330            pub index: u32,
1331        }
1332
1333        /// Obtain vertex ids for a path
1334        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1335        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1336        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1337        pub struct PathGetVertexUuids {
1338            /// Which path to query
1339            pub path_id: Uuid,
1340        }
1341
1342        /// Obtain the sketch target id (if the path was drawn in sketchmode) for a path
1343        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1344        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1345        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1346        pub struct PathGetSketchTargetUuid {
1347            /// Which path to query
1348            pub path_id: Uuid,
1349        }
1350
1351        /// Start dragging the mouse.
1352        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1353        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1354        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1355        pub struct HandleMouseDragStart {
1356            /// The mouse position.
1357            pub window: Point2d,
1358        }
1359
1360        /// Continue dragging the mouse.
1361        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1362        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1363        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1364        pub struct HandleMouseDragMove {
1365            /// The mouse position.
1366            pub window: Point2d,
1367            /// Logical timestamp. The client should increment this
1368            /// with every event in the current mouse drag. That way, if the
1369            /// events are being sent over an unordered channel, the API
1370            /// can ignore the older events.
1371            pub sequence: Option<u32>,
1372        }
1373
1374        /// Stop dragging the mouse.
1375        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1376        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1377        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1378        pub struct HandleMouseDragEnd {
1379            /// The mouse position.
1380            pub window: Point2d,
1381        }
1382
1383        /// Remove scene objects.
1384        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1385        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1386        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1387        pub struct RemoveSceneObjects {
1388            /// Objects to remove.
1389            pub object_ids: HashSet<Uuid>,
1390        }
1391
1392        /// Utility method. Performs both a ray cast and projection to plane-local coordinates.
1393        /// Returns the plane coordinates for the given window coordinates.
1394        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1395        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1396        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1397        pub struct PlaneIntersectAndProject {
1398            /// The plane you're intersecting against.
1399            pub plane_id: Uuid,
1400            /// Window coordinates where the ray cast should be aimed.
1401            pub window: Point2d,
1402        }
1403
1404        /// Find the start and end of a curve.
1405        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1406        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1407        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1408        pub struct CurveGetEndPoints {
1409            /// ID of the curve being queried.
1410            pub curve_id: Uuid,
1411        }
1412
1413        /// Reconfigure the stream.
1414        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1415        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1416        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1417        pub struct ReconfigureStream {
1418            /// Width of the stream.
1419            pub width: u32,
1420            /// Height of the stream.
1421            pub height: u32,
1422            /// Frames per second.
1423            pub fps: u32,
1424            /// Video feed's constant bitrate (CBR)
1425            #[serde(default)]
1426            pub bitrate: Option<u32>,
1427        }
1428
1429        /// Import files to the current model.
1430        #[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1431        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1432        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1433        pub struct ImportFiles {
1434            /// Files to import.
1435            pub files: Vec<super::ImportFile>,
1436            /// Input file format.
1437            pub format: crate::format::InputFormat3d,
1438        }
1439
1440        /// Set the units of the scene.
1441        /// For all following commands, the units will be interpreted as the given units.
1442        /// Any previously executed commands will not be affected or have their units changed.
1443        /// They will remain in the units they were originally executed in.
1444        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1445        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1446        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1447        pub struct SetSceneUnits {
1448            /// Which units the scene uses.
1449            pub unit: units::UnitLength,
1450        }
1451
1452        /// Get the mass of entities in the scene or the default scene.
1453        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1454        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1455        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1456        pub struct Mass {
1457            /// IDs of the entities to get the mass of. If this is empty, then the default scene is included in
1458            /// the mass.
1459            pub entity_ids: Vec<Uuid>,
1460            /// The material density.
1461            pub material_density: f64,
1462            /// The material density unit.
1463            pub material_density_unit: units::UnitDensity,
1464            /// The output unit for the mass.
1465            pub output_unit: units::UnitMass,
1466        }
1467
1468        /// Get the density of entities in the scene or the default scene.
1469        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1470        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1471        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1472        pub struct Density {
1473            /// IDs of the entities to get the density of. If this is empty, then the default scene is included in
1474            /// the density.
1475            pub entity_ids: Vec<Uuid>,
1476            /// The material mass.
1477            pub material_mass: f64,
1478            /// The material mass unit.
1479            pub material_mass_unit: units::UnitMass,
1480            /// The output unit for the density.
1481            pub output_unit: units::UnitDensity,
1482        }
1483
1484        /// Get the volume of entities in the scene or the default scene.
1485        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1486        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1487        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1488        pub struct Volume {
1489            /// IDs of the entities to get the volume of. If this is empty, then the default scene is included in
1490            /// the volume.
1491            pub entity_ids: Vec<Uuid>,
1492            /// The output unit for the volume.
1493            pub output_unit: units::UnitVolume,
1494        }
1495
1496        /// Get the center of mass of entities in the scene or the default scene.
1497        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1498        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1499        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1500        pub struct CenterOfMass {
1501            /// IDs of the entities to get the center of mass of. If this is empty, then the default scene is included in
1502            /// the center of mass.
1503            pub entity_ids: Vec<Uuid>,
1504            /// The output unit for the center of mass.
1505            pub output_unit: units::UnitLength,
1506        }
1507
1508        /// Get the surface area of entities in the scene or the default scene.
1509        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1510        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1511        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1512        pub struct SurfaceArea {
1513            /// IDs of the entities to get the surface area of. If this is empty, then the default scene is included in
1514            /// the surface area.
1515            pub entity_ids: Vec<Uuid>,
1516            /// The output unit for the surface area.
1517            pub output_unit: units::UnitArea,
1518        }
1519
1520        /// Focus the default camera upon an object in the scene.
1521        #[derive(
1522            Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant,
1523        )]
1524        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1525        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1526        pub struct DefaultCameraFocusOn {
1527            /// UUID of object to focus on.
1528            pub uuid: Uuid,
1529        }
1530        /// When you select some entity with the current tool, what should happen to the entity?
1531        #[derive(
1532            Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant,
1533        )]
1534        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1535        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1536        pub struct SetSelectionType {
1537            /// What type of selection should occur when you select something?
1538            pub selection_type: SceneSelectionType,
1539        }
1540
1541        /// What kind of entities can be selected?
1542        #[derive(
1543            Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant,
1544        )]
1545        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1546        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1547        pub struct SetSelectionFilter {
1548            /// If vector is empty, clear all filters.
1549            /// If vector is non-empty, only the given entity types will be selectable.
1550            pub filter: Vec<EntityType>,
1551        }
1552
1553        /// Get the ids of a given entity type.
1554        #[derive(
1555            Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant,
1556        )]
1557        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1558        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1559        pub struct SceneGetEntityIds {
1560            /// The entity types to be queried.
1561            pub filter: Vec<EntityType>,
1562            /// Skip the first n returned ids. If multiple filters are provided, this skip will
1563            /// apply to each filter individually.
1564            pub skip: u32,
1565            /// Take n ids after any ids skipped. This value must be greater than zero and not
1566            /// exceed 1000. If multiple filters are provided, this take will apply to each filter
1567            /// individually. If there are fewer than `take` items of the provided filter type then the
1568            /// returned list's length will be the smaller value.
1569            #[schemars(range(min = 1, max = 1000))]
1570            pub take: u32,
1571        }
1572
1573        /// Use orthographic projection.
1574        #[derive(
1575            Clone, Debug, Default, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant,
1576        )]
1577        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1578        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1579        pub struct DefaultCameraSetOrthographic {}
1580
1581        /// Use perspective projection.
1582        #[derive(
1583            Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant,
1584        )]
1585        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1586        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1587        pub struct DefaultCameraSetPerspective {
1588            /// If this is not given, use the same parameters as last time the perspective camera was used.
1589            pub parameters: Option<PerspectiveCameraParameters>,
1590        }
1591
1592        ///Updates the camera to center to the center of the current selection
1593        ///(or the origin if nothing is selected)
1594        #[derive(
1595            Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant,
1596        )]
1597        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1598        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1599        pub struct DefaultCameraCenterToSelection {
1600            /// Dictates whether or not the camera position should be adjusted during this operation
1601            /// If no movement is requested, the camera will orbit around the new center from its current position
1602            #[serde(default)]
1603            pub camera_movement: CameraMovement,
1604        }
1605
1606        ///Updates the camera to center to the center of the current scene's bounds
1607        #[derive(
1608            Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant,
1609        )]
1610        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1611        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1612        pub struct DefaultCameraCenterToScene {
1613            /// Dictates whether or not the camera position should be adjusted during this operation
1614            /// If no movement is requested, the camera will orbit around the new center from its current position
1615            #[serde(default)]
1616            pub camera_movement: CameraMovement,
1617        }
1618
1619        /// Fit the view to the specified object(s).
1620        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1621        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1622        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1623        pub struct ZoomToFit {
1624            /// Which objects to fit camera to; if empty, fit to all non-default objects. Defaults to empty vector.
1625            #[serde(default = "default_uuid_vector")]
1626            pub object_ids: Vec<Uuid>,
1627            /// How much to pad the view frame by, as a fraction of the object(s) bounding box size.
1628            /// Negative padding will crop the view of the object proportionally.
1629            /// e.g. padding = 0.2 means the view will span 120% of the object(s) bounding box,
1630            /// and padding = -0.2 means the view will span 80% of the object(s) bounding box.
1631            #[serde(default)]
1632            pub padding: f32,
1633            /// Whether or not to animate the camera movement.
1634            #[serde(default)]
1635            pub animated: bool,
1636        }
1637
1638        /// Looks along the normal of the specified face (if it is planar!), and fits the view to it.
1639        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1640        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1641        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1642        pub struct OrientToFace {
1643            /// Which face to orient camera to. If the face is not planar, no action will occur.
1644            pub face_id: Uuid,
1645            /// How much to pad the view frame by, as a fraction of the face bounding box size.
1646            /// Negative padding will crop the view of the face proportionally.
1647            /// e.g. padding = 0.2 means the view will span 120% of the face bounding box,
1648            /// and padding = -0.2 means the view will span 80% of the face bounding box.
1649            #[serde(default)]
1650            pub padding: f32,
1651            /// Whether or not to animate the camera movement. (Animation is currently not supported.)
1652            #[serde(default)]
1653            pub animated: bool,
1654        }
1655
1656        /// Fit the view to the scene with an isometric view.
1657        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1658        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1659        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1660        pub struct ViewIsometric {
1661            /// How much to pad the view frame by, as a fraction of the object(s) bounding box size.
1662            /// Negative padding will crop the view of the object proportionally.
1663            /// e.g. padding = 0.2 means the view will span 120% of the object(s) bounding box,
1664            /// and padding = -0.2 means the view will span 80% of the object(s) bounding box.
1665            #[serde(default = "f32::default")]
1666            pub padding: f32,
1667        }
1668
1669        /// Get a concise description of all of an extrusion's faces.
1670        #[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)]
1671        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1672        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1673        pub struct Solid3dGetExtrusionFaceInfo {
1674            /// The Solid3d object whose extrusion is being queried.
1675            pub object_id: Uuid,
1676            /// Any edge that lies on the extrusion base path.
1677            pub edge_id: Uuid,
1678        }
1679
1680        /// Get a concise description of all of solids edges.
1681        #[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)]
1682        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1683        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1684        pub struct Solid3dGetAdjacencyInfo {
1685            /// The Solid3d object whose info is being queried.
1686            pub object_id: Uuid,
1687            /// Any edge that lies on the extrusion base path.
1688            pub edge_id: Uuid,
1689        }
1690
1691
1692        /// Clear the selection
1693        #[derive(Clone, Debug, Default, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)]
1694        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1695        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1696        pub struct SelectClear {}
1697
1698        /// Find all IDs of selected entities
1699        #[derive(Clone, Debug, Default, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)]
1700        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1701        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1702        pub struct SelectGet {}
1703
1704        /// Get the number of objects in the scene
1705        #[derive(
1706            Clone, Debug, Default, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant,
1707        )]
1708        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1709        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1710        pub struct GetNumObjects {}
1711
1712        ///Set the transform of an object.
1713        #[derive(
1714            Clone, Debug, Deserialize, PartialEq, JsonSchema, Serialize, ModelingCmdVariant,
1715        )]
1716        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1717        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1718        pub struct SetObjectTransform
1719        {
1720            /// Id of the object whose transform is to be set.
1721            pub object_id: Uuid,
1722            /// List of transforms to be applied to the object.
1723            pub transforms: Vec<ComponentTransform>,
1724        }
1725
1726        /// Create a new solid from combining other smaller solids.
1727        /// In other words, every part of the input solids will be included in the output solid.
1728        #[derive(
1729            Clone, Debug, Deserialize, PartialEq, JsonSchema, Serialize, ModelingCmdVariant,
1730        )]
1731        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1732        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1733        pub struct BooleanUnion
1734        {
1735            /// Which solids to union together.
1736            /// Cannot be empty.
1737            pub solid_ids: Vec<Uuid>,
1738            /// The maximum acceptable surface gap computed between the joined solids. Must be positive (i.e. greater than zero).
1739            pub tolerance: LengthUnit,
1740        }
1741
1742        /// Create a new solid from intersecting several other solids.
1743        /// In other words, the part of the input solids where they all overlap will be the output solid.
1744        #[derive(
1745            Clone, Debug, Deserialize, PartialEq, JsonSchema, Serialize, ModelingCmdVariant,
1746        )]
1747        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1748        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1749        pub struct BooleanIntersection
1750        {
1751            /// Which solids to intersect together
1752            pub solid_ids: Vec<Uuid>,
1753            /// The maximum acceptable surface gap computed between the joined solids. Must be positive (i.e. greater than zero).
1754            pub tolerance: LengthUnit,
1755        }
1756
1757        /// Create a new solid from subtracting several other solids.
1758        /// The 'target' is what will be cut from.
1759        /// The 'tool' is what will be cut out from 'target'.
1760        #[derive(
1761            Clone, Debug, Deserialize, PartialEq, JsonSchema, Serialize, ModelingCmdVariant,
1762        )]
1763        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1764        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1765        pub struct BooleanSubtract
1766        {
1767            /// Geometry to cut out from.
1768            pub target_ids: Vec<Uuid>,
1769            /// Will be cut out from the 'target'.
1770            pub tool_ids: Vec<Uuid>,
1771            /// The maximum acceptable surface gap computed between the target and the solids cut out from it. Must be positive (i.e. greater than zero).
1772            pub tolerance: LengthUnit,
1773        }
1774
1775        /// Make a new path by offsetting an object by a given distance.
1776        /// The new path's ID will be the ID of this command.
1777        #[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)]
1778        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1779        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1780        pub struct MakeOffsetPath {
1781            /// The object that will be offset (can be a path, sketch, or a solid)
1782            pub object_id: Uuid,
1783            /// If the object is a solid, this is the ID of the face to base the offset on.
1784            /// If given, and `object_id` refers to a solid, then this face on the solid will be offset.
1785            /// If given but `object_id` doesn't refer to a solid, responds with an error.
1786            /// If not given, then `object_id` itself will be offset directly.
1787            #[serde(default)]
1788            pub face_id: Option<Uuid>,
1789            /// The distance to offset the path (positive for outset, negative for inset)
1790            pub offset: LengthUnit,
1791        }
1792
1793        /// Add a hole to a closed path by offsetting it a uniform distance inward.
1794        #[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)]
1795        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1796        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1797        pub struct AddHoleFromOffset {
1798            /// The closed path to add a hole to.
1799            pub object_id: Uuid,
1800            /// The distance to offset the path (positive for outset, negative for inset)
1801            pub offset: LengthUnit,
1802        }
1803
1804        /// Align the grid with a plane or a planar face.
1805        #[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)]
1806        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1807        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1808        pub struct SetGridReferencePlane {
1809            /// The grid to be moved.
1810            pub grid_id: Uuid,
1811            /// The plane or face that the grid will be aligned to.
1812            /// If a face, it must be planar to succeed.
1813            pub reference_id: Uuid,
1814        }
1815
1816        /// Set the scale of the grid lines in the video feed.
1817        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1818        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1819        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1820        pub struct SetGridScale {
1821            /// Distance between grid lines represents this much distance.
1822            pub value: f32,
1823            /// Which units the `value` field uses.
1824            pub units: units::UnitLength,
1825        }
1826
1827        /// Set the grid lines to auto scale. The grid will get larger the further you zoom out,
1828        /// and smaller the more you zoom in.
1829        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1830        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1831        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1832        pub struct SetGridAutoScale {
1833        }
1834
1835        /// Render transparent surfaces more accurately, but this might make rendering slower.
1836        /// Because it can interfere with runtime performance, it defaults to false.
1837        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
1838        #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1839        #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1840        pub struct SetOrderIndependentTransparency {
1841            /// Enables or disables OIT.
1842            /// If not given, toggles it.
1843            pub enabled: Option<bool>,
1844        }
1845    }
1846}
1847
1848impl ModelingCmd {
1849    /// Is this command safe to run in an engine batch?
1850    pub fn is_safe_to_batch(&self) -> bool {
1851        use ModelingCmd::*;
1852        matches!(
1853            self,
1854            MovePathPen(_)
1855                | ExtendPath(_)
1856                | Extrude(_)
1857                | Revolve(_)
1858                | Solid3dFilletEdge(_)
1859                | ClosePath(_)
1860                | UpdateAnnotation(_)
1861                | ObjectVisible(_)
1862                | ObjectBringToFront(_)
1863                | Solid2dAddHole(_)
1864                | SendObject(_)
1865                | EntitySetOpacity(_)
1866                | PlaneSetColor(_)
1867                | SetTool(_)
1868        )
1869    }
1870}
1871
1872/// File to import into the current model.
1873/// If you are sending binary data for a file, be sure to send the WebSocketRequest as
1874/// binary/bson, not text/json.
1875#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, Eq, PartialEq)]
1876#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1877#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1878pub struct ImportFile {
1879    /// The file's full path, including file extension.
1880    pub path: String,
1881    /// The raw bytes of the file
1882    #[serde(
1883        serialize_with = "serde_bytes::serialize",
1884        deserialize_with = "serde_bytes::deserialize"
1885    )]
1886    pub data: Vec<u8>,
1887}