Track artifact commands and operations per-module (#7426)
* Change so that operations are stored per module * Refactor so that all modeling commands go through ExecState * Remove unneeded PartialOrd implementations * Remove artifact_commands from KclError since it was only for debugging --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -9,7 +9,7 @@ use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
execution::{
|
||||
types::{PrimitiveType, RuntimeType},
|
||||
ExecState, Helix as HelixValue, KclValue, Solid,
|
||||
ExecState, Helix as HelixValue, KclValue, ModelingCmdMeta, Solid,
|
||||
},
|
||||
std::{axis_or_reference::Axis3dOrEdgeReference, Args},
|
||||
};
|
||||
@ -124,17 +124,18 @@ async fn inner_helix(
|
||||
}
|
||||
|
||||
if let Some(cylinder) = cylinder {
|
||||
args.batch_modeling_cmd(
|
||||
id,
|
||||
ModelingCmd::from(mcmd::EntityMakeHelix {
|
||||
cylinder_id: cylinder.id,
|
||||
is_clockwise: !helix_result.ccw,
|
||||
length: LengthUnit(length.as_ref().map(|t| t.to_mm()).unwrap_or(cylinder.height_in_mm())),
|
||||
revolutions,
|
||||
start_angle: Angle::from_degrees(angle_start),
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
exec_state
|
||||
.batch_modeling_cmd(
|
||||
ModelingCmdMeta::from_args_id(&args, id),
|
||||
ModelingCmd::from(mcmd::EntityMakeHelix {
|
||||
cylinder_id: cylinder.id,
|
||||
is_clockwise: !helix_result.ccw,
|
||||
length: LengthUnit(length.as_ref().map(|t| t.to_mm()).unwrap_or(cylinder.height_in_mm())),
|
||||
revolutions,
|
||||
start_angle: Angle::from_degrees(angle_start),
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
} else if let (Some(axis), Some(radius)) = (axis, radius) {
|
||||
match axis {
|
||||
Axis3dOrEdgeReference::Axis { direction, origin } => {
|
||||
@ -146,43 +147,45 @@ async fn inner_helix(
|
||||
)));
|
||||
};
|
||||
|
||||
args.batch_modeling_cmd(
|
||||
id,
|
||||
ModelingCmd::from(mcmd::EntityMakeHelixFromParams {
|
||||
radius: LengthUnit(radius.to_mm()),
|
||||
is_clockwise: !helix_result.ccw,
|
||||
length: LengthUnit(length.to_mm()),
|
||||
revolutions,
|
||||
start_angle: Angle::from_degrees(angle_start),
|
||||
axis: Point3d {
|
||||
x: direction[0].to_mm(),
|
||||
y: direction[1].to_mm(),
|
||||
z: direction[2].to_mm(),
|
||||
},
|
||||
center: Point3d {
|
||||
x: LengthUnit(origin[0].to_mm()),
|
||||
y: LengthUnit(origin[1].to_mm()),
|
||||
z: LengthUnit(origin[2].to_mm()),
|
||||
},
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
exec_state
|
||||
.batch_modeling_cmd(
|
||||
ModelingCmdMeta::from_args_id(&args, id),
|
||||
ModelingCmd::from(mcmd::EntityMakeHelixFromParams {
|
||||
radius: LengthUnit(radius.to_mm()),
|
||||
is_clockwise: !helix_result.ccw,
|
||||
length: LengthUnit(length.to_mm()),
|
||||
revolutions,
|
||||
start_angle: Angle::from_degrees(angle_start),
|
||||
axis: Point3d {
|
||||
x: direction[0].to_mm(),
|
||||
y: direction[1].to_mm(),
|
||||
z: direction[2].to_mm(),
|
||||
},
|
||||
center: Point3d {
|
||||
x: LengthUnit(origin[0].to_mm()),
|
||||
y: LengthUnit(origin[1].to_mm()),
|
||||
z: LengthUnit(origin[2].to_mm()),
|
||||
},
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
Axis3dOrEdgeReference::Edge(edge) => {
|
||||
let edge_id = edge.get_engine_id(exec_state, &args)?;
|
||||
|
||||
args.batch_modeling_cmd(
|
||||
id,
|
||||
ModelingCmd::from(mcmd::EntityMakeHelixFromEdge {
|
||||
radius: LengthUnit(radius.to_mm()),
|
||||
is_clockwise: !helix_result.ccw,
|
||||
length: length.map(|t| LengthUnit(t.to_mm())),
|
||||
revolutions,
|
||||
start_angle: Angle::from_degrees(angle_start),
|
||||
edge_id,
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
exec_state
|
||||
.batch_modeling_cmd(
|
||||
ModelingCmdMeta::from_args_id(&args, id),
|
||||
ModelingCmd::from(mcmd::EntityMakeHelixFromEdge {
|
||||
radius: LengthUnit(radius.to_mm()),
|
||||
is_clockwise: !helix_result.ccw,
|
||||
length: length.map(|t| LengthUnit(t.to_mm())),
|
||||
revolutions,
|
||||
start_angle: Angle::from_degrees(angle_start),
|
||||
edge_id,
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user