More types stuff (#5901)
* parse union and fancy array types Signed-off-by: Nick Cameron <nrc@ncameron.org> * type aliases Signed-off-by: Nick Cameron <nrc@ncameron.org> * Treat Helix and Face as primitive types Signed-off-by: Nick Cameron <nrc@ncameron.org> * code motion: factor our execution::types module Signed-off-by: Nick Cameron <nrc@ncameron.org> * Tests for type coercion and subtyping Signed-off-by: Nick Cameron <nrc@ncameron.org> * Add Point2D/3D to std Signed-off-by: Nick Cameron <nrc@ncameron.org> * Rebasing and fixes Signed-off-by: Nick Cameron <nrc@ncameron.org> --------- Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
@ -12,10 +12,7 @@ use validator::Validate;
|
||||
|
||||
use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
execution::{
|
||||
kcl_value::{ArrayLen, RuntimeType},
|
||||
ExecState, KclValue, PrimitiveType, Solid,
|
||||
},
|
||||
execution::{types::RuntimeType, ExecState, KclValue, Solid},
|
||||
std::Args,
|
||||
};
|
||||
|
||||
@ -42,11 +39,7 @@ struct AppearanceData {
|
||||
|
||||
/// Set the appearance of a solid. This only works on solids, not sketches or individual paths.
|
||||
pub async fn appearance(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let solids = args.get_unlabeled_kw_arg_typed(
|
||||
"solids",
|
||||
&RuntimeType::Array(PrimitiveType::Solid, ArrayLen::NonEmpty),
|
||||
exec_state,
|
||||
)?;
|
||||
let solids = args.get_unlabeled_kw_arg_typed("solids", &RuntimeType::solids(), exec_state)?;
|
||||
|
||||
let color: String = args.get_kw_arg("color")?;
|
||||
let metalness: Option<f64> = args.get_kw_arg_opt("metalness")?;
|
||||
|
@ -12,9 +12,10 @@ use serde::{Deserialize, Serialize};
|
||||
use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
execution::{
|
||||
kcl_value::{ArrayLen, FunctionSource, NumericType, RuntimeType},
|
||||
ExecState, ExecutorContext, ExtrudeSurface, Helix, KclObjectFields, KclValue, Metadata, PrimitiveType, Sketch,
|
||||
SketchSurface, Solid, TagIdentifier,
|
||||
kcl_value::FunctionSource,
|
||||
types::{NumericType, PrimitiveType, RuntimeType},
|
||||
ExecState, ExecutorContext, ExtrudeSurface, Helix, KclObjectFields, KclValue, Metadata, Sketch, SketchSurface,
|
||||
Solid, TagIdentifier,
|
||||
},
|
||||
parsing::ast::types::TagNode,
|
||||
source_range::SourceRange,
|
||||
@ -188,8 +189,10 @@ impl Args {
|
||||
ty.human_friendly_type(),
|
||||
);
|
||||
let suggestion = match (ty, actual_type_name) {
|
||||
(RuntimeType::Primitive(PrimitiveType::Solid), "Sketch")
|
||||
| (RuntimeType::Array(PrimitiveType::Solid, _), "Sketch") => Some(
|
||||
(RuntimeType::Primitive(PrimitiveType::Solid), "Sketch") => Some(
|
||||
"You can convert a sketch (2D) into a Solid (3D) by calling a function like `extrude` or `revolve`",
|
||||
),
|
||||
(RuntimeType::Array(t, _), "Sketch") if **t == RuntimeType::Primitive(PrimitiveType::Solid) => Some(
|
||||
"You can convert a sketch (2D) into a Solid (3D) by calling a function like `extrude` or `revolve`",
|
||||
),
|
||||
_ => None,
|
||||
@ -309,8 +312,10 @@ impl Args {
|
||||
ty.human_friendly_type(),
|
||||
);
|
||||
let suggestion = match (ty, actual_type_name) {
|
||||
(RuntimeType::Primitive(PrimitiveType::Solid), "Sketch")
|
||||
| (RuntimeType::Array(PrimitiveType::Solid, _), "Sketch") => Some(
|
||||
(RuntimeType::Primitive(PrimitiveType::Solid), "Sketch") => Some(
|
||||
"You can convert a sketch (2D) into a Solid (3D) by calling a function like `extrude` or `revolve`",
|
||||
),
|
||||
(RuntimeType::Array(ty, _), "Sketch") if **ty == RuntimeType::Primitive(PrimitiveType::Solid) => Some(
|
||||
"You can convert a sketch (2D) into a Solid (3D) by calling a function like `extrude` or `revolve`",
|
||||
),
|
||||
_ => None,
|
||||
@ -597,7 +602,7 @@ impl Args {
|
||||
};
|
||||
let sarg = arg0
|
||||
.value
|
||||
.coerce(&RuntimeType::Array(PrimitiveType::Sketch, ArrayLen::None), exec_state)
|
||||
.coerce(&RuntimeType::sketches(), exec_state)
|
||||
.ok_or(KclError::Type(KclErrorDetails {
|
||||
message: format!(
|
||||
"Expected an array of sketches, found {}",
|
||||
@ -685,7 +690,7 @@ impl Args {
|
||||
};
|
||||
let sarg = arg1
|
||||
.value
|
||||
.coerce(&RuntimeType::Array(PrimitiveType::Sketch, ArrayLen::None), exec_state)
|
||||
.coerce(&RuntimeType::sketches(), exec_state)
|
||||
.ok_or(KclError::Type(KclErrorDetails {
|
||||
message: format!(
|
||||
"Expected one or more sketches for second argument, found {}",
|
||||
|
@ -8,8 +8,8 @@ use kittycad_modeling_cmds as kcmc;
|
||||
use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
execution::{
|
||||
kcl_value::RuntimeType, ChamferSurface, EdgeCut, ExecState, ExtrudeSurface, GeoMeta, KclValue, PrimitiveType,
|
||||
Solid,
|
||||
types::{PrimitiveType, RuntimeType},
|
||||
ChamferSurface, EdgeCut, ExecState, ExtrudeSurface, GeoMeta, KclValue, Solid,
|
||||
},
|
||||
parsing::ast::types::TagNode,
|
||||
std::{fillet::EdgeReference, Args},
|
||||
|
@ -5,20 +5,14 @@ use kcl_derive_docs::stdlib;
|
||||
|
||||
use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
execution::{
|
||||
kcl_value::{ArrayLen, RuntimeType},
|
||||
ExecState, KclValue, PrimitiveType, Solid,
|
||||
},
|
||||
execution::{types::RuntimeType, ExecState, KclValue, Solid},
|
||||
std::Args,
|
||||
};
|
||||
|
||||
/// Union two or more solids into a single solid.
|
||||
pub async fn union(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let solids: Vec<Solid> = args.get_unlabeled_kw_arg_typed(
|
||||
"objects",
|
||||
&RuntimeType::Union(vec![RuntimeType::Array(PrimitiveType::Solid, ArrayLen::NonEmpty)]),
|
||||
exec_state,
|
||||
)?;
|
||||
let solids: Vec<Solid> =
|
||||
args.get_unlabeled_kw_arg_typed("solids", &RuntimeType::Union(vec![RuntimeType::solids()]), exec_state)?;
|
||||
|
||||
if solids.len() < 2 {
|
||||
return Err(KclError::UndefinedValue(KclErrorDetails {
|
||||
@ -74,11 +68,7 @@ async fn inner_union(solids: Vec<Solid>, exec_state: &mut ExecState, args: Args)
|
||||
/// Intersect returns the shared volume between multiple solids, preserving only
|
||||
/// overlapping regions.
|
||||
pub async fn intersect(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let solids: Vec<Solid> = args.get_unlabeled_kw_arg_typed(
|
||||
"objects",
|
||||
&RuntimeType::Union(vec![RuntimeType::Array(PrimitiveType::Solid, ArrayLen::NonEmpty)]),
|
||||
exec_state,
|
||||
)?;
|
||||
let solids: Vec<Solid> = args.get_unlabeled_kw_arg_typed("solids", &RuntimeType::solids(), exec_state)?;
|
||||
|
||||
if solids.len() < 2 {
|
||||
return Err(KclError::UndefinedValue(KclErrorDetails {
|
||||
@ -139,16 +129,8 @@ async fn inner_intersect(solids: Vec<Solid>, exec_state: &mut ExecState, args: A
|
||||
|
||||
/// Subtract removes tool solids from base solids, leaving the remaining material.
|
||||
pub async fn subtract(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let solids: Vec<Solid> = args.get_unlabeled_kw_arg_typed(
|
||||
"objects",
|
||||
&RuntimeType::Union(vec![RuntimeType::Array(PrimitiveType::Solid, ArrayLen::NonEmpty)]),
|
||||
exec_state,
|
||||
)?;
|
||||
let tools: Vec<Solid> = args.get_kw_arg_typed(
|
||||
"tools",
|
||||
&RuntimeType::Union(vec![RuntimeType::Array(PrimitiveType::Solid, ArrayLen::NonEmpty)]),
|
||||
exec_state,
|
||||
)?;
|
||||
let solids: Vec<Solid> = args.get_unlabeled_kw_arg_typed("solids", &RuntimeType::solids(), exec_state)?;
|
||||
let tools: Vec<Solid> = args.get_kw_arg_typed("tools", &RuntimeType::solids(), exec_state)?;
|
||||
|
||||
let solids = inner_subtract(solids, tools, exec_state, args).await?;
|
||||
Ok(solids.into())
|
||||
|
@ -19,8 +19,8 @@ use uuid::Uuid;
|
||||
use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
execution::{
|
||||
kcl_value::{ArrayLen, RuntimeType},
|
||||
ArtifactId, ExecState, ExtrudeSurface, GeoMeta, KclValue, Path, PrimitiveType, Sketch, SketchSurface, Solid,
|
||||
types::RuntimeType, ArtifactId, ExecState, ExtrudeSurface, GeoMeta, KclValue, Path, Sketch, SketchSurface,
|
||||
Solid,
|
||||
},
|
||||
parsing::ast::types::TagNode,
|
||||
std::Args,
|
||||
@ -28,11 +28,7 @@ use crate::{
|
||||
|
||||
/// Extrudes by a given amount.
|
||||
pub async fn extrude(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let sketches = args.get_unlabeled_kw_arg_typed(
|
||||
"sketches",
|
||||
&RuntimeType::Array(PrimitiveType::Sketch, ArrayLen::NonEmpty),
|
||||
exec_state,
|
||||
)?;
|
||||
let sketches = args.get_unlabeled_kw_arg_typed("sketches", &RuntimeType::sketches(), exec_state)?;
|
||||
let length = args.get_kw_arg("length")?;
|
||||
let tag_start = args.get_kw_arg_opt("tagStart")?;
|
||||
let tag_end = args.get_kw_arg_opt("tagEnd")?;
|
||||
|
@ -11,8 +11,8 @@ use serde::{Deserialize, Serialize};
|
||||
use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
execution::{
|
||||
kcl_value::RuntimeType, EdgeCut, ExecState, ExtrudeSurface, FilletSurface, GeoMeta, KclValue, PrimitiveType,
|
||||
Solid, TagIdentifier,
|
||||
types::{PrimitiveType, RuntimeType},
|
||||
EdgeCut, ExecState, ExtrudeSurface, FilletSurface, GeoMeta, KclValue, Solid, TagIdentifier,
|
||||
},
|
||||
parsing::ast::types::TagNode,
|
||||
settings::types::UnitLength,
|
||||
|
@ -9,10 +9,7 @@ use kittycad_modeling_cmds as kcmc;
|
||||
|
||||
use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
execution::{
|
||||
kcl_value::{ArrayLen, RuntimeType},
|
||||
ExecState, KclValue, PrimitiveType, Sketch, Solid,
|
||||
},
|
||||
execution::{types::RuntimeType, ExecState, KclValue, Sketch, Solid},
|
||||
parsing::ast::types::TagNode,
|
||||
std::{extrude::do_post_extrude, fillet::default_tolerance, Args},
|
||||
};
|
||||
@ -21,11 +18,7 @@ const DEFAULT_V_DEGREE: u32 = 2;
|
||||
|
||||
/// Create a 3D surface or solid by interpolating between two or more sketches.
|
||||
pub async fn loft(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let sketches = args.get_unlabeled_kw_arg_typed(
|
||||
"sketches",
|
||||
&RuntimeType::Array(PrimitiveType::Sketch, ArrayLen::NonEmpty),
|
||||
exec_state,
|
||||
)?;
|
||||
let sketches = args.get_unlabeled_kw_arg_typed("sketches", &RuntimeType::sketches(), exec_state)?;
|
||||
let v_degree: NonZeroU32 = args
|
||||
.get_kw_arg_opt("vDegree")?
|
||||
.unwrap_or(NonZeroU32::new(DEFAULT_V_DEGREE).unwrap());
|
||||
|
@ -42,7 +42,7 @@ use serde::{Deserialize, Serialize};
|
||||
use crate::{
|
||||
docs::StdLibFn,
|
||||
errors::KclError,
|
||||
execution::{ExecState, KclValue},
|
||||
execution::{types::PrimitiveType, ExecState, KclValue},
|
||||
};
|
||||
|
||||
pub type StdFn = fn(
|
||||
@ -207,20 +207,13 @@ pub(crate) fn std_fn(path: &str, fn_name: &str) -> (crate::std::StdFn, StdFnProp
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn std_ty(path: &str, fn_name: &str) -> (crate::execution::PrimitiveType, StdFnProps) {
|
||||
pub(crate) fn std_ty(path: &str, fn_name: &str) -> (PrimitiveType, StdFnProps) {
|
||||
match (path, fn_name) {
|
||||
("prelude", "Sketch") => (
|
||||
crate::execution::PrimitiveType::Sketch,
|
||||
StdFnProps::default("std::Sketch"),
|
||||
),
|
||||
("prelude", "Solid") => (
|
||||
crate::execution::PrimitiveType::Solid,
|
||||
StdFnProps::default("std::Solid"),
|
||||
),
|
||||
("prelude", "Plane") => (
|
||||
crate::execution::PrimitiveType::Plane,
|
||||
StdFnProps::default("std::Plane"),
|
||||
),
|
||||
("prelude", "Sketch") => (PrimitiveType::Sketch, StdFnProps::default("std::Sketch")),
|
||||
("prelude", "Solid") => (PrimitiveType::Solid, StdFnProps::default("std::Solid")),
|
||||
("prelude", "Plane") => (PrimitiveType::Plane, StdFnProps::default("std::Plane")),
|
||||
("prelude", "Face") => (PrimitiveType::Face, StdFnProps::default("std::Face")),
|
||||
("prelude", "Helix") => (PrimitiveType::Helix, StdFnProps::default("std::Helix")),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,9 @@ use super::args::Arg;
|
||||
use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
execution::{
|
||||
kcl_value::{ArrayLen, FunctionSource, NumericType, RuntimeType},
|
||||
ExecState, Geometries, Geometry, KclObjectFields, KclValue, Point2d, Point3d, PrimitiveType, Sketch, Solid,
|
||||
kcl_value::FunctionSource,
|
||||
types::{NumericType, RuntimeType},
|
||||
ExecState, Geometries, Geometry, KclObjectFields, KclValue, Point2d, Point3d, Sketch, Solid,
|
||||
},
|
||||
std::Args,
|
||||
ExecutorContext, SourceRange,
|
||||
@ -47,11 +48,7 @@ pub struct LinearPattern3dData {
|
||||
|
||||
/// Repeat some 3D solid, changing each repetition slightly.
|
||||
pub async fn pattern_transform(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let solids = args.get_unlabeled_kw_arg_typed(
|
||||
"solids",
|
||||
&RuntimeType::Array(PrimitiveType::Solid, ArrayLen::NonEmpty),
|
||||
exec_state,
|
||||
)?;
|
||||
let solids = args.get_unlabeled_kw_arg_typed("solids", &RuntimeType::solids(), exec_state)?;
|
||||
let instances: u32 = args.get_kw_arg("instances")?;
|
||||
let transform: &FunctionSource = args.get_kw_arg("transform")?;
|
||||
let use_original: Option<bool> = args.get_kw_arg_opt("useOriginal")?;
|
||||
@ -62,11 +59,7 @@ pub async fn pattern_transform(exec_state: &mut ExecState, args: Args) -> Result
|
||||
|
||||
/// Repeat some 2D sketch, changing each repetition slightly.
|
||||
pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let sketches = args.get_unlabeled_kw_arg_typed(
|
||||
"sketches",
|
||||
&RuntimeType::Array(PrimitiveType::Sketch, ArrayLen::NonEmpty),
|
||||
exec_state,
|
||||
)?;
|
||||
let sketches = args.get_unlabeled_kw_arg_typed("sketches", &RuntimeType::sketches(), exec_state)?;
|
||||
let instances: u32 = args.get_kw_arg("instances")?;
|
||||
let transform: &FunctionSource = args.get_kw_arg("transform")?;
|
||||
let use_original: Option<bool> = args.get_kw_arg_opt("useOriginal")?;
|
||||
@ -664,7 +657,7 @@ impl GeometryTrait for Solid {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::execution::kcl_value::NumericType;
|
||||
use crate::execution::types::NumericType;
|
||||
|
||||
#[test]
|
||||
fn test_array_to_point3d() {
|
||||
@ -696,11 +689,7 @@ mod tests {
|
||||
|
||||
/// A linear pattern on a 2D sketch.
|
||||
pub async fn pattern_linear_2d(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let sketches = args.get_unlabeled_kw_arg_typed(
|
||||
"sketches",
|
||||
&RuntimeType::Array(PrimitiveType::Sketch, ArrayLen::NonEmpty),
|
||||
exec_state,
|
||||
)?;
|
||||
let sketches = args.get_unlabeled_kw_arg_typed("sketches", &RuntimeType::sketches(), exec_state)?;
|
||||
let instances: u32 = args.get_kw_arg("instances")?;
|
||||
let distance: f64 = args.get_kw_arg("distance")?;
|
||||
let axis: [f64; 2] = args.get_kw_arg("axis")?;
|
||||
@ -779,11 +768,7 @@ async fn inner_pattern_linear_2d(
|
||||
|
||||
/// A linear pattern on a 3D model.
|
||||
pub async fn pattern_linear_3d(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let solids = args.get_unlabeled_kw_arg_typed(
|
||||
"solids",
|
||||
&RuntimeType::Array(PrimitiveType::Solid, ArrayLen::NonEmpty),
|
||||
exec_state,
|
||||
)?;
|
||||
let solids = args.get_unlabeled_kw_arg_typed("solids", &RuntimeType::solids(), exec_state)?;
|
||||
let instances: u32 = args.get_kw_arg("instances")?;
|
||||
let distance: f64 = args.get_kw_arg("distance")?;
|
||||
let axis: [f64; 3] = args.get_kw_arg("axis")?;
|
||||
@ -1028,11 +1013,7 @@ impl CircularPattern {
|
||||
|
||||
/// A circular pattern on a 2D sketch.
|
||||
pub async fn pattern_circular_2d(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let sketches = args.get_unlabeled_kw_arg_typed(
|
||||
"sketches",
|
||||
&RuntimeType::Array(PrimitiveType::Sketch, ArrayLen::NonEmpty),
|
||||
exec_state,
|
||||
)?;
|
||||
let sketches = args.get_unlabeled_kw_arg_typed("sketches", &RuntimeType::sketches(), exec_state)?;
|
||||
let instances: u32 = args.get_kw_arg("instances")?;
|
||||
let center: [f64; 2] = args.get_kw_arg("center")?;
|
||||
let arc_degrees: f64 = args.get_kw_arg("arcDegrees")?;
|
||||
@ -1136,11 +1117,7 @@ async fn inner_pattern_circular_2d(
|
||||
|
||||
/// A circular pattern on a 3D model.
|
||||
pub async fn pattern_circular_3d(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let solids = args.get_unlabeled_kw_arg_typed(
|
||||
"solids",
|
||||
&RuntimeType::Array(PrimitiveType::Solid, ArrayLen::NonEmpty),
|
||||
exec_state,
|
||||
)?;
|
||||
let solids = args.get_unlabeled_kw_arg_typed("solids", &RuntimeType::solids(), exec_state)?;
|
||||
// The number of total instances. Must be greater than or equal to 1.
|
||||
// This includes the original entity. For example, if instances is 2,
|
||||
// there will be two copies -- the original, and one new copy.
|
||||
|
@ -7,21 +7,14 @@ use kittycad_modeling_cmds::{self as kcmc};
|
||||
|
||||
use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
execution::{
|
||||
kcl_value::{ArrayLen, RuntimeType},
|
||||
ExecState, KclValue, PrimitiveType, Sketch, Solid,
|
||||
},
|
||||
execution::{types::RuntimeType, ExecState, KclValue, Sketch, Solid},
|
||||
parsing::ast::types::TagNode,
|
||||
std::{axis_or_reference::Axis2dOrEdgeReference, extrude::do_post_extrude, fillet::default_tolerance, Args},
|
||||
};
|
||||
|
||||
/// Revolve a sketch or set of sketches around an axis.
|
||||
pub async fn revolve(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let sketches = args.get_unlabeled_kw_arg_typed(
|
||||
"sketches",
|
||||
&RuntimeType::Array(PrimitiveType::Sketch, ArrayLen::NonEmpty),
|
||||
exec_state,
|
||||
)?;
|
||||
let sketches = args.get_unlabeled_kw_arg_typed("sketches", &RuntimeType::sketches(), exec_state)?;
|
||||
let axis: Axis2dOrEdgeReference = args.get_kw_arg("axis")?;
|
||||
let angle = args.get_kw_arg_opt("angle")?;
|
||||
let tolerance = args.get_kw_arg_opt("tolerance")?;
|
||||
|
@ -6,7 +6,10 @@ use kittycad_modeling_cmds::shared::Angle;
|
||||
|
||||
use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
execution::{kcl_value::RuntimeType, ExecState, KclValue, Point2d, PrimitiveType, Sketch, TagIdentifier},
|
||||
execution::{
|
||||
types::{PrimitiveType, RuntimeType},
|
||||
ExecState, KclValue, Point2d, Sketch, TagIdentifier,
|
||||
},
|
||||
std::{utils::between, Args},
|
||||
};
|
||||
|
||||
|
@ -7,20 +7,13 @@ use kittycad_modeling_cmds as kcmc;
|
||||
|
||||
use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
execution::{
|
||||
kcl_value::{ArrayLen, RuntimeType},
|
||||
ExecState, KclValue, PrimitiveType, Solid,
|
||||
},
|
||||
execution::{types::RuntimeType, ExecState, KclValue, Solid},
|
||||
std::{sketch::FaceTag, Args},
|
||||
};
|
||||
|
||||
/// Create a shell.
|
||||
pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let solids = args.get_unlabeled_kw_arg_typed(
|
||||
"solids",
|
||||
&RuntimeType::Array(PrimitiveType::Solid, ArrayLen::NonEmpty),
|
||||
exec_state,
|
||||
)?;
|
||||
let solids = args.get_unlabeled_kw_arg_typed("solids", &RuntimeType::solids(), exec_state)?;
|
||||
let thickness = args.get_kw_arg("thickness")?;
|
||||
let faces = args.get_kw_arg("faces")?;
|
||||
|
||||
|
@ -14,9 +14,9 @@ use serde::{Deserialize, Serialize};
|
||||
use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
execution::{
|
||||
kcl_value::RuntimeType, Artifact, ArtifactId, BasePath, CodeRef, ExecState, Face, GeoMeta, KclValue, Path,
|
||||
Plane, Point2d, Point3d, PrimitiveType, Sketch, SketchSurface, Solid, StartSketchOnFace, StartSketchOnPlane,
|
||||
TagEngineInfo, TagIdentifier,
|
||||
types::{PrimitiveType, RuntimeType},
|
||||
Artifact, ArtifactId, BasePath, CodeRef, ExecState, Face, GeoMeta, KclValue, Path, Plane, Point2d, Point3d,
|
||||
Sketch, SketchSurface, Solid, StartSketchOnFace, StartSketchOnPlane, TagEngineInfo, TagIdentifier,
|
||||
},
|
||||
parsing::ast::types::TagNode,
|
||||
std::{
|
||||
|
@ -9,10 +9,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
errors::KclError,
|
||||
execution::{
|
||||
kcl_value::{ArrayLen, RuntimeType},
|
||||
ExecState, Helix, KclValue, PrimitiveType, Sketch, Solid,
|
||||
},
|
||||
execution::{types::RuntimeType, ExecState, Helix, KclValue, Sketch, Solid},
|
||||
parsing::ast::types::TagNode,
|
||||
std::{extrude::do_post_extrude, fillet::default_tolerance, Args},
|
||||
};
|
||||
@ -28,11 +25,7 @@ pub enum SweepPath {
|
||||
|
||||
/// Extrude a sketch along a path.
|
||||
pub async fn sweep(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let sketches = args.get_unlabeled_kw_arg_typed(
|
||||
"sketches",
|
||||
&RuntimeType::Array(PrimitiveType::Sketch, ArrayLen::NonEmpty),
|
||||
exec_state,
|
||||
)?;
|
||||
let sketches = args.get_unlabeled_kw_arg_typed("sketches", &RuntimeType::sketches(), exec_state)?;
|
||||
let path: SweepPath = args.get_kw_arg("path")?;
|
||||
let sectional = args.get_kw_arg_opt("sectional")?;
|
||||
let tolerance = args.get_kw_arg_opt("tolerance")?;
|
||||
|
@ -13,10 +13,7 @@ use kittycad_modeling_cmds as kcmc;
|
||||
|
||||
use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
execution::{
|
||||
kcl_value::{ArrayLen, RuntimeType},
|
||||
ExecState, KclValue, PrimitiveType, SolidOrSketchOrImportedGeometry,
|
||||
},
|
||||
execution::{types::RuntimeType, ExecState, KclValue, SolidOrSketchOrImportedGeometry},
|
||||
std::Args,
|
||||
};
|
||||
|
||||
@ -25,9 +22,9 @@ pub async fn scale(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
let objects = args.get_unlabeled_kw_arg_typed(
|
||||
"objects",
|
||||
&RuntimeType::Union(vec![
|
||||
RuntimeType::Array(PrimitiveType::Sketch, ArrayLen::NonEmpty),
|
||||
RuntimeType::Array(PrimitiveType::Solid, ArrayLen::NonEmpty),
|
||||
RuntimeType::Primitive(PrimitiveType::ImportedGeometry),
|
||||
RuntimeType::sketches(),
|
||||
RuntimeType::solids(),
|
||||
RuntimeType::imported(),
|
||||
]),
|
||||
exec_state,
|
||||
)?;
|
||||
@ -187,9 +184,9 @@ pub async fn translate(exec_state: &mut ExecState, args: Args) -> Result<KclValu
|
||||
let objects = args.get_unlabeled_kw_arg_typed(
|
||||
"objects",
|
||||
&RuntimeType::Union(vec![
|
||||
RuntimeType::Array(PrimitiveType::Sketch, ArrayLen::NonEmpty),
|
||||
RuntimeType::Array(PrimitiveType::Solid, ArrayLen::NonEmpty),
|
||||
RuntimeType::Primitive(PrimitiveType::ImportedGeometry),
|
||||
RuntimeType::sketches(),
|
||||
RuntimeType::solids(),
|
||||
RuntimeType::imported(),
|
||||
]),
|
||||
exec_state,
|
||||
)?;
|
||||
@ -390,9 +387,9 @@ pub async fn rotate(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
let objects = args.get_unlabeled_kw_arg_typed(
|
||||
"objects",
|
||||
&RuntimeType::Union(vec![
|
||||
RuntimeType::Array(PrimitiveType::Sketch, ArrayLen::NonEmpty),
|
||||
RuntimeType::Array(PrimitiveType::Solid, ArrayLen::NonEmpty),
|
||||
RuntimeType::Primitive(PrimitiveType::ImportedGeometry),
|
||||
RuntimeType::sketches(),
|
||||
RuntimeType::solids(),
|
||||
RuntimeType::imported(),
|
||||
]),
|
||||
exec_state,
|
||||
)?;
|
||||
|
@ -5,7 +5,7 @@ use kcl_derive_docs::stdlib;
|
||||
|
||||
use crate::{
|
||||
errors::KclError,
|
||||
execution::{ExecState, KclValue, UnitLen},
|
||||
execution::{types::UnitLen, ExecState, KclValue},
|
||||
std::Args,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user