Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ kittycad = { version = "0.3.37", default-features = false, features = [
"js",
"requests",
] }
kittycad-modeling-cmds = { version = "0.2.131", features = [
kittycad-modeling-cmds = { git = "https://github.com/alteous/modeling-api.git", rev = "48be0bca23805a05936fb10af760ad26162467a3", features = [
"ts-rs",
"websocket",
] }
Expand Down
13 changes: 12 additions & 1 deletion rust/kcl-lib/src/std/shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ pub async fn rectangle(exec_state: &mut ExecState, args: Args) -> Result<KclValu
let corner = args.get_kw_arg_opt("corner", &RuntimeType::point2d(), exec_state)?;
let width: TyF64 = args.get_kw_arg("width", &RuntimeType::length(), exec_state)?;
let height: TyF64 = args.get_kw_arg("height", &RuntimeType::length(), exec_state)?;
let tag = args.get_kw_arg_opt("tag", &RuntimeType::tag_decl(), exec_state)?;

inner_rectangle(sketch_or_surface, center, corner, width, height, exec_state, args)
inner_rectangle(sketch_or_surface, center, corner, width, height, tag, exec_state, args)
.await
.map(Box::new)
.map(|value| KclValue::Sketch { value })
Expand All @@ -59,6 +60,7 @@ async fn inner_rectangle(
corner: Option<[TyF64; 2]>,
width: TyF64,
height: TyF64,
tag: Option<TagNode>,
exec_state: &mut ExecState,
args: Args,
) -> Result<Sketch, KclError> {
Expand Down Expand Up @@ -113,6 +115,7 @@ async fn inner_rectangle(
.map(LengthUnit),
relative: true,
},
label: tag.as_ref().map(|node| node.name.clone()),
}),
)
.await?;
Expand Down Expand Up @@ -207,6 +210,7 @@ async fn inner_circle(
radius: LengthUnit(radius.to_mm()),
relative: false,
},
label: tag.as_ref().map(|node| node.name.clone()),
}),
)
.await?;
Expand Down Expand Up @@ -308,6 +312,7 @@ async fn inner_circle_three_point(
radius: units.adjust_to(radius, UnitLen::Mm).0.into(),
relative: false,
},
label: tag.as_ref().map(|node| node.name.clone()),
}),
)
.await?;
Expand Down Expand Up @@ -365,13 +370,15 @@ pub async fn polygon(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
let num_sides: TyF64 = args.get_kw_arg("numSides", &RuntimeType::count(), exec_state)?;
let center = args.get_kw_arg("center", &RuntimeType::point2d(), exec_state)?;
let inscribed = args.get_kw_arg_opt("inscribed", &RuntimeType::bool(), exec_state)?;
let tag = args.get_kw_arg_opt("tag", &RuntimeType::tag_decl(), exec_state)?;

let sketch = inner_polygon(
sketch_or_surface,
radius,
num_sides.n as u64,
center,
inscribed,
tag,
exec_state,
args,
)
Expand All @@ -388,6 +395,7 @@ async fn inner_polygon(
num_sides: u64,
center: [TyF64; 2],
inscribed: Option<bool>,
tag: Option<TagNode>,
exec_state: &mut ExecState,
args: Args,
) -> Result<Sketch, KclError> {
Expand Down Expand Up @@ -459,6 +467,7 @@ async fn inner_polygon(
.map(LengthUnit),
relative: false,
},
label: tag.as_ref().map(|node| node.name.clone()),
}),
)
.await?;
Expand Down Expand Up @@ -494,6 +503,7 @@ async fn inner_polygon(
.map(LengthUnit),
relative: false,
},
label: tag.as_ref().map(|node| node.name.clone()),
}),
)
.await?;
Expand Down Expand Up @@ -611,6 +621,7 @@ async fn inner_ellipse(
start_angle: Angle::from_degrees(angle_start.to_degrees()),
end_angle: Angle::from_degrees(angle_end.to_degrees()),
},
label: tag.as_ref().map(|node| node.name.clone()),
}),
)
.await?;
Expand Down
20 changes: 18 additions & 2 deletions rust/kcl-lib/src/std/sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ async fn inner_involute_circular(
angle: Angle::from_degrees(angle.to_degrees()),
reverse: reverse.unwrap_or_default(),
},
label: tag.as_ref().map(|node| node.name.clone()),
}),
)
.await?;
Expand Down Expand Up @@ -331,6 +332,7 @@ async fn straight_line(
end: KPoint2d::from(point_to_mm(point.clone())).with_z(0.0).map(LengthUnit),
relative: !is_absolute,
},
label: tag.as_ref().map(|node| node.name.clone()),
}),
)
.await?;
Expand Down Expand Up @@ -557,6 +559,7 @@ async fn inner_angled_line_length(
.map(LengthUnit),
relative,
},
label: tag.as_ref().map(|node| node.name.clone()),
}),
)
.await?;
Expand Down Expand Up @@ -1373,6 +1376,7 @@ pub async fn absolute_arc(
},
relative: false,
},
label: tag.as_ref().map(|node| node.name.clone()),
}),
)
.await?;
Expand Down Expand Up @@ -1442,6 +1446,7 @@ pub async fn relative_arc(
radius: LengthUnit(from.units.adjust_to(radius, UnitLen::Mm).0),
relative: false,
},
label: tag.as_ref().map(|node| node.name.clone()),
}),
)
.await?;
Expand Down Expand Up @@ -1609,6 +1614,7 @@ async fn inner_tangential_arc_radius_angle(
radius: LengthUnit(radius.to_mm()),
offset,
},
label: tag.as_ref().map(|node| node.name.clone()),
}),
)
.await?;
Expand Down Expand Up @@ -1642,7 +1648,7 @@ async fn inner_tangential_arc_radius_angle(
}

