2023-08-24 15:34:51 -07:00
|
|
|
//! Functions implemented for language execution.
|
|
|
|
|
2024-12-10 17:51:51 -08:00
|
|
|
pub mod appearance;
|
2024-07-16 07:45:43 -05:00
|
|
|
pub mod args;
|
2024-09-14 00:10:17 -04:00
|
|
|
pub mod array;
|
2024-07-26 15:14:51 -04:00
|
|
|
pub mod assert;
|
2025-01-07 19:10:53 -08:00
|
|
|
pub mod axis_or_reference;
|
2024-06-17 12:13:19 -07:00
|
|
|
pub mod chamfer;
|
2025-04-23 21:26:09 -07:00
|
|
|
pub mod clone;
|
2025-03-19 19:26:57 -07:00
|
|
|
pub mod csg;
|
2025-03-19 15:12:27 -07:00
|
|
|
pub mod edge;
|
2023-08-28 14:58:24 -07:00
|
|
|
pub mod extrude;
|
2024-03-05 11:52:45 -08:00
|
|
|
pub mod fillet;
|
2024-03-25 17:07:53 -07:00
|
|
|
pub mod helix;
|
2024-09-04 14:34:33 -07:00
|
|
|
pub mod loft;
|
2023-09-13 15:09:07 -07:00
|
|
|
pub mod math;
|
2024-09-25 16:12:18 -07:00
|
|
|
pub mod mirror;
|
2024-02-11 15:08:54 -08:00
|
|
|
pub mod patterns;
|
2024-09-04 14:34:33 -07:00
|
|
|
pub mod planes;
|
2024-03-26 19:07:16 -07:00
|
|
|
pub mod revolve;
|
2023-08-28 14:58:24 -07:00
|
|
|
pub mod segment;
|
2023-11-09 09:58:20 -06:00
|
|
|
pub mod shapes;
|
2024-06-17 13:10:40 -07:00
|
|
|
pub mod shell;
|
2023-08-28 14:58:24 -07:00
|
|
|
pub mod sketch;
|
2024-12-11 12:59:02 -08:00
|
|
|
pub mod sweep;
|
2025-02-26 16:45:19 -08:00
|
|
|
pub mod transform;
|
2023-08-28 14:58:24 -07:00
|
|
|
pub mod utils;
|
2023-08-24 15:34:51 -07:00
|
|
|
|
2023-08-25 13:41:04 -07:00
|
|
|
use anyhow::Result;
|
2024-07-29 13:18:55 -07:00
|
|
|
pub use args::Args;
|
2023-08-25 13:41:04 -07:00
|
|
|
|
2023-08-24 15:34:51 -07:00
|
|
|
use crate::{
|
2024-07-16 07:45:43 -05:00
|
|
|
errors::KclError,
|
2025-06-26 17:02:54 -05:00
|
|
|
execution::{ExecState, KclValue, types::PrimitiveType},
|
2023-08-24 15:34:51 -07:00
|
|
|
};
|
|
|
|
|
2024-09-16 15:10:33 -04:00
|
|
|
pub type StdFn = fn(
|
|
|
|
&mut ExecState,
|
|
|
|
Args,
|
|
|
|
) -> std::pin::Pin<Box<dyn std::future::Future<Output = Result<KclValue, KclError>> + Send + '_>>;
|
2024-04-12 21:32:57 -07:00
|
|
|
|
2025-02-22 20:16:29 +13:00
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
pub struct StdFnProps {
|
|
|
|
pub name: String,
|
|
|
|
pub deprecated: bool,
|
2025-04-03 22:44:52 +13:00
|
|
|
pub include_in_feature_tree: bool,
|
2025-02-22 20:16:29 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
impl StdFnProps {
|
|
|
|
fn default(name: &str) -> Self {
|
|
|
|
Self {
|
|
|
|
name: name.to_owned(),
|
|
|
|
deprecated: false,
|
2025-04-03 22:44:52 +13:00
|
|
|
include_in_feature_tree: false,
|
2025-02-22 20:16:29 +13:00
|
|
|
}
|
|
|
|
}
|
2025-04-03 22:44:52 +13:00
|
|
|
|
|
|
|
fn include_in_feature_tree(mut self) -> Self {
|
|
|
|
self.include_in_feature_tree = true;
|
|
|
|
self
|
|
|
|
}
|
2025-02-22 20:16:29 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn std_fn(path: &str, fn_name: &str) -> (crate::std::StdFn, StdFnProps) {
|
2025-02-20 19:33:21 +13:00
|
|
|
match (path, fn_name) {
|
2025-02-22 20:16:29 +13:00
|
|
|
("math", "cos") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::cos(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::cos"),
|
2025-02-22 20:16:29 +13:00
|
|
|
),
|
|
|
|
("math", "sin") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::sin(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::sin"),
|
2025-02-22 20:16:29 +13:00
|
|
|
),
|
|
|
|
("math", "tan") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::tan(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::tan"),
|
2025-02-22 20:16:29 +13:00
|
|
|
),
|
2025-04-30 15:59:19 +12:00
|
|
|
("math", "acos") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::acos(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::acos"),
|
2025-04-30 15:59:19 +12:00
|
|
|
),
|
|
|
|
("math", "asin") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::asin(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::asin"),
|
2025-04-30 15:59:19 +12:00
|
|
|
),
|
|
|
|
("math", "atan") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::atan(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::atan"),
|
2025-04-30 15:59:19 +12:00
|
|
|
),
|
|
|
|
("math", "atan2") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::atan2(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::atan2"),
|
2025-04-30 15:59:19 +12:00
|
|
|
),
|
|
|
|
("math", "sqrt") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::sqrt(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::sqrt"),
|
2025-04-30 15:59:19 +12:00
|
|
|
),
|
|
|
|
|
|
|
|
("math", "abs") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::abs(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::abs"),
|
2025-04-30 15:59:19 +12:00
|
|
|
),
|
|
|
|
("math", "rem") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::rem(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::rem"),
|
2025-04-30 15:59:19 +12:00
|
|
|
),
|
|
|
|
("math", "round") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::round(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::round"),
|
2025-04-30 15:59:19 +12:00
|
|
|
),
|
|
|
|
("math", "floor") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::floor(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::floor"),
|
2025-04-30 15:59:19 +12:00
|
|
|
),
|
|
|
|
("math", "ceil") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::ceil(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::ceil"),
|
2025-04-30 15:59:19 +12:00
|
|
|
),
|
|
|
|
("math", "min") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::min(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::min"),
|
2025-04-30 15:59:19 +12:00
|
|
|
),
|
|
|
|
("math", "max") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::max(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::max"),
|
2025-04-30 15:59:19 +12:00
|
|
|
),
|
|
|
|
("math", "pow") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::pow(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::pow"),
|
2025-04-30 15:59:19 +12:00
|
|
|
),
|
|
|
|
("math", "log") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::log(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::log"),
|
2025-04-30 15:59:19 +12:00
|
|
|
),
|
|
|
|
("math", "log2") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::log2(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::log2"),
|
2025-04-30 15:59:19 +12:00
|
|
|
),
|
|
|
|
("math", "log10") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::log10(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::log10"),
|
2025-04-30 15:59:19 +12:00
|
|
|
),
|
|
|
|
("math", "ln") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::ln(e, a)),
|
2025-05-13 08:29:38 +12:00
|
|
|
StdFnProps::default("std::math::ln"),
|
|
|
|
),
|
|
|
|
("math", "legLen") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::leg_length(e, a)),
|
|
|
|
StdFnProps::default("std::math::legLen"),
|
|
|
|
),
|
|
|
|
("math", "legAngX") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::leg_angle_x(e, a)),
|
|
|
|
StdFnProps::default("std::math::legAngX"),
|
|
|
|
),
|
|
|
|
("math", "legAngY") => (
|
|
|
|
|e, a| Box::pin(crate::std::math::leg_angle_y(e, a)),
|
|
|
|
StdFnProps::default("std::math::legAngY"),
|
2025-04-30 15:59:19 +12:00
|
|
|
),
|
2025-04-03 22:44:52 +13:00
|
|
|
("prelude", "helix") => (
|
|
|
|
|e, a| Box::pin(crate::std::helix::helix(e, a)),
|
|
|
|
StdFnProps::default("std::helix").include_in_feature_tree(),
|
|
|
|
),
|
2025-05-06 16:09:59 +12:00
|
|
|
("transform", "mirror2d") => (
|
2025-04-03 22:44:52 +13:00
|
|
|
|e, a| Box::pin(crate::std::mirror::mirror_2d(e, a)),
|
2025-06-05 12:52:53 -04:00
|
|
|
StdFnProps::default("std::transform::mirror2d").include_in_feature_tree(),
|
2025-04-03 22:44:52 +13:00
|
|
|
),
|
2025-05-29 07:15:04 +12:00
|
|
|
("transform", "translate") => (
|
|
|
|
|e, a| Box::pin(crate::std::transform::translate(e, a)),
|
2025-06-02 10:32:36 -04:00
|
|
|
StdFnProps::default("std::transform::translate").include_in_feature_tree(),
|
2025-05-29 07:15:04 +12:00
|
|
|
),
|
|
|
|
("transform", "rotate") => (
|
|
|
|
|e, a| Box::pin(crate::std::transform::rotate(e, a)),
|
2025-06-02 10:32:36 -04:00
|
|
|
StdFnProps::default("std::transform::rotate").include_in_feature_tree(),
|
2025-05-29 07:15:04 +12:00
|
|
|
),
|
|
|
|
("transform", "scale") => (
|
|
|
|
|e, a| Box::pin(crate::std::transform::scale(e, a)),
|
2025-06-02 10:32:36 -04:00
|
|
|
StdFnProps::default("std::transform::scale").include_in_feature_tree(),
|
2025-05-29 07:15:04 +12:00
|
|
|
),
|
2025-04-24 22:01:27 +12:00
|
|
|
("prelude", "offsetPlane") => (
|
|
|
|
|e, a| Box::pin(crate::std::planes::offset_plane(e, a)),
|
|
|
|
StdFnProps::default("std::offsetPlane").include_in_feature_tree(),
|
|
|
|
),
|
2025-05-30 11:00:16 +12:00
|
|
|
("prelude", "assert") => (
|
|
|
|
|e, a| Box::pin(crate::std::assert::assert(e, a)),
|
|
|
|
StdFnProps::default("std::assert"),
|
|
|
|
),
|
|
|
|
("prelude", "assertIs") => (
|
|
|
|
|e, a| Box::pin(crate::std::assert::assert_is(e, a)),
|
|
|
|
StdFnProps::default("std::assertIs"),
|
|
|
|
),
|
2025-04-28 14:20:38 +12:00
|
|
|
("solid", "fillet") => (
|
|
|
|
|e, a| Box::pin(crate::std::fillet::fillet(e, a)),
|
|
|
|
StdFnProps::default("std::solid::fillet").include_in_feature_tree(),
|
|
|
|
),
|
|
|
|
("solid", "chamfer") => (
|
|
|
|
|e, a| Box::pin(crate::std::chamfer::chamfer(e, a)),
|
|
|
|
StdFnProps::default("std::solid::chamfer").include_in_feature_tree(),
|
|
|
|
),
|
|
|
|
("solid", "shell") => (
|
|
|
|
|e, a| Box::pin(crate::std::shell::shell(e, a)),
|
|
|
|
StdFnProps::default("std::solid::shell").include_in_feature_tree(),
|
|
|
|
),
|
|
|
|
("solid", "hollow") => (
|
|
|
|
|e, a| Box::pin(crate::std::shell::hollow(e, a)),
|
|
|
|
StdFnProps::default("std::solid::hollow").include_in_feature_tree(),
|
|
|
|
),
|
2025-05-28 08:37:54 +12:00
|
|
|
("solid", "union") => (
|
|
|
|
|e, a| Box::pin(crate::std::csg::union(e, a)),
|
|
|
|
StdFnProps::default("std::solid::union").include_in_feature_tree(),
|
|
|
|
),
|
|
|
|
("solid", "intersect") => (
|
|
|
|
|e, a| Box::pin(crate::std::csg::intersect(e, a)),
|
|
|
|
StdFnProps::default("std::solid::intersect").include_in_feature_tree(),
|
|
|
|
),
|
|
|
|
("solid", "subtract") => (
|
|
|
|
|e, a| Box::pin(crate::std::csg::subtract(e, a)),
|
|
|
|
StdFnProps::default("std::solid::subtract").include_in_feature_tree(),
|
|
|
|
),
|
|
|
|
("solid", "patternTransform") => (
|
|
|
|
|e, a| Box::pin(crate::std::patterns::pattern_transform(e, a)),
|
|
|
|
StdFnProps::default("std::solid::patternTransform").include_in_feature_tree(),
|
|
|
|
),
|
|
|
|
("solid", "patternLinear3d") => (
|
|
|
|
|e, a| Box::pin(crate::std::patterns::pattern_linear_3d(e, a)),
|
|
|
|
StdFnProps::default("std::solid::patternLinear3d").include_in_feature_tree(),
|
|
|
|
),
|
|
|
|
("solid", "patternCircular3d") => (
|
|
|
|
|e, a| Box::pin(crate::std::patterns::pattern_circular_3d(e, a)),
|
|
|
|
StdFnProps::default("std::solid::patternCircular3d").include_in_feature_tree(),
|
|
|
|
),
|
2025-05-28 11:25:27 +12:00
|
|
|
("solid", "appearance") => (
|
|
|
|
|e, a| Box::pin(crate::std::appearance::appearance(e, a)),
|
|
|
|
StdFnProps::default("std::solid::appearance"),
|
|
|
|
),
|
2025-05-13 08:29:38 +12:00
|
|
|
("array", "map") => (
|
|
|
|
|e, a| Box::pin(crate::std::array::map(e, a)),
|
|
|
|
StdFnProps::default("std::array::map"),
|
|
|
|
),
|
|
|
|
("array", "reduce") => (
|
|
|
|
|e, a| Box::pin(crate::std::array::reduce(e, a)),
|
|
|
|
StdFnProps::default("std::array::reduce"),
|
|
|
|
),
|
|
|
|
("array", "push") => (
|
|
|
|
|e, a| Box::pin(crate::std::array::push(e, a)),
|
|
|
|
StdFnProps::default("std::array::push"),
|
|
|
|
),
|
|
|
|
("array", "pop") => (
|
|
|
|
|e, a| Box::pin(crate::std::array::pop(e, a)),
|
|
|
|
StdFnProps::default("std::array::pop"),
|
|
|
|
),
|
|
|
|
("prelude", "clone") => (
|
|
|
|
|e, a| Box::pin(crate::std::clone::clone(e, a)),
|
|
|
|
StdFnProps::default("std::clone").include_in_feature_tree(),
|
|
|
|
),
|
2025-05-29 10:14:04 +12:00
|
|
|
("sketch", "circle") => (
|
|
|
|
|e, a| Box::pin(crate::std::shapes::circle(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::circle"),
|
|
|
|
),
|
2025-05-30 11:00:16 +12:00
|
|
|
("sketch", "extrude") => (
|
|
|
|
|e, a| Box::pin(crate::std::extrude::extrude(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::extrude").include_in_feature_tree(),
|
|
|
|
),
|
2025-05-20 08:25:29 +12:00
|
|
|
("sketch", "patternTransform2d") => (
|
|
|
|
|e, a| Box::pin(crate::std::patterns::pattern_transform_2d(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::patternTransform2d"),
|
|
|
|
),
|
2025-05-29 10:14:04 +12:00
|
|
|
("sketch", "revolve") => (
|
|
|
|
|e, a| Box::pin(crate::std::revolve::revolve(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::revolve").include_in_feature_tree(),
|
|
|
|
),
|
2025-05-30 11:00:16 +12:00
|
|
|
("sketch", "sweep") => (
|
|
|
|
|e, a| Box::pin(crate::std::sweep::sweep(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::sweep").include_in_feature_tree(),
|
|
|
|
),
|
|
|
|
("sketch", "loft") => (
|
|
|
|
|e, a| Box::pin(crate::std::loft::loft(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::loft").include_in_feature_tree(),
|
|
|
|
),
|
|
|
|
("sketch", "polygon") => (
|
|
|
|
|e, a| Box::pin(crate::std::shapes::polygon(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::polygon"),
|
|
|
|
),
|
|
|
|
("sketch", "circleThreePoint") => (
|
|
|
|
|e, a| Box::pin(crate::std::shapes::circle_three_point(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::circleThreePoint"),
|
|
|
|
),
|
2025-05-29 10:14:04 +12:00
|
|
|
("sketch", "getCommonEdge") => (
|
|
|
|
|e, a| Box::pin(crate::std::edge::get_common_edge(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::getCommonEdge"),
|
|
|
|
),
|
|
|
|
("sketch", "getNextAdjacentEdge") => (
|
|
|
|
|e, a| Box::pin(crate::std::edge::get_next_adjacent_edge(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::getNextAdjacentEdge"),
|
|
|
|
),
|
|
|
|
("sketch", "getOppositeEdge") => (
|
|
|
|
|e, a| Box::pin(crate::std::edge::get_opposite_edge(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::revolve"),
|
|
|
|
),
|
|
|
|
("sketch", "getPreviousAdjacentEdge") => (
|
|
|
|
|e, a| Box::pin(crate::std::edge::get_previous_adjacent_edge(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::getPreviousAdjacentEdge"),
|
|
|
|
),
|
2025-05-30 11:00:16 +12:00
|
|
|
("sketch", "patternLinear2d") => (
|
|
|
|
|e, a| Box::pin(crate::std::patterns::pattern_linear_2d(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::patternLinear2d"),
|
|
|
|
),
|
|
|
|
("sketch", "patternCircular2d") => (
|
|
|
|
|e, a| Box::pin(crate::std::patterns::pattern_circular_2d(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::patternCircular2d"),
|
|
|
|
),
|
2025-06-03 15:15:51 +12:00
|
|
|
("sketch", "segEnd") => (
|
|
|
|
|e, a| Box::pin(crate::std::segment::segment_end(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::segEnd"),
|
|
|
|
),
|
|
|
|
("sketch", "segEndX") => (
|
|
|
|
|e, a| Box::pin(crate::std::segment::segment_end_x(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::segEndX"),
|
|
|
|
),
|
|
|
|
("sketch", "segEndY") => (
|
|
|
|
|e, a| Box::pin(crate::std::segment::segment_end_y(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::segEndY"),
|
|
|
|
),
|
|
|
|
("sketch", "segStart") => (
|
|
|
|
|e, a| Box::pin(crate::std::segment::segment_start(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::segStart"),
|
|
|
|
),
|
|
|
|
("sketch", "segStartX") => (
|
|
|
|
|e, a| Box::pin(crate::std::segment::segment_start_x(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::segStartX"),
|
|
|
|
),
|
|
|
|
("sketch", "segStartY") => (
|
|
|
|
|e, a| Box::pin(crate::std::segment::segment_start_y(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::segStartY"),
|
|
|
|
),
|
|
|
|
("sketch", "lastSegX") => (
|
|
|
|
|e, a| Box::pin(crate::std::segment::last_segment_x(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::lastSegX"),
|
|
|
|
),
|
|
|
|
("sketch", "lastSegY") => (
|
|
|
|
|e, a| Box::pin(crate::std::segment::last_segment_y(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::lastSegY"),
|
|
|
|
),
|
|
|
|
("sketch", "segLen") => (
|
|
|
|
|e, a| Box::pin(crate::std::segment::segment_length(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::segLen"),
|
|
|
|
),
|
|
|
|
("sketch", "segAng") => (
|
|
|
|
|e, a| Box::pin(crate::std::segment::segment_angle(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::segAng"),
|
|
|
|
),
|
|
|
|
("sketch", "tangentToEnd") => (
|
|
|
|
|e, a| Box::pin(crate::std::segment::tangent_to_end(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::tangentToEnd"),
|
|
|
|
),
|
2025-06-05 07:41:01 +12:00
|
|
|
("sketch", "profileStart") => (
|
|
|
|
|e, a| Box::pin(crate::std::sketch::profile_start(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::profileStart"),
|
|
|
|
),
|
|
|
|
("sketch", "profileStartX") => (
|
|
|
|
|e, a| Box::pin(crate::std::sketch::profile_start_x(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::profileStartX"),
|
|
|
|
),
|
|
|
|
("sketch", "profileStartY") => (
|
|
|
|
|e, a| Box::pin(crate::std::sketch::profile_start_y(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::profileStartY"),
|
|
|
|
),
|
|
|
|
("sketch", "startSketchOn") => (
|
|
|
|
|e, a| Box::pin(crate::std::sketch::start_sketch_on(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::startSketchOn").include_in_feature_tree(),
|
|
|
|
),
|
|
|
|
("sketch", "startProfile") => (
|
|
|
|
|e, a| Box::pin(crate::std::sketch::start_profile(e, a)),
|
|
|
|
StdFnProps::default("std::sketch::startProfile"),
|
|
|
|
),
|
|
|
|
("sketch", "involuteCircular") => (
|
|
|
|
|e, a| Box::pin(crate::std::sketch::involute_circular(e, a)),
|
2025-06-06 10:05:38 +12:00
|
|
|
StdFnProps::default("std::sketch::involuteCircular"),
|
2025-06-05 07:41:01 +12:00
|
|
|
),
|
|
|
|
("sketch", "line") => (
|
|
|
|
|e, a| Box::pin(crate::std::sketch::line(e, a)),
|
2025-06-06 10:05:38 +12:00
|
|
|
StdFnProps::default("std::sketch::line"),
|
2025-06-05 07:41:01 +12:00
|
|
|
),
|
|
|
|
("sketch", "xLine") => (
|
|
|
|
|e, a| Box::pin(crate::std::sketch::x_line(e, a)),
|
2025-06-06 10:05:38 +12:00
|
|
|
StdFnProps::default("std::sketch::xLine"),
|
2025-06-05 07:41:01 +12:00
|
|
|
),
|
|
|
|
("sketch", "yLine") => (
|
|
|
|
|e, a| Box::pin(crate::std::sketch::y_line(e, a)),
|
2025-06-06 10:05:38 +12:00
|
|
|
StdFnProps::default("std::sketch::yLine"),
|
2025-06-05 07:41:01 +12:00
|
|
|
),
|
|
|
|
("sketch", "angledLine") => (
|
|
|
|
|e, a| Box::pin(crate::std::sketch::angled_line(e, a)),
|
2025-06-06 10:05:38 +12:00
|
|
|
StdFnProps::default("std::sketch::angledLine"),
|
2025-06-05 07:41:01 +12:00
|
|
|
),
|
|
|
|
("sketch", "angledLineThatIntersects") => (
|
|
|
|
|e, a| Box::pin(crate::std::sketch::angled_line_that_intersects(e, a)),
|
2025-06-06 10:05:38 +12:00
|
|
|
StdFnProps::default("std::sketch::angledLineThatIntersects"),
|
2025-06-05 07:41:01 +12:00
|
|
|
),
|
|
|
|
("sketch", "close") => (
|
|
|
|
|e, a| Box::pin(crate::std::sketch::close(e, a)),
|
2025-06-06 10:05:38 +12:00
|
|
|
StdFnProps::default("std::sketch::close"),
|
2025-06-05 07:41:01 +12:00
|
|
|
),
|
|
|
|
("sketch", "arc") => (
|
|
|
|
|e, a| Box::pin(crate::std::sketch::arc(e, a)),
|
2025-06-06 10:05:38 +12:00
|
|
|
StdFnProps::default("std::sketch::arc"),
|
2025-06-05 07:41:01 +12:00
|
|
|
),
|
|
|
|
("sketch", "tangentialArc") => (
|
|
|
|
|e, a| Box::pin(crate::std::sketch::tangential_arc(e, a)),
|
2025-06-06 10:05:38 +12:00
|
|
|
StdFnProps::default("std::sketch::tangentialArc"),
|
2025-06-05 07:41:01 +12:00
|
|
|
),
|
|
|
|
("sketch", "bezierCurve") => (
|
|
|
|
|e, a| Box::pin(crate::std::sketch::bezier_curve(e, a)),
|
2025-06-06 10:05:38 +12:00
|
|
|
StdFnProps::default("std::sketch::bezierCurve"),
|
2025-06-05 07:41:01 +12:00
|
|
|
),
|
|
|
|
("sketch", "subtract2d") => (
|
|
|
|
|e, a| Box::pin(crate::std::sketch::subtract_2d(e, a)),
|
2025-06-06 10:05:38 +12:00
|
|
|
StdFnProps::default("std::sketch::subtract2d").include_in_feature_tree(),
|
2025-06-05 07:41:01 +12:00
|
|
|
),
|
2025-05-23 13:53:58 -05:00
|
|
|
("appearance", "hexString") => (
|
|
|
|
|e, a| Box::pin(crate::std::appearance::hex_string(e, a)),
|
|
|
|
StdFnProps::default("std::appearance::hexString"),
|
|
|
|
),
|
|
|
|
(module, fn_name) => {
|
|
|
|
panic!("No implementation found for {module}::{fn_name}, please add it to this big match statement")
|
|
|
|
}
|
2025-02-20 19:33:21 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-03-21 10:56:55 +13:00
|
|
|
pub(crate) fn std_ty(path: &str, fn_name: &str) -> (PrimitiveType, StdFnProps) {
|
2025-03-08 03:53:34 +13:00
|
|
|
match (path, fn_name) {
|
2025-04-22 11:00:53 +12:00
|
|
|
("types", "Sketch") => (PrimitiveType::Sketch, StdFnProps::default("std::types::Sketch")),
|
|
|
|
("types", "Solid") => (PrimitiveType::Solid, StdFnProps::default("std::types::Solid")),
|
|
|
|
("types", "Plane") => (PrimitiveType::Plane, StdFnProps::default("std::types::Plane")),
|
|
|
|
("types", "Face") => (PrimitiveType::Face, StdFnProps::default("std::types::Face")),
|
|
|
|
("types", "Helix") => (PrimitiveType::Helix, StdFnProps::default("std::types::Helix")),
|
|
|
|
("types", "Edge") => (PrimitiveType::Edge, StdFnProps::default("std::types::Edge")),
|
|
|
|
("types", "Axis2d") => (PrimitiveType::Axis2d, StdFnProps::default("std::types::Axis2d")),
|
|
|
|
("types", "Axis3d") => (PrimitiveType::Axis3d, StdFnProps::default("std::types::Axis3d")),
|
2025-06-16 09:10:36 +12:00
|
|
|
("types", "TaggedEdge") => (PrimitiveType::TaggedEdge, StdFnProps::default("std::types::TaggedEdge")),
|
|
|
|
("types", "TaggedFace") => (PrimitiveType::TaggedFace, StdFnProps::default("std::types::TaggedFace")),
|
2025-03-08 03:53:34 +13:00
|
|
|
_ => unreachable!(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-06-20 11:42:14 -04:00
|
|
|
/// The default tolerance for modeling commands in millimeters.
|
|
|
|
const DEFAULT_TOLERANCE_MM: f64 = 0.0000001;
|