From 42f44e11f512d020cfcd92c35b829f1dd22e23ca Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Fri, 28 Mar 2025 11:18:10 +0800 Subject: [PATCH] Add Edge type to std Signed-off-by: Nick Cameron --- docs/kcl/index.md | 1 + docs/kcl/types/Edge.md | 12 ++++++++++++ rust/kcl-lib/src/docs/gen_std_tests.rs | 4 ++-- rust/kcl-lib/src/execution/types.rs | 8 ++++++++ rust/kcl-lib/std/prelude.kcl | 4 ++++ 5 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 docs/kcl/types/Edge.md diff --git a/docs/kcl/index.md b/docs/kcl/index.md index 97bf13f51..f04c9ebb8 100644 --- a/docs/kcl/index.md +++ b/docs/kcl/index.md @@ -22,6 +22,7 @@ layout: manual * [`string`](kcl/types/string) * [`tag`](kcl/types/tag) * **std** + * [`Edge`](kcl/types/Edge) * [`Face`](kcl/types/Face) * [`Helix`](kcl/types/Helix) * [`Plane`](kcl/types/Plane) diff --git a/docs/kcl/types/Edge.md b/docs/kcl/types/Edge.md new file mode 100644 index 000000000..78644b2a0 --- /dev/null +++ b/docs/kcl/types/Edge.md @@ -0,0 +1,12 @@ +--- +title: "std::Edge" +excerpt: "The edge of a solid." +layout: manual +--- + +The edge of a solid. + + + + + diff --git a/rust/kcl-lib/src/docs/gen_std_tests.rs b/rust/kcl-lib/src/docs/gen_std_tests.rs index 475329a58..8753456b4 100644 --- a/rust/kcl-lib/src/docs/gen_std_tests.rs +++ b/rust/kcl-lib/src/docs/gen_std_tests.rs @@ -23,8 +23,8 @@ use crate::{ const TYPES_DIR: &str = "../../docs/kcl/types"; const LANG_TOPICS: [&str; 5] = ["Types", "Modules", "Settings", "Known Issues", "Constants"]; // These types are declared in std. -const DECLARED_TYPES: [&str; 11] = [ - "number", "string", "tag", "bool", "Sketch", "Solid", "Plane", "Helix", "Face", "Point2d", "Point3d", +const DECLARED_TYPES: [&str; 12] = [ + "number", "string", "tag", "bool", "Sketch", "Solid", "Plane", "Helix", "Face", "Edge", "Point2d", "Point3d", ]; fn init_handlebars() -> Result> { diff --git a/rust/kcl-lib/src/execution/types.rs b/rust/kcl-lib/src/execution/types.rs index 2728ddc83..4fa0aabc5 100644 --- a/rust/kcl-lib/src/execution/types.rs +++ b/rust/kcl-lib/src/execution/types.rs @@ -233,6 +233,7 @@ pub enum PrimitiveType { Plane, Helix, Face, + Edge, ImportedGeometry, } @@ -248,6 +249,7 @@ impl PrimitiveType { PrimitiveType::Plane => "Planes".to_owned(), PrimitiveType::Helix => "Helices".to_owned(), PrimitiveType::Face => "Faces".to_owned(), + PrimitiveType::Edge => "Edges".to_owned(), PrimitiveType::ImportedGeometry => "imported geometries".to_owned(), PrimitiveType::Tag => "tags".to_owned(), } @@ -273,6 +275,7 @@ impl fmt::Display for PrimitiveType { PrimitiveType::Solid => write!(f, "Solid"), PrimitiveType::Plane => write!(f, "Plane"), PrimitiveType::Face => write!(f, "Face"), + PrimitiveType::Edge => write!(f, "Edge"), PrimitiveType::Helix => write!(f, "Helix"), PrimitiveType::ImportedGeometry => write!(f, "imported geometry"), } @@ -609,6 +612,11 @@ impl KclValue { KclValue::Helix { .. } => Some(value.clone()), _ => None, }, + PrimitiveType::Edge => match value { + KclValue::Uuid { .. } => Some(value.clone()), + KclValue::TagIdentifier { .. } => Some(value.clone()), + _ => None, + }, PrimitiveType::ImportedGeometry => match value { KclValue::ImportedGeometry { .. } => Some(value.clone()), _ => None, diff --git a/rust/kcl-lib/std/prelude.kcl b/rust/kcl-lib/std/prelude.kcl index 6addc621a..7bf5fa863 100644 --- a/rust/kcl-lib/std/prelude.kcl +++ b/rust/kcl-lib/std/prelude.kcl @@ -234,6 +234,10 @@ export type Face @(impl = std_rust) export type Helix +/// The edge of a solid. +@(impl = std_rust) +export type Edge + /// A point in two dimensional space. /// /// `Point2d` is an alias for a two-element array of [number](/docs/kcl/types/number)s. To write a value