Support new sweep flag (#6932)
Closes https://github.com/KittyCAD/engine/issues/3115
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -13,6 +13,7 @@ sweep(
|
||||
path: Sketch | Helix,
|
||||
sectional?: bool,
|
||||
tolerance?: number,
|
||||
relativeTo?: string,
|
||||
tagStart?: TagDeclarator,
|
||||
tagEnd?: TagDeclarator,
|
||||
): [Solid]
|
||||
@ -30,6 +31,7 @@ You can provide more than one sketch to sweep, and they will all be swept along
|
||||
| `path` | [`Sketch`](/docs/kcl-std/types/std-types-Sketch) or [`Helix`](/docs/kcl-std/types/std-types-Helix) | The path to sweep the sketch along | Yes |
|
||||
| `sectional` | [`bool`](/docs/kcl-std/types/std-types-bool) | If true, the sweep will be broken up into sub-sweeps (extrusions, revolves, sweeps) based on the trajectory path components. | No |
|
||||
| `tolerance` | [`number`](/docs/kcl-std/types/std-types-number) | Tolerance for this operation | No |
|
||||
| `relativeTo` | [`string`](/docs/kcl-std/types/std-types-string) | What is the sweep relative to? Can be either 'sketchPlane' or 'trajectoryCurve'. Defaults to sketchPlane. | No |
|
||||
| `tagStart` | [`TagDeclarator`](/docs/kcl-lang/types#TagDeclarator) | A named tag for the face at the start of the sweep, i.e. the original sketch | No |
|
||||
| `tagEnd` | [`TagDeclarator`](/docs/kcl-lang/types#TagDeclarator) | A named tag for the face at the end of the sweep | No |
|
||||
|
||||
|
18
rust/Cargo.lock
generated
18
rust/Cargo.lock
generated
@ -535,7 +535,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -963,7 +963,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1746,7 +1746,7 @@ checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2080,9 +2080,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kittycad-modeling-cmds"
|
||||
version = "0.2.120"
|
||||
version = "0.2.121"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48b71e06ee5d711d0085864a756fb6a304531246689ea00c6ef5d740670c3701"
|
||||
checksum = "94ba95c22493d79ec8a1faab963d8903f6de0e373efedf2bc3bb76a0ddbab036"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
@ -2987,7 +2987,7 @@ dependencies = [
|
||||
"once_cell",
|
||||
"socket2",
|
||||
"tracing",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3306,7 +3306,7 @@ dependencies = [
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3900,7 +3900,7 @@ dependencies = [
|
||||
"getrandom 0.3.1",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -4753,7 +4753,7 @@ version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||
dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3,7 +3,7 @@
|
||||
use anyhow::Result;
|
||||
use kcl_derive_docs::stdlib;
|
||||
use kcmc::{each_cmd as mcmd, length_unit::LengthUnit, ModelingCmd};
|
||||
use kittycad_modeling_cmds::{self as kcmc};
|
||||
use kittycad_modeling_cmds::{self as kcmc, shared::RelativeTo};
|
||||
use schemars::JsonSchema;
|
||||
use serde::Serialize;
|
||||
|
||||
@ -37,11 +37,20 @@ pub async fn sweep(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
)?;
|
||||
let sectional = args.get_kw_arg_opt("sectional")?;
|
||||
let tolerance: Option<TyF64> = args.get_kw_arg_opt_typed("tolerance", &RuntimeType::length(), exec_state)?;
|
||||
let relative_to: Option<String> = args.get_kw_arg_opt_typed("relativeTo", &RuntimeType::string(), exec_state)?;
|
||||
let tag_start = args.get_kw_arg_opt("tagStart")?;
|
||||
let tag_end = args.get_kw_arg_opt("tagEnd")?;
|
||||
|
||||
let value = inner_sweep(
|
||||
sketches, path, sectional, tolerance, tag_start, tag_end, exec_state, args,
|
||||
sketches,
|
||||
path,
|
||||
sectional,
|
||||
tolerance,
|
||||
relative_to,
|
||||
tag_start,
|
||||
tag_end,
|
||||
exec_state,
|
||||
args,
|
||||
)
|
||||
.await?;
|
||||
Ok(value.into())
|
||||
@ -158,6 +167,7 @@ pub async fn sweep(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
path = { docs = "The path to sweep the sketch along" },
|
||||
sectional = { docs = "If true, the sweep will be broken up into sub-sweeps (extrusions, revolves, sweeps) based on the trajectory path components." },
|
||||
tolerance = { docs = "Tolerance for this operation" },
|
||||
relative_to = { docs = "What is the sweep relative to? Can be either 'sketchPlane' or 'trajectoryCurve'. Defaults to sketchPlane."},
|
||||
tag_start = { docs = "A named tag for the face at the start of the sweep, i.e. the original sketch" },
|
||||
tag_end = { docs = "A named tag for the face at the end of the sweep" },
|
||||
},
|
||||
@ -169,6 +179,7 @@ async fn inner_sweep(
|
||||
path: SweepPath,
|
||||
sectional: Option<bool>,
|
||||
tolerance: Option<TyF64>,
|
||||
relative_to: Option<String>,
|
||||
tag_start: Option<TagNode>,
|
||||
tag_end: Option<TagNode>,
|
||||
exec_state: &mut ExecState,
|
||||
@ -178,6 +189,17 @@ async fn inner_sweep(
|
||||
SweepPath::Sketch(sketch) => sketch.id.into(),
|
||||
SweepPath::Helix(helix) => helix.value.into(),
|
||||
};
|
||||
let relative_to = match relative_to.as_deref() {
|
||||
Some("sketchPlane") => RelativeTo::SketchPlane,
|
||||
Some("trajectoryCurve") => RelativeTo::TrajectoryCurve,
|
||||
Some(_) => {
|
||||
return Err(KclError::Syntax(crate::errors::KclErrorDetails {
|
||||
source_ranges: vec![args.source_range],
|
||||
message: "If you provide relativeTo, it must either be 'sketchPlane' or 'trajectoryCurve'".to_owned(),
|
||||
}))
|
||||
}
|
||||
None => RelativeTo::default(),
|
||||
};
|
||||
|
||||
let mut solids = Vec::new();
|
||||
for sketch in &sketches {
|
||||
@ -189,6 +211,7 @@ async fn inner_sweep(
|
||||
trajectory,
|
||||
sectional: sectional.unwrap_or(false),
|
||||
tolerance: LengthUnit(tolerance.as_ref().map(|t| t.to_mm()).unwrap_or(DEFAULT_TOLERANCE)),
|
||||
relative_to,
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
|
@ -5121,7 +5121,8 @@ description: Artifact commands bench.kcl
|
||||
"target": "[uuid]",
|
||||
"trajectory": "[uuid]",
|
||||
"sectional": false,
|
||||
"tolerance": 0.0000001
|
||||
"tolerance": 0.0000001,
|
||||
"relative_to": "sketch_plane"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -5132,7 +5133,8 @@ description: Artifact commands bench.kcl
|
||||
"target": "[uuid]",
|
||||
"trajectory": "[uuid]",
|
||||
"sectional": false,
|
||||
"tolerance": 0.0000001
|
||||
"tolerance": 0.0000001,
|
||||
"relative_to": "sketch_plane"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -905,7 +905,8 @@ description: Artifact commands cold-plate.kcl
|
||||
"target": "[uuid]",
|
||||
"trajectory": "[uuid]",
|
||||
"sectional": false,
|
||||
"tolerance": 0.0000001
|
||||
"tolerance": 0.0000001,
|
||||
"relative_to": "sketch_plane"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -5575,7 +5575,8 @@ description: Artifact commands cpu-cooler.kcl
|
||||
"target": "[uuid]",
|
||||
"trajectory": "[uuid]",
|
||||
"sectional": false,
|
||||
"tolerance": 0.0000001
|
||||
"tolerance": 0.0000001,
|
||||
"relative_to": "sketch_plane"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -6109,7 +6110,8 @@ description: Artifact commands cpu-cooler.kcl
|
||||
"target": "[uuid]",
|
||||
"trajectory": "[uuid]",
|
||||
"sectional": false,
|
||||
"tolerance": 0.0000001
|
||||
"tolerance": 0.0000001,
|
||||
"relative_to": "sketch_plane"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -9466,7 +9468,8 @@ description: Artifact commands cpu-cooler.kcl
|
||||
"target": "[uuid]",
|
||||
"trajectory": "[uuid]",
|
||||
"sectional": false,
|
||||
"tolerance": 0.0000001
|
||||
"tolerance": 0.0000001,
|
||||
"relative_to": "sketch_plane"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -9597,7 +9600,8 @@ description: Artifact commands cpu-cooler.kcl
|
||||
"target": "[uuid]",
|
||||
"trajectory": "[uuid]",
|
||||
"sectional": false,
|
||||
"tolerance": 0.0000001
|
||||
"tolerance": 0.0000001,
|
||||
"relative_to": "sketch_plane"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -10115,7 +10119,8 @@ description: Artifact commands cpu-cooler.kcl
|
||||
"target": "[uuid]",
|
||||
"trajectory": "[uuid]",
|
||||
"sectional": false,
|
||||
"tolerance": 0.0000001
|
||||
"tolerance": 0.0000001,
|
||||
"relative_to": "sketch_plane"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -10246,7 +10251,8 @@ description: Artifact commands cpu-cooler.kcl
|
||||
"target": "[uuid]",
|
||||
"trajectory": "[uuid]",
|
||||
"sectional": false,
|
||||
"tolerance": 0.0000001
|
||||
"tolerance": 0.0000001,
|
||||
"relative_to": "sketch_plane"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -1597,7 +1597,8 @@ description: Artifact commands exhaust-manifold.kcl
|
||||
"target": "[uuid]",
|
||||
"trajectory": "[uuid]",
|
||||
"sectional": false,
|
||||
"tolerance": 0.0000001
|
||||
"tolerance": 0.0000001,
|
||||
"relative_to": "sketch_plane"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -1608,7 +1609,8 @@ description: Artifact commands exhaust-manifold.kcl
|
||||
"target": "[uuid]",
|
||||
"trajectory": "[uuid]",
|
||||
"sectional": false,
|
||||
"tolerance": 0.0000001
|
||||
"tolerance": 0.0000001,
|
||||
"relative_to": "sketch_plane"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -1619,7 +1621,8 @@ description: Artifact commands exhaust-manifold.kcl
|
||||
"target": "[uuid]",
|
||||
"trajectory": "[uuid]",
|
||||
"sectional": false,
|
||||
"tolerance": 0.0000001
|
||||
"tolerance": 0.0000001,
|
||||
"relative_to": "sketch_plane"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -1630,7 +1633,8 @@ description: Artifact commands exhaust-manifold.kcl
|
||||
"target": "[uuid]",
|
||||
"trajectory": "[uuid]",
|
||||
"sectional": false,
|
||||
"tolerance": 0.0000001
|
||||
"tolerance": 0.0000001,
|
||||
"relative_to": "sketch_plane"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -4490,7 +4490,8 @@ description: Artifact commands utility-sink.kcl
|
||||
"target": "[uuid]",
|
||||
"trajectory": "[uuid]",
|
||||
"sectional": false,
|
||||
"tolerance": 0.0000001
|
||||
"tolerance": 0.0000001,
|
||||
"relative_to": "sketch_plane"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -417,7 +417,8 @@ description: Artifact commands subtract_regression03.kcl
|
||||
"target": "[uuid]",
|
||||
"trajectory": "[uuid]",
|
||||
"sectional": false,
|
||||
"tolerance": 0.0000001
|
||||
"tolerance": 0.0000001,
|
||||
"relative_to": "sketch_plane"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -394,7 +394,8 @@ description: Artifact commands subtract_regression05.kcl
|
||||
"target": "[uuid]",
|
||||
"trajectory": "[uuid]",
|
||||
"sectional": false,
|
||||
"tolerance": 0.0000001
|
||||
"tolerance": 0.0000001,
|
||||
"relative_to": "sketch_plane"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
Reference in New Issue
Block a user