turns on helix from edge (#5036)
* updates for new lib Signed-off-by: Jess Frazelle <github@jessfraz.com> * autocomplete Signed-off-by: Jess Frazelle <github@jessfraz.com> * bump version Signed-off-by: Jess Frazelle <github@jessfraz.com> * bump all the things Signed-off-by: Jess Frazelle <github@jessfraz.com> * new samples Signed-off-by: Jess Frazelle <github@jessfraz.com> * docs Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
File diff suppressed because one or more lines are too long
@ -75843,7 +75843,6 @@
|
||||
"required": [
|
||||
"angleStart",
|
||||
"axis",
|
||||
"length",
|
||||
"radius",
|
||||
"revolutions"
|
||||
],
|
||||
@ -75864,9 +75863,10 @@
|
||||
"type": "boolean"
|
||||
},
|
||||
"length": {
|
||||
"description": "Length of the helix.",
|
||||
"description": "Length of the helix. This is not necessary if the helix is created around an edge. If not given the length of the edge is used.",
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
"format": "double",
|
||||
"nullable": true
|
||||
},
|
||||
"radius": {
|
||||
"description": "Radius of the helix.",
|
||||
@ -76962,7 +76962,7 @@
|
||||
"deprecated": false,
|
||||
"examples": [
|
||||
"// Create a helix around the Z axis.\nhelixPath = helix({\n angleStart = 0,\n ccw = true,\n revolutions = 16,\n length = 10,\n radius = 5,\n axis = 'Z'\n})\n\n// Create a spring by sweeping around the helix path.\nspringSketch = startSketchOn('YZ')\n |> circle({ center = [0, 0], radius = 1 }, %)\n// |> sweep({ path = helixPath }, %)",
|
||||
""
|
||||
"// Create a helix around an edge.\nhelper001 = startSketchOn('XZ')\n |> startProfileAt([0, 0], %)\n |> line([0, 10], %, $edge001)\n\nhelixPath = helix({\n angleStart = 0,\n ccw = true,\n revolutions = 16,\n length = 10,\n radius = 5,\n axis = edge001\n})\n\n// Create a spring by sweeping around the helix path.\nspringSketch = startSketchOn('XY')\n |> circle({ center = [0, 0], radius = 1 }, %)\n// |> sweep({ path = helixPath }, %)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@ -19,7 +19,7 @@ Data for a helix.
|
||||
| `revolutions` |`number`| Number of revolutions. | No |
|
||||
| `angleStart` |`number`| Start angle (in degrees). | No |
|
||||
| `ccw` |`boolean`| Is the helix rotation counter clockwise? The default is `false`. | No |
|
||||
| `length` |`number`| Length of the helix. | No |
|
||||
| `length` |`number`| Length of the helix. This is not necessary if the helix is created around an edge. If not given the length of the edge is used. | No |
|
||||
| `radius` |`number`| Radius of the helix. | No |
|
||||
| `axis` |[`Axis3dOrEdgeReference`](/docs/kcl/types/Axis3dOrEdgeReference)| Axis to use as mirror. | No |
|
||||
|
||||
|
||||
14
src/wasm-lib/Cargo.lock
generated
14
src/wasm-lib/Cargo.lock
generated
@ -723,7 +723,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "derive-docs"
|
||||
version = "0.1.33"
|
||||
version = "0.1.34"
|
||||
dependencies = [
|
||||
"Inflector",
|
||||
"anyhow",
|
||||
@ -1716,7 +1716,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-lib"
|
||||
version = "0.2.29"
|
||||
version = "0.2.30"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"approx 0.5.1",
|
||||
@ -1784,7 +1784,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-test-server"
|
||||
version = "0.1.19"
|
||||
version = "0.1.20"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"hyper 0.14.30",
|
||||
@ -1851,9 +1851,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kittycad-modeling-cmds"
|
||||
version = "0.2.86"
|
||||
version = "0.2.89"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65e34a8eeb4fff5167666d1f2bc36c95d08ab3a0f736a02c8d33a8cde21cfd8d"
|
||||
checksum = "ce9e58b34645facea36bc9f4868877bbe6fcac01b92896825e8d4f2f7c71dbd6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
@ -4191,9 +4191,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "1.11.0"
|
||||
version = "1.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a"
|
||||
checksum = "b913a3b5fe84142e269d63cc62b64319ccaf89b748fc31fe025177f767a756c4"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"serde",
|
||||
|
||||
@ -76,7 +76,7 @@ members = [
|
||||
[workspace.dependencies]
|
||||
http = "1"
|
||||
kittycad = { version = "0.3.28", default-features = false, features = ["js", "requests"] }
|
||||
kittycad-modeling-cmds = { version = "0.2.86", features = [
|
||||
kittycad-modeling-cmds = { version = "0.2.89", features = [
|
||||
"ts-rs",
|
||||
"websocket",
|
||||
] }
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "derive-docs"
|
||||
description = "A tool for generating documentation from Rust derive macros"
|
||||
version = "0.1.33"
|
||||
version = "0.1.34"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/KittyCAD/modeling-app"
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "kcl-test-server"
|
||||
description = "A test server for KCL"
|
||||
version = "0.1.19"
|
||||
version = "0.1.20"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "kcl-lib"
|
||||
description = "KittyCAD Language implementation and tools"
|
||||
version = "0.2.29"
|
||||
version = "0.2.30"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/KittyCAD/modeling-app"
|
||||
@ -22,7 +22,7 @@ clap = { version = "4.5.23", default-features = false, optional = true, features
|
||||
] }
|
||||
convert_case = "0.6.0"
|
||||
dashmap = "6.1.0"
|
||||
derive-docs = { version = "0.1.33", path = "../derive-docs" }
|
||||
derive-docs = { version = "0.1.34", path = "../derive-docs" }
|
||||
dhat = { version = "0.3", optional = true }
|
||||
fnv = "1.0.7"
|
||||
form_urlencoded = "1.2.1"
|
||||
|
||||
@ -1024,6 +1024,36 @@ mod tests {
|
||||
assert_eq!(snippet, r#"hole(${0:holeSketch}, ${1:%})${}"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_autocomplete_snippet_helix() {
|
||||
let helix_fn: Box<dyn StdLibFn> = Box::new(crate::std::helix::Helix);
|
||||
let snippet = helix_fn.to_autocomplete_snippet().unwrap();
|
||||
assert_eq!(
|
||||
snippet,
|
||||
r#"helix({
|
||||
revolutions = ${0:3.14},
|
||||
angleStart = ${1:3.14},
|
||||
ccw = ${2:false},
|
||||
radius = ${3:3.14},
|
||||
axis = ${4:"X"},
|
||||
})${}"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_autocomplete_snippet_helix_revolutions() {
|
||||
let helix_fn: Box<dyn StdLibFn> = Box::new(crate::std::helix::HelixRevolutions);
|
||||
let snippet = helix_fn.to_autocomplete_snippet().unwrap();
|
||||
assert_eq!(
|
||||
snippet,
|
||||
r#"helixRevolutions({
|
||||
revolutions = ${0:3.14},
|
||||
angleStart = ${1:3.14},
|
||||
ccw = ${2:false},
|
||||
}, ${3:%})${}"#
|
||||
);
|
||||
}
|
||||
|
||||
// We want to test the snippets we compile at lsp start.
|
||||
#[test]
|
||||
fn get_all_stdlib_autocomplete_snippets() {
|
||||
|
||||
@ -1108,7 +1108,7 @@ impl<'a> FromKclValue<'a> for super::helix::HelixData {
|
||||
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
||||
let obj = arg.as_object()?;
|
||||
let_field_of!(obj, revolutions);
|
||||
let_field_of!(obj, length);
|
||||
let_field_of!(obj, length?);
|
||||
let_field_of!(obj, ccw?);
|
||||
let_field_of!(obj, radius);
|
||||
let_field_of!(obj, axis);
|
||||
|
||||
@ -26,8 +26,9 @@ pub struct HelixData {
|
||||
/// The default is `false`.
|
||||
#[serde(default)]
|
||||
pub ccw: bool,
|
||||
/// Length of the helix.
|
||||
pub length: f64,
|
||||
/// Length of the helix. This is not necessary if the helix is created around an edge. If not
|
||||
/// given the length of the edge is used.
|
||||
pub length: Option<f64>,
|
||||
/// Radius of the helix.
|
||||
pub radius: f64,
|
||||
/// Axis to use as mirror.
|
||||
@ -64,7 +65,7 @@ pub async fn helix(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Create a helix around an edge.
|
||||
/// /*helper001 = startSketchOn('XZ')
|
||||
/// helper001 = startSketchOn('XZ')
|
||||
/// |> startProfileAt([0, 0], %)
|
||||
/// |> line([0, 10], %, $edge001)
|
||||
///
|
||||
@ -80,7 +81,7 @@ pub async fn helix(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// // Create a spring by sweeping around the helix path.
|
||||
/// springSketch = startSketchOn('XY')
|
||||
/// |> circle({ center = [0, 0], radius = 1 }, %)
|
||||
/// |> sweep({ path = helixPath }, %)*/
|
||||
/// //|> sweep({ path = helixPath }, %)
|
||||
/// ```
|
||||
#[stdlib {
|
||||
name = "helix",
|
||||
@ -105,12 +106,20 @@ async fn inner_helix(data: HelixData, exec_state: &mut ExecState, args: Args) ->
|
||||
Axis3dOrEdgeReference::Axis(axis) => {
|
||||
let (axis, origin) = axis.axis_and_origin()?;
|
||||
|
||||
// Make sure they gave us a length.
|
||||
let Some(length) = data.length else {
|
||||
return Err(KclError::Semantic(crate::errors::KclErrorDetails {
|
||||
message: "Length is required when creating a helix around an axis.".to_string(),
|
||||
source_ranges: vec![args.source_range],
|
||||
}));
|
||||
};
|
||||
|
||||
args.batch_modeling_cmd(
|
||||
exec_state.next_uuid(),
|
||||
ModelingCmd::from(mcmd::EntityMakeHelixFromParams {
|
||||
radius: data.radius,
|
||||
is_clockwise: !data.ccw,
|
||||
length: LengthUnit(data.length),
|
||||
length: LengthUnit(length),
|
||||
revolutions: data.revolutions,
|
||||
start_angle: Angle::from_degrees(data.angle_start),
|
||||
axis,
|
||||
@ -119,25 +128,21 @@ async fn inner_helix(data: HelixData, exec_state: &mut ExecState, args: Args) ->
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
Axis3dOrEdgeReference::Edge(_edge) => {
|
||||
/*let edge_id = edge.get_engine_id(exec_state, &args)?;
|
||||
Axis3dOrEdgeReference::Edge(edge) => {
|
||||
let edge_id = edge.get_engine_id(exec_state, &args)?;
|
||||
|
||||
args.batch_modeling_cmd(
|
||||
exec_state.next_uuid(),
|
||||
ModelingCmd::from(mcmd::EntityMakeHelixFromEdge {
|
||||
radius: data.radius,
|
||||
is_clockwise: !data.ccw,
|
||||
length: LengthUnit(data.length),
|
||||
length: data.length.map(LengthUnit),
|
||||
revolutions: data.revolutions,
|
||||
start_angle: Angle::from_degrees(data.angle_start),
|
||||
edge_id,
|
||||
}),
|
||||
)
|
||||
.await?;*/
|
||||
return Err(KclError::Unimplemented(crate::errors::KclErrorDetails {
|
||||
message: "Helix around edge is not yet implemented".to_string(),
|
||||
source_ranges: vec![args.source_range],
|
||||
}));
|
||||
.await?;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 198 KiB |
Reference in New Issue
Block a user