KCL: Angled line should use keyword args (#5803)
We continue migrating KCL stdlib functions to use keyword arguments. Next up is the `angledLine` family of functions (except `angledLineThatIntersects, which will be a quick follow-up). Before vs. after: `angledLine({angle = 90, length = 3}, %, $edge)` => `angledLine(angle = 90, length = 3, tag = $edge)` `angledLineOfXLength({angle = 90, length = 3}, %, $edge)` => `angledLine(angle = 90, lengthX = 3, tag = $edge)` `angledLineOfYLength({angle = 90, length = 3}, %, $edge)` => `angledLine(angle = 90, lengthY = 3, tag = $edge)` `angledLineToX({angle = 90, length = 3}, %, $edge)` => `angledLine(angle = 90, endAbsoluteX = 3, tag = $edge)` `angledLineToY({angle = 90, length = 3}, %, $edge)` => `angledLine(angle = 90, endAbsoluteY = 3, tag = $edge)`
This commit is contained in:
@ -1243,24 +1243,6 @@ impl<'a> FromKclValue<'a> for FaceTag {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> FromKclValue<'a> for super::sketch::AngledLineToData {
|
||||
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
||||
// Deserialize from an {angle, to} object.
|
||||
let case1 = || {
|
||||
let obj = arg.as_object()?;
|
||||
let_field_of!(obj, to);
|
||||
let_field_of!(obj, angle);
|
||||
Some(Self { angle, to })
|
||||
};
|
||||
// Deserialize from an [angle, to] array.
|
||||
let case2 = || {
|
||||
let [angle, to] = arg.as_point2d()?;
|
||||
Some(Self { angle, to })
|
||||
};
|
||||
case1().or_else(case2)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> FromKclValue<'a> for super::sketch::ArcData {
|
||||
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
||||
let obj = arg.as_object()?;
|
||||
@ -1580,24 +1562,6 @@ impl<'a> FromKclValue<'a> for super::axis_or_reference::Axis3dOrEdgeReference {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> FromKclValue<'a> for super::sketch::AngledLineData {
|
||||
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
||||
let case1 = |arg: &KclValue| {
|
||||
let obj = arg.as_object()?;
|
||||
let_field_of!(obj, angle);
|
||||
let_field_of!(obj, length);
|
||||
Some(Self::AngleAndLengthNamed { angle, length })
|
||||
};
|
||||
let case2 = |arg: &KclValue| {
|
||||
let array = arg.as_array()?;
|
||||
let ang = array.first()?.as_f64()?;
|
||||
let len = array.get(1)?.as_f64()?;
|
||||
Some(Self::AngleAndLengthPair([ang, len]))
|
||||
};
|
||||
case1(arg).or_else(|| case2(arg))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> FromKclValue<'a> for i64 {
|
||||
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
||||
match arg {
|
||||
|
Reference in New Issue
Block a user