BREAKING: Change polygon to keyword args (#6385)

* Change polygon to keyword args

* Update docs

* Update generated output

* Update docs to mention the default for inscribed

* Appease clippy

* Remove tag parameter

* Update docs since removing tag

* Remove inscribed from autocomplete snippet since the default is true
This commit is contained in:
Jonathan Tran
2025-04-21 14:29:32 -04:00
committed by GitHub
parent 7a90d029e1
commit f8ca6ad746
17 changed files with 5386 additions and 698 deletions

View File

@ -205,12 +205,12 @@ fn transform(i) {
}
startSketchOn(XY)
|> startProfileAt([0, 0], %)
|> polygon({
|> polygon(
radius = 10,
numSides = 4,
center = [0, 0],
inscribed = false
}, %)
inscribed = false,
)
|> extrude(length = 4)
|> patternTransform(instances = 3, transform = transform)
```

View File

@ -10,9 +10,11 @@ Create a regular polygon with the specified number of sides that is either inscr
```js
polygon(
data: PolygonData,
sketchSurfaceOrGroup: SketchOrSurface,
tag?: TagDeclarator,
radius: number,
numSides: u64,
center: [number],
inscribed?: bool,
): Sketch
```
@ -21,9 +23,11 @@ polygon(
| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `data` | [`PolygonData`](/docs/kcl/types/PolygonData) | Data for drawing a polygon | Yes |
| `sketchSurfaceOrGroup` | [`SketchOrSurface`](/docs/kcl/types/SketchOrSurface) | A sketch surface or a sketch. | Yes |
| [`tag`](/docs/kcl/types/tag) | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
| `sketchSurfaceOrGroup` | [`SketchOrSurface`](/docs/kcl/types/SketchOrSurface) | Plane or surface to sketch on | Yes |
| `radius` | [`number`](/docs/kcl/types/number) | The radius of the polygon | Yes |
| `numSides` | `u64` | The number of sides in the polygon | Yes |
| `center` | [`[number]`](/docs/kcl/types/number) | The center point of the polygon | Yes |
| `inscribed` | [`bool`](/docs/kcl/types/bool) | Whether the polygon is inscribed (true, the default) or circumscribed (false) about a circle with the specified radius | No |
### Returns
@ -35,12 +39,12 @@ polygon(
```js
// Create a regular hexagon inscribed in a circle of radius 10
hex = startSketchOn(XY)
|> polygon({
|> polygon(
radius = 10,
numSides = 6,
center = [0, 0],
inscribed = true
}, %)
inscribed = true,
)
example = extrude(hex, length = 5)
```
@ -50,12 +54,12 @@ example = extrude(hex, length = 5)
```js
// Create a square circumscribed around a circle of radius 5
square = startSketchOn(XY)
|> polygon({
|> polygon(
radius = 5.0,
numSides = 4,
center = [10, 10],
inscribed = false
}, %)
inscribed = false,
)
example = extrude(square, length = 5)
```

File diff suppressed because it is too large Load Diff

View File

@ -46,12 +46,12 @@ export fn divider(plane) {
fn connectorSketch(plane, start) {
sketch001 = startSketchOn(plane)
|> startProfileAt(start, %)
|> polygon({
|> polygon(
radius = 1.2,
numSides = 6,
center = profileStart(%),
inscribed = false
}, %)
inscribed = false,
)
return sketch001
}

View File

@ -38,20 +38,20 @@ plane = {
// Create a regular pentagon inscribed in a circle of radius pentR
bottomFace = startSketchOn(XY)
|> polygon({
|> polygon(
radius = pentR,
numSides = 5,
center = [0, 0],
inscribed = true
}, %)
inscribed = true,
)
bottomSideFace = startSketchOn(plane)
|> polygon({
|> polygon(
radius = pentR,
numSides = 5,
center = [0, 0],
inscribed = true
}, %)
inscribed = true,
)
// Extrude the faces in each plane
bottom = extrude(bottomFace, length = wallThickness)

View File

@ -66,6 +66,10 @@ impl RuntimeType {
RuntimeType::Primitive(PrimitiveType::Plane)
}
pub fn bool() -> Self {
RuntimeType::Primitive(PrimitiveType::Boolean)
}
pub fn string() -> Self {
RuntimeType::Primitive(PrimitiveType::String)
}

View File

@ -775,19 +775,6 @@ impl Args {
source_ranges: vec![self.source_range],
}))
}
pub(crate) fn get_polygon_args(
&self,
) -> Result<
(
crate::std::shapes::PolygonData,
crate::std::shapes::SketchOrSurface,
Option<TagNode>,
),
KclError,
> {
FromArgs::from_args(self, 0)
}
}
/// Types which impl this trait can be read out of the `Args` passed into a KCL function.
@ -963,28 +950,6 @@ macro_rules! let_field_of {
};
}
impl<'a> FromKclValue<'a> for super::shapes::PolygonData {
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
let obj = arg.as_object()?;
let_field_of!(obj, radius);
let_field_of!(obj, num_sides "numSides");
let_field_of!(obj, center);
let_field_of!(obj, inscribed);
let polygon_type = if inscribed {
PolygonType::Inscribed
} else {
PolygonType::Circumscribed
};
Some(Self {
radius,
num_sides,
center,
polygon_type,
inscribed,
})
}
}
impl<'a> FromKclValue<'a> for crate::execution::Plane {
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
arg.as_plane().cloned()

View File

@ -245,12 +245,12 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
/// }
/// startSketchOn('XY')
/// |> startProfileAt([0, 0], %)
/// |> polygon({
/// radius: 10,
/// numSides: 4,
/// center: [0, 0],
/// inscribed: false
/// }, %)
/// |> polygon(
/// radius = 10,
/// numSides = 4,
/// center = [0, 0],
/// inscribed = false,
/// )
/// |> extrude(length = 4)
/// |> patternTransform(instances = 3, transform = transform)
/// ```

View File

@ -13,6 +13,7 @@ use kittycad_modeling_cmds::shared::PathSegment;
use schemars::JsonSchema;
use serde::Serialize;
use super::{args::TyF64, utils::untype_point};
use crate::{
errors::{KclError, KclErrorDetails},
execution::{types::RuntimeType, BasePath, ExecState, GeoMeta, KclValue, Path, Sketch, SketchSurface},
@ -24,8 +25,6 @@ use crate::{
},
};
use super::{args::TyF64, utils::untype_point};
/// A sketch surface or a sketch.
#[derive(Debug, Clone, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
#[ts(export)]
@ -259,35 +258,24 @@ pub enum PolygonType {
Circumscribed,
}
/// Data for drawing a polygon
#[derive(Debug, Clone, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct PolygonData {
/// The radius of the polygon
pub radius: TyF64,
/// The number of sides in the polygon
pub num_sides: u64,
/// The center point of the polygon
pub center: [TyF64; 2],
/// The type of the polygon (inscribed or circumscribed)
#[serde(skip)]
pub polygon_type: PolygonType,
/// Whether the polygon is inscribed (true) or circumscribed (false) about a circle with the specified radius
#[serde(default = "default_inscribed")]
pub inscribed: bool,
}
fn default_inscribed() -> bool {
true
}
/// Create a regular polygon with the specified number of sides and radius.
pub async fn polygon(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let (data, sketch_surface_or_group, tag): (PolygonData, SketchOrSurface, Option<TagNode>) =
args.get_polygon_args()?;
let sketch_surface_or_group = args.get_unlabeled_kw_arg("sketchOrSurface")?;
let radius: TyF64 = args.get_kw_arg_typed("radius", &RuntimeType::length(), exec_state)?;
let num_sides: TyF64 = args.get_kw_arg_typed("numSides", &RuntimeType::count(), exec_state)?;
let center = args.get_kw_arg_typed("center", &RuntimeType::point2d(), exec_state)?;
let inscribed = args.get_kw_arg_opt_typed("inscribed", &RuntimeType::bool(), exec_state)?;
let sketch = inner_polygon(data, sketch_surface_or_group, tag, exec_state, args).await?;
let sketch = inner_polygon(
sketch_surface_or_group,
radius,
num_sides.n as u64,
untype_point(center).0,
inscribed,
exec_state,
args,
)
.await?;
Ok(KclValue::Sketch {
value: Box::new(sketch),
})
@ -298,12 +286,12 @@ pub async fn polygon(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// ```no_run
/// // Create a regular hexagon inscribed in a circle of radius 10
/// hex = startSketchOn('XY')
/// |> polygon({
/// |> polygon(
/// radius = 10,
/// numSides = 6,
/// center = [0, 0],
/// inscribed = true,
/// }, %)
/// )
///
/// example = extrude(hex, length = 5)
/// ```
@ -311,32 +299,44 @@ pub async fn polygon(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// ```no_run
/// // Create a square circumscribed around a circle of radius 5
/// square = startSketchOn('XY')
/// |> polygon({
/// |> polygon(
/// radius = 5.0,
/// numSides = 4,
/// center = [10, 10],
/// inscribed = false,
/// }, %)
/// )
/// example = extrude(square, length = 5)
/// ```
#[stdlib {
name = "polygon",
keywords = true,
unlabeled_first = true,
args = {
sketch_surface_or_group = { docs = "Plane or surface to sketch on" },
radius = { docs = "The radius of the polygon", include_in_snippet = true },
num_sides = { docs = "The number of sides in the polygon", include_in_snippet = true },
center = { docs = "The center point of the polygon", include_in_snippet = true },
inscribed = { docs = "Whether the polygon is inscribed (true, the default) or circumscribed (false) about a circle with the specified radius" },
}
}]
#[allow(clippy::too_many_arguments)]
async fn inner_polygon(
data: PolygonData,
sketch_surface_or_group: SketchOrSurface,
tag: Option<TagNode>,
radius: TyF64,
num_sides: u64,
center: [f64; 2],
inscribed: Option<bool>,
exec_state: &mut ExecState,
args: Args,
) -> Result<Sketch, KclError> {
if data.num_sides < 3 {
if num_sides < 3 {
return Err(KclError::Type(KclErrorDetails {
message: "Polygon must have at least 3 sides".to_string(),
source_ranges: vec![args.source_range],
}));
}
if data.radius.n <= 0.0 {
if radius.n <= 0.0 {
return Err(KclError::Type(KclErrorDetails {
message: "Radius must be greater than 0".to_string(),
source_ranges: vec![args.source_range],
@ -348,21 +348,24 @@ async fn inner_polygon(
SketchOrSurface::Sketch(group) => group.on,
};
let half_angle = std::f64::consts::PI / data.num_sides as f64;
let half_angle = std::f64::consts::PI / num_sides as f64;
let radius_to_vertices = match data.polygon_type {
PolygonType::Inscribed => data.radius.n,
PolygonType::Circumscribed => data.radius.n / half_angle.cos(),
let radius_to_vertices = if inscribed.unwrap_or(true) {
// inscribed
radius.n
} else {
// circumscribed
radius.n / half_angle.cos()
};
let angle_step = 2.0 * std::f64::consts::PI / data.num_sides as f64;
let angle_step = std::f64::consts::TAU / num_sides as f64;
let vertices: Vec<[f64; 2]> = (0..data.num_sides)
let vertices: Vec<[f64; 2]> = (0..num_sides)
.map(|i| {
let angle = angle_step * i as f64;
[
data.center[0].n + radius_to_vertices * angle.cos(),
data.center[1].n + radius_to_vertices * angle.sin(),
center[0] + radius_to_vertices * angle.cos(),
center[1] + radius_to_vertices * angle.sin(),
]
})
.collect();
@ -391,7 +394,7 @@ async fn inner_polygon(
base: BasePath {
from: from.into(),
to: *vertex,
tag: tag.clone(),
tag: None,
units: sketch.units,
geo_meta: GeoMeta {
id,
@ -400,10 +403,6 @@ async fn inner_polygon(
},
};
if let Some(tag) = &tag {
sketch.add_tag(tag, &current_path, exec_state);
}
sketch.paths.push(current_path);
}
@ -427,7 +426,7 @@ async fn inner_polygon(
base: BasePath {
from: from.into(),
to: vertices[0],
tag: tag.clone(),
tag: None,
units: sketch.units,
geo_meta: GeoMeta {
id: close_id,
@ -436,10 +435,6 @@ async fn inner_polygon(
},
};
if let Some(tag) = &tag {
sketch.add_tag(tag, &current_path, exec_state);
}
sketch.paths.push(current_path);
args.batch_modeling_cmd(

View File

@ -154,82 +154,82 @@ flowchart LR
522["Path<br>[1762, 1786, 5]"]
end
subgraph path523 [Path]
523["Path<br>[1794, 1924, 5]"]
524["Segment<br>[1794, 1924, 5]"]
525["Segment<br>[1794, 1924, 5]"]
526["Segment<br>[1794, 1924, 5]"]
527["Segment<br>[1794, 1924, 5]"]
528["Segment<br>[1794, 1924, 5]"]
529["Segment<br>[1794, 1924, 5]"]
530["Segment<br>[1794, 1924, 5]"]
523["Path<br>[1794, 1920, 5]"]
524["Segment<br>[1794, 1920, 5]"]
525["Segment<br>[1794, 1920, 5]"]
526["Segment<br>[1794, 1920, 5]"]
527["Segment<br>[1794, 1920, 5]"]
528["Segment<br>[1794, 1920, 5]"]
529["Segment<br>[1794, 1920, 5]"]
530["Segment<br>[1794, 1920, 5]"]
531[Solid2d]
end
subgraph path553 [Path]
553["Path<br>[1762, 1786, 5]"]
end
subgraph path554 [Path]
554["Path<br>[1794, 1924, 5]"]
555["Segment<br>[1794, 1924, 5]"]
556["Segment<br>[1794, 1924, 5]"]
557["Segment<br>[1794, 1924, 5]"]
558["Segment<br>[1794, 1924, 5]"]
559["Segment<br>[1794, 1924, 5]"]
560["Segment<br>[1794, 1924, 5]"]
561["Segment<br>[1794, 1924, 5]"]
554["Path<br>[1794, 1920, 5]"]
555["Segment<br>[1794, 1920, 5]"]
556["Segment<br>[1794, 1920, 5]"]
557["Segment<br>[1794, 1920, 5]"]
558["Segment<br>[1794, 1920, 5]"]
559["Segment<br>[1794, 1920, 5]"]
560["Segment<br>[1794, 1920, 5]"]
561["Segment<br>[1794, 1920, 5]"]
562[Solid2d]
end
subgraph path585 [Path]
585["Path<br>[2200, 2227, 5]"]
586["Segment<br>[2235, 2257, 5]"]
587["Segment<br>[2265, 2287, 5]"]
588["Segment<br>[2295, 2317, 5]"]
589["Segment<br>[2325, 2348, 5]"]
590["Segment<br>[2356, 2379, 5]"]
591["Segment<br>[2387, 2422, 5]"]
592["Segment<br>[2430, 2437, 5]"]
585["Path<br>[2196, 2223, 5]"]
586["Segment<br>[2231, 2253, 5]"]
587["Segment<br>[2261, 2283, 5]"]
588["Segment<br>[2291, 2313, 5]"]
589["Segment<br>[2321, 2344, 5]"]
590["Segment<br>[2352, 2375, 5]"]
591["Segment<br>[2383, 2418, 5]"]
592["Segment<br>[2426, 2433, 5]"]
593[Solid2d]
end
subgraph path618 [Path]
618["Path<br>[2709, 2738, 5]"]
619["Segment<br>[2746, 2781, 5]"]
620["Segment<br>[2789, 2814, 5]"]
621["Segment<br>[2822, 2858, 5]"]
622["Segment<br>[2866, 2890, 5]"]
623["Segment<br>[2898, 2932, 5]"]
624["Segment<br>[2940, 2975, 5]"]
625["Segment<br>[2983, 2990, 5]"]
618["Path<br>[2705, 2734, 5]"]
619["Segment<br>[2742, 2777, 5]"]
620["Segment<br>[2785, 2810, 5]"]
621["Segment<br>[2818, 2854, 5]"]
622["Segment<br>[2862, 2886, 5]"]
623["Segment<br>[2894, 2928, 5]"]
624["Segment<br>[2936, 2971, 5]"]
625["Segment<br>[2979, 2986, 5]"]
626[Solid2d]
end
subgraph path650 [Path]
650["Path<br>[3265, 3292, 5]"]
651["Segment<br>[3300, 3319, 5]"]
652["Segment<br>[3327, 3376, 5]"]
650["Path<br>[3261, 3288, 5]"]
651["Segment<br>[3296, 3315, 5]"]
652["Segment<br>[3323, 3372, 5]"]
end
subgraph path654 [Path]
654["Path<br>[3476, 3509, 5]"]
655["Segment<br>[3517, 3536, 5]"]
656["Segment<br>[3544, 3566, 5]"]
657["Segment<br>[3574, 3597, 5]"]
658["Segment<br>[3605, 3625, 5]"]
659["Segment<br>[3633, 3657, 5]"]
660["Segment<br>[3665, 3688, 5]"]
661["Segment<br>[3696, 3703, 5]"]
654["Path<br>[3472, 3505, 5]"]
655["Segment<br>[3513, 3532, 5]"]
656["Segment<br>[3540, 3562, 5]"]
657["Segment<br>[3570, 3593, 5]"]
658["Segment<br>[3601, 3621, 5]"]
659["Segment<br>[3629, 3653, 5]"]
660["Segment<br>[3661, 3684, 5]"]
661["Segment<br>[3692, 3699, 5]"]
662[Solid2d]
end
subgraph path688 [Path]
688["Path<br>[3265, 3292, 5]"]
689["Segment<br>[3300, 3319, 5]"]
690["Segment<br>[3327, 3376, 5]"]
688["Path<br>[3261, 3288, 5]"]
689["Segment<br>[3296, 3315, 5]"]
690["Segment<br>[3323, 3372, 5]"]
end
subgraph path692 [Path]
692["Path<br>[3476, 3509, 5]"]
693["Segment<br>[3517, 3536, 5]"]
694["Segment<br>[3544, 3566, 5]"]
695["Segment<br>[3574, 3597, 5]"]
696["Segment<br>[3605, 3625, 5]"]
697["Segment<br>[3633, 3657, 5]"]
698["Segment<br>[3665, 3688, 5]"]
699["Segment<br>[3696, 3703, 5]"]
692["Path<br>[3472, 3505, 5]"]
693["Segment<br>[3513, 3532, 5]"]
694["Segment<br>[3540, 3562, 5]"]
695["Segment<br>[3570, 3593, 5]"]
696["Segment<br>[3601, 3621, 5]"]
697["Segment<br>[3629, 3653, 5]"]
698["Segment<br>[3661, 3684, 5]"]
699["Segment<br>[3692, 3699, 5]"]
700[Solid2d]
end
1["Plane<br>[333, 353, 5]"]
@ -615,7 +615,7 @@ flowchart LR
519["SweepEdge Opposite"]
520["SweepEdge Adjacent"]
521["Plane<br>[975, 1017, 0]"]
532["Sweep Extrusion<br>[2026, 2050, 5]"]
532["Sweep Extrusion<br>[2022, 2046, 5]"]
533[Wall]
534[Wall]
535[Wall]
@ -636,7 +636,7 @@ flowchart LR
550["SweepEdge Adjacent"]
551["SweepEdge Opposite"]
552["SweepEdge Adjacent"]
563["Sweep Extrusion<br>[2092, 2116, 5]"]
563["Sweep Extrusion<br>[2088, 2112, 5]"]
564[Wall]
565[Wall]
566[Wall]
@ -658,7 +658,7 @@ flowchart LR
582["SweepEdge Opposite"]
583["SweepEdge Adjacent"]
584["Plane<br>[1068, 1135, 0]"]
594["Sweep Extrusion<br>[2600, 2624, 5]"]
594["Sweep Extrusion<br>[2596, 2620, 5]"]
595[Wall]
596[Wall]
597[Wall]
@ -679,10 +679,10 @@ flowchart LR
612["SweepEdge Adjacent"]
613["SweepEdge Opposite"]
614["SweepEdge Adjacent"]
615["Sweep Extrusion<br>[2600, 2624, 5]"]
616["Sweep Extrusion<br>[2600, 2624, 5]"]
615["Sweep Extrusion<br>[2596, 2620, 5]"]
616["Sweep Extrusion<br>[2596, 2620, 5]"]
617["Plane<br>[1205, 1272, 0]"]
627["Sweep Extrusion<br>[3160, 3184, 5]"]
627["Sweep Extrusion<br>[3156, 3180, 5]"]
628[Wall]
629[Wall]
630[Wall]
@ -703,10 +703,10 @@ flowchart LR
645["SweepEdge Adjacent"]
646["SweepEdge Opposite"]
647["SweepEdge Adjacent"]
648["Sweep Extrusion<br>[3160, 3184, 5]"]
649["Plane<br>[3784, 3819, 5]"]
653["Plane<br>[3850, 3879, 5]"]
663["Sweep Sweep<br>[3891, 3918, 5]"]
648["Sweep Extrusion<br>[3156, 3180, 5]"]
649["Plane<br>[3780, 3815, 5]"]
653["Plane<br>[3846, 3875, 5]"]
663["Sweep Sweep<br>[3887, 3914, 5]"]
664[Wall]
665[Wall]
666[Wall]
@ -730,9 +730,9 @@ flowchart LR
684["SweepEdge Adjacent"]
685["SweepEdge Opposite"]
686["SweepEdge Adjacent"]
687["Plane<br>[3784, 3819, 5]"]
691["Plane<br>[3850, 3879, 5]"]
701["Sweep Sweep<br>[3891, 3918, 5]"]
687["Plane<br>[3780, 3815, 5]"]
691["Plane<br>[3846, 3875, 5]"]
701["Sweep Sweep<br>[3887, 3914, 5]"]
702[Wall]
703[Wall]
704[Wall]
@ -762,12 +762,12 @@ flowchart LR
728["StartSketchOnPlane<br>[333, 353, 5]"]
729["StartSketchOnPlane<br>[1734, 1754, 5]"]
730["StartSketchOnPlane<br>[1734, 1754, 5]"]
731["StartSketchOnPlane<br>[2172, 2192, 5]"]
732["StartSketchOnPlane<br>[2681, 2701, 5]"]
733["StartSketchOnPlane<br>[3237, 3257, 5]"]
734["StartSketchOnPlane<br>[3448, 3468, 5]"]
735["StartSketchOnPlane<br>[3237, 3257, 5]"]
736["StartSketchOnPlane<br>[3448, 3468, 5]"]
731["StartSketchOnPlane<br>[2168, 2188, 5]"]
732["StartSketchOnPlane<br>[2677, 2697, 5]"]
733["StartSketchOnPlane<br>[3233, 3253, 5]"]
734["StartSketchOnPlane<br>[3444, 3464, 5]"]
735["StartSketchOnPlane<br>[3233, 3253, 5]"]
736["StartSketchOnPlane<br>[3444, 3464, 5]"]
1 --- 2
2 --- 3
2 --- 4

View File

@ -807,8 +807,8 @@ description: Operations executed bench.kcl
"type": "FunctionCall",
"name": "connector",
"functionSourceRange": [
1966,
2129,
1962,
2125,
5
],
"unlabeledArg": null,
@ -823,7 +823,7 @@ description: Operations executed bench.kcl
"name": "connectorSketch",
"functionSourceRange": [
1703,
1945,
1941,
5
],
"unlabeledArg": null,
@ -888,7 +888,7 @@ description: Operations executed bench.kcl
"name": "connectorSketch",
"functionSourceRange": [
1703,
1945,
1941,
5
],
"unlabeledArg": null,
@ -985,8 +985,8 @@ description: Operations executed bench.kcl
"type": "FunctionCall",
"name": "seatSlats",
"functionSourceRange": [
2551,
2637,
2547,
2633,
5
],
"unlabeledArg": null,
@ -1000,8 +1000,8 @@ description: Operations executed bench.kcl
"type": "FunctionCall",
"name": "seatSlatSketch",
"functionSourceRange": [
2148,
2530,
2144,
2526,
5
],
"unlabeledArg": null,
@ -1115,8 +1115,8 @@ description: Operations executed bench.kcl
"type": "FunctionCall",
"name": "backSlats",
"functionSourceRange": [
3106,
3197,
3102,
3193,
5
],
"unlabeledArg": null,
@ -1130,8 +1130,8 @@ description: Operations executed bench.kcl
"type": "FunctionCall",
"name": "backSlatsSketch",
"functionSourceRange": [
2657,
3085,
2653,
3081,
5
],
"unlabeledArg": null,
@ -1209,8 +1209,8 @@ description: Operations executed bench.kcl
"type": "FunctionCall",
"name": "armRest",
"functionSourceRange": [
3743,
3931,
3739,
3927,
5
],
"unlabeledArg": null,
@ -1254,8 +1254,8 @@ description: Operations executed bench.kcl
"type": "FunctionCall",
"name": "armRestPath",
"functionSourceRange": [
3213,
3397,
3209,
3393,
5
],
"unlabeledArg": null,
@ -1317,8 +1317,8 @@ description: Operations executed bench.kcl
"type": "FunctionCall",
"name": "armRestProfile",
"functionSourceRange": [
3416,
3724,
3412,
3720,
5
],
"unlabeledArg": null,
@ -1378,8 +1378,8 @@ description: Operations executed bench.kcl
"type": "FunctionCall",
"name": "armRest",
"functionSourceRange": [
3743,
3931,
3739,
3927,
5
],
"unlabeledArg": null,
@ -1423,8 +1423,8 @@ description: Operations executed bench.kcl
"type": "FunctionCall",
"name": "armRestPath",
"functionSourceRange": [
3213,
3397,
3209,
3393,
5
],
"unlabeledArg": null,
@ -1486,8 +1486,8 @@ description: Operations executed bench.kcl
"type": "FunctionCall",
"name": "armRestProfile",
"functionSourceRange": [
3416,
3724,
3412,
3720,
5
],
"unlabeledArg": null,

View File

@ -1,28 +1,28 @@
```mermaid
flowchart LR
subgraph path2 [Path]
2["Path<br>[1130, 1242, 0]"]
3["Segment<br>[1130, 1242, 0]"]
4["Segment<br>[1130, 1242, 0]"]
5["Segment<br>[1130, 1242, 0]"]
6["Segment<br>[1130, 1242, 0]"]
7["Segment<br>[1130, 1242, 0]"]
8["Segment<br>[1130, 1242, 0]"]
2["Path<br>[1130, 1238, 0]"]
3["Segment<br>[1130, 1238, 0]"]
4["Segment<br>[1130, 1238, 0]"]
5["Segment<br>[1130, 1238, 0]"]
6["Segment<br>[1130, 1238, 0]"]
7["Segment<br>[1130, 1238, 0]"]
8["Segment<br>[1130, 1238, 0]"]
9[Solid2d]
end
subgraph path11 [Path]
11["Path<br>[1287, 1399, 0]"]
12["Segment<br>[1287, 1399, 0]"]
13["Segment<br>[1287, 1399, 0]"]
14["Segment<br>[1287, 1399, 0]"]
15["Segment<br>[1287, 1399, 0]"]
16["Segment<br>[1287, 1399, 0]"]
17["Segment<br>[1287, 1399, 0]"]
11["Path<br>[1283, 1391, 0]"]
12["Segment<br>[1283, 1391, 0]"]
13["Segment<br>[1283, 1391, 0]"]
14["Segment<br>[1283, 1391, 0]"]
15["Segment<br>[1283, 1391, 0]"]
16["Segment<br>[1283, 1391, 0]"]
17["Segment<br>[1283, 1391, 0]"]
18[Solid2d]
end
1["Plane<br>[1107, 1124, 0]"]
10["Plane<br>[1261, 1281, 0]"]
19["Sweep Extrusion<br>[1445, 1488, 0]"]
10["Plane<br>[1257, 1277, 0]"]
19["Sweep Extrusion<br>[1437, 1480, 0]"]
20[Wall]
21[Wall]
22[Wall]
@ -40,7 +40,7 @@ flowchart LR
34["SweepEdge Adjacent"]
35["SweepEdge Opposite"]
36["SweepEdge Adjacent"]
37["Sweep Extrusion<br>[1502, 1549, 0]"]
37["Sweep Extrusion<br>[1494, 1541, 0]"]
38[Wall]
39[Wall]
40[Wall]

View File

@ -1405,22 +1405,15 @@ description: Result of parsing dodecahedron.kcl
{
"arguments": [
{
"commentStart": 0,
"end": 0,
"properties": [
{
"commentStart": 0,
"end": 0,
"key": {
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "radius",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"arg": {
"abs_path": false,
"commentStart": 0,
"end": 0,
@ -1438,18 +1431,15 @@ description: Result of parsing dodecahedron.kcl
}
},
{
"commentStart": 0,
"end": 0,
"key": {
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "numSides",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"arg": {
"commentStart": 0,
"end": 0,
"raw": "5",
@ -1463,18 +1453,15 @@ description: Result of parsing dodecahedron.kcl
}
},
{
"commentStart": 0,
"end": 0,
"key": {
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "center",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"arg": {
"commentStart": 0,
"elements": [
{
@ -1509,18 +1496,15 @@ description: Result of parsing dodecahedron.kcl
}
},
{
"commentStart": 0,
"end": 0,
"key": {
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "inscribed",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"arg": {
"commentStart": 0,
"end": 0,
"raw": "true",
@ -1531,18 +1515,6 @@ description: Result of parsing dodecahedron.kcl
}
}
],
"start": 0,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"commentStart": 0,
"end": 0,
"start": 0,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
@ -1561,8 +1533,9 @@ description: Result of parsing dodecahedron.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": null
}
],
"commentStart": 0,
@ -1642,22 +1615,15 @@ description: Result of parsing dodecahedron.kcl
{
"arguments": [
{
"commentStart": 0,
"end": 0,
"properties": [
{
"commentStart": 0,
"end": 0,
"key": {
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "radius",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"arg": {
"abs_path": false,
"commentStart": 0,
"end": 0,
@ -1675,18 +1641,15 @@ description: Result of parsing dodecahedron.kcl
}
},
{
"commentStart": 0,
"end": 0,
"key": {
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "numSides",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"arg": {
"commentStart": 0,
"end": 0,
"raw": "5",
@ -1700,18 +1663,15 @@ description: Result of parsing dodecahedron.kcl
}
},
{
"commentStart": 0,
"end": 0,
"key": {
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "center",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"arg": {
"commentStart": 0,
"elements": [
{
@ -1746,18 +1706,15 @@ description: Result of parsing dodecahedron.kcl
}
},
{
"commentStart": 0,
"end": 0,
"key": {
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "inscribed",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"arg": {
"commentStart": 0,
"end": 0,
"raw": "true",
@ -1768,18 +1725,6 @@ description: Result of parsing dodecahedron.kcl
}
}
],
"start": 0,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"commentStart": 0,
"end": 0,
"start": 0,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
@ -1798,8 +1743,9 @@ description: Result of parsing dodecahedron.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": null
}
],
"commentStart": 0,

View File

@ -4,16 +4,16 @@ flowchart LR
2["Path<br>[132, 157, 0]"]
end
subgraph path3 [Path]
3["Path<br>[163, 273, 0]"]
4["Segment<br>[163, 273, 0]"]
5["Segment<br>[163, 273, 0]"]
6["Segment<br>[163, 273, 0]"]
7["Segment<br>[163, 273, 0]"]
8["Segment<br>[163, 273, 0]"]
3["Path<br>[163, 269, 0]"]
4["Segment<br>[163, 269, 0]"]
5["Segment<br>[163, 269, 0]"]
6["Segment<br>[163, 269, 0]"]
7["Segment<br>[163, 269, 0]"]
8["Segment<br>[163, 269, 0]"]
9[Solid2d]
end
1["Plane<br>[109, 126, 0]"]
10["Sweep Extrusion<br>[279, 298, 0]"]
10["Sweep Extrusion<br>[275, 294, 0]"]
11[Wall]
12[Wall]
13[Wall]

View File

@ -351,22 +351,15 @@ description: Result of parsing multi_transform.kcl
{
"arguments": [
{
"commentStart": 0,
"end": 0,
"properties": [
{
"commentStart": 0,
"end": 0,
"key": {
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "radius",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"arg": {
"commentStart": 0,
"end": 0,
"raw": "10",
@ -380,18 +373,15 @@ description: Result of parsing multi_transform.kcl
}
},
{
"commentStart": 0,
"end": 0,
"key": {
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "numSides",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"arg": {
"commentStart": 0,
"end": 0,
"raw": "4",
@ -405,18 +395,15 @@ description: Result of parsing multi_transform.kcl
}
},
{
"commentStart": 0,
"end": 0,
"key": {
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "center",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"arg": {
"commentStart": 0,
"elements": [
{
@ -451,18 +438,15 @@ description: Result of parsing multi_transform.kcl
}
},
{
"commentStart": 0,
"end": 0,
"key": {
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "inscribed",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"arg": {
"commentStart": 0,
"end": 0,
"raw": "false",
@ -473,18 +457,6 @@ description: Result of parsing multi_transform.kcl
}
}
],
"start": 0,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"commentStart": 0,
"end": 0,
"start": 0,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
@ -503,8 +475,9 @@ description: Result of parsing multi_transform.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": null
},
{
"arguments": [

View File

@ -6,11 +6,11 @@ fn transform(i) {
}
startSketchOn(XY)
|> startProfileAt([0, 0], %)
|> polygon({
|> polygon(
radius = 10,
numSides = 4,
center = [0, 0],
inscribed = false
}, %)
inscribed = false,
)
|> extrude(length = 4)
|> patternTransform(instances = 3, transform = transform)

View File

@ -10,11 +10,11 @@ fn transform(i) {
}
startSketchOn(XY)
|> startProfileAt([0, 0], %)
|> polygon({
|> polygon(
radius = 10,
numSides = 4,
center = [0, 0],
inscribed = false
}, %)
inscribed = false,
)
|> extrude(length = 4)
|> patternTransform(instances = 3, transform = transform)