// `to` must be in sketch.units
fn tan_arc_to(sketch: &Sketch, to: [f64; 2]) -> ModelingCmd {
fn tan_arc_to(sketch: &Sketch, to: [f64; 2], label: Option<String>) -> ModelingCmd {
ModelingCmd::from(mcmd::ExtendPath {
path: sketch.id.into(),
segment: PathSegment::TangentialArcTo {
Expand All @@ -1651,6 +1657,7 @@ fn tan_arc_to(sketch: &Sketch, to: [f64; 2]) -> ModelingCmd {
.with_z(0.0)
.map(LengthUnit),
},
label,
})
}

Expand Down Expand Up @@ -1702,7 +1709,10 @@ async fn inner_tangential_arc_to_point(
};
let id = exec_state.next_uuid();
exec_state
.batch_modeling_cmd(ModelingCmdMeta::from_args_id(&args, id), tan_arc_to(&sketch, delta))
.batch_modeling_cmd(
ModelingCmdMeta::from_args_id(&args, id),
tan_arc_to(&sketch, delta, tag.as_ref().map(|node| node.name.clone())),
)
.await?;

let current_path = Path::TangentialArcTo {
Expand Down Expand Up @@ -1802,6 +1812,7 @@ async fn inner_bezier_curve(
end: KPoint2d::from(point_to_mm(delta)).with_z(0.0).map(LengthUnit),
relative: true,
},
label: tag.as_ref().map(|node| node.name.clone()),
}),
)
.await?;
Expand All @@ -1821,6 +1832,7 @@ async fn inner_bezier_curve(
end: KPoint2d::from(point_to_mm(end)).with_z(0.0).map(LengthUnit),
relative: false,
},
label: tag.as_ref().map(|node| node.name.clone()),
}),
)
.await?;
Expand Down Expand Up @@ -2079,6 +2091,7 @@ pub(crate) async fn inner_elliptic(
start_angle,
end_angle,
},
label: tag.as_ref().map(|node| node.name.clone()),
}),
)
.await?;
Expand Down Expand Up @@ -2246,6 +2259,7 @@ pub(crate) async fn inner_hyperbolic(
interior: KPoint2d::from(untyped_point_to_mm(interior, from.units)).map(LengthUnit),
relative,
},
label: tag.as_ref().map(|node| node.name.clone()),
}),
)
.await?;
Expand Down Expand Up @@ -2459,6 +2473,7 @@ pub(crate) async fn inner_parabolic(
interior: KPoint2d::from(untyped_point_to_mm(interior, from.units)).map(LengthUnit),
relative,
},
label: tag.as_ref().map(|node| node.name.clone()),
}),
)
.await?;
Expand Down Expand Up @@ -2613,6 +2628,7 @@ pub(crate) async fn inner_conic(
interior: KPoint2d::from(untyped_point_to_mm(interior, from.units)).map(LengthUnit),
relative,
},
label: tag.as_ref().map(|node| node.name.clone()),
}),
)
.await?;
Expand Down
6 changes: 5 additions & 1 deletion rust/kcl-to-core/src/conn_mock_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ impl EngineConnection {
to.y.0
)
}
kcmc::ModelingCmd::ExtendPath(kcmc::ExtendPath { path, segment }) => match segment {
kcmc::ModelingCmd::ExtendPath(kcmc::ExtendPath {
path,
segment,
label: _,
}) => match segment {
Line { end, relative } => {
format!(
r#"
Expand Down