transform w optional args (#6095)
Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
File diff suppressed because one or more lines are too long
@ -267784,9 +267784,10 @@
|
||||
"type": "number",
|
||||
"schema": {
|
||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||
"title": "double",
|
||||
"title": "Nullable_double",
|
||||
"type": "number",
|
||||
"format": "double",
|
||||
"nullable": true,
|
||||
"definitions": {
|
||||
"Solid": {
|
||||
"type": "object",
|
||||
@ -269371,9 +269372,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true,
|
||||
"required": false,
|
||||
"includeInSnippet": true,
|
||||
"description": "The scale factor for the x axis.",
|
||||
"description": "The scale factor for the x axis. Default is 1 if not provided.",
|
||||
"labelRequired": true
|
||||
},
|
||||
{
|
||||
@ -269381,9 +269382,10 @@
|
||||
"type": "number",
|
||||
"schema": {
|
||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||
"title": "double",
|
||||
"title": "Nullable_double",
|
||||
"type": "number",
|
||||
"format": "double",
|
||||
"nullable": true,
|
||||
"definitions": {
|
||||
"Solid": {
|
||||
"type": "object",
|
||||
@ -270968,9 +270970,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true,
|
||||
"required": false,
|
||||
"includeInSnippet": true,
|
||||
"description": "The scale factor for the y axis.",
|
||||
"description": "The scale factor for the y axis. Default is 1 if not provided.",
|
||||
"labelRequired": true
|
||||
},
|
||||
{
|
||||
@ -270978,9 +270980,10 @@
|
||||
"type": "number",
|
||||
"schema": {
|
||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||
"title": "double",
|
||||
"title": "Nullable_double",
|
||||
"type": "number",
|
||||
"format": "double",
|
||||
"nullable": true,
|
||||
"definitions": {
|
||||
"Solid": {
|
||||
"type": "object",
|
||||
@ -272565,9 +272568,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true,
|
||||
"required": false,
|
||||
"includeInSnippet": true,
|
||||
"description": "The scale factor for the z axis.",
|
||||
"description": "The scale factor for the z axis. Default is 1 if not provided.",
|
||||
"labelRequired": true
|
||||
},
|
||||
{
|
||||
@ -275836,9 +275839,9 @@
|
||||
"unpublished": false,
|
||||
"deprecated": false,
|
||||
"examples": [
|
||||
"// Scale a pipe.\n\n// Create a path for the sweep.\nsweepPath = startSketchOn(XZ)\n |> startProfileAt([0.05, 0.05], %)\n |> line(end = [0, 7])\n |> tangentialArc({ offset = 90, radius = 5 }, %)\n |> line(end = [-3, 0])\n |> tangentialArc({ offset = -90, radius = 5 }, %)\n |> line(end = [0, 7])\n\n// Create a hole for the pipe.\npipeHole = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 1.5)\n\nsweepSketch = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 2)\n |> hole(pipeHole, %)\n |> sweep(path = sweepPath)\n |> scale(x = 1.0, y = 1.0, z = 2.5)",
|
||||
"// Scale an imported model.\n\n\nimport \"tests/inputs/cube.sldprt\" as cube\n\ncube\n |> scale(x = 1.0, y = 1.0, z = 2.5)",
|
||||
"// Sweep two sketches along the same path.\n\n\nsketch001 = startSketchOn(XY)\nrectangleSketch = startProfileAt([-200, 23.86], sketch001)\n |> angledLine([0, 73.47], %, $rectangleSegmentA001)\n |> angledLine([\n segAng(rectangleSegmentA001) - 90,\n 50.61\n ], %)\n |> angledLine([\n segAng(rectangleSegmentA001),\n -segLen(rectangleSegmentA001)\n ], %)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)\n\nsketch002 = startSketchOn(YZ)\nsweepPath = startProfileAt([0, 0], sketch002)\n |> yLine(length = 231.81)\n |> tangentialArc({ radius = 80, offset = -90 }, %)\n |> xLine(length = 384.93)\n\nparts = sweep([rectangleSketch, circleSketch], path = sweepPath)\n\n// Scale the sweep.\nscale(\n parts,\n x = 1.0,\n y = 1.0,\n z = 0.5,\n)"
|
||||
"// Scale a pipe.\n\n// Create a path for the sweep.\nsweepPath = startSketchOn(XZ)\n |> startProfileAt([0.05, 0.05], %)\n |> line(end = [0, 7])\n |> tangentialArc({ offset = 90, radius = 5 }, %)\n |> line(end = [-3, 0])\n |> tangentialArc({ offset = -90, radius = 5 }, %)\n |> line(end = [0, 7])\n\n// Create a hole for the pipe.\npipeHole = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 1.5)\n\nsweepSketch = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 2)\n |> hole(pipeHole, %)\n |> sweep(path = sweepPath)\n |> scale(z = 2.5)",
|
||||
"// Scale an imported model.\n\n\nimport \"tests/inputs/cube.sldprt\" as cube\n\ncube\n |> scale(z = 2.5)",
|
||||
"// Sweep two sketches along the same path.\n\n\nsketch001 = startSketchOn(XY)\nrectangleSketch = startProfileAt([-200, 23.86], sketch001)\n |> angledLine([0, 73.47], %, $rectangleSegmentA001)\n |> angledLine([\n segAng(rectangleSegmentA001) - 90,\n 50.61\n ], %)\n |> angledLine([\n segAng(rectangleSegmentA001),\n -segLen(rectangleSegmentA001)\n ], %)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)\n\nsketch002 = startSketchOn(YZ)\nsweepPath = startProfileAt([0, 0], sketch002)\n |> yLine(length = 231.81)\n |> tangentialArc({ radius = 80, offset = -90 }, %)\n |> xLine(length = 384.93)\n\nparts = sweep([rectangleSketch, circleSketch], path = sweepPath)\n\n// Scale the sweep.\nscale(parts, z = 0.5)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -326051,9 +326054,10 @@
|
||||
"type": "number",
|
||||
"schema": {
|
||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||
"title": "double",
|
||||
"title": "Nullable_double",
|
||||
"type": "number",
|
||||
"format": "double",
|
||||
"nullable": true,
|
||||
"definitions": {
|
||||
"Solid": {
|
||||
"type": "object",
|
||||
@ -327638,9 +327642,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true,
|
||||
"required": false,
|
||||
"includeInSnippet": true,
|
||||
"description": "The amount to move the solid or sketch along the x axis.",
|
||||
"description": "The amount to move the solid or sketch along the x axis. Defaults to 0 if not provided.",
|
||||
"labelRequired": true
|
||||
},
|
||||
{
|
||||
@ -327648,9 +327652,10 @@
|
||||
"type": "number",
|
||||
"schema": {
|
||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||
"title": "double",
|
||||
"title": "Nullable_double",
|
||||
"type": "number",
|
||||
"format": "double",
|
||||
"nullable": true,
|
||||
"definitions": {
|
||||
"Solid": {
|
||||
"type": "object",
|
||||
@ -329235,9 +329240,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true,
|
||||
"required": false,
|
||||
"includeInSnippet": true,
|
||||
"description": "The amount to move the solid or sketch along the y axis.",
|
||||
"description": "The amount to move the solid or sketch along the y axis. Defaults to 0 if not provided.",
|
||||
"labelRequired": true
|
||||
},
|
||||
{
|
||||
@ -329245,9 +329250,10 @@
|
||||
"type": "number",
|
||||
"schema": {
|
||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||
"title": "double",
|
||||
"title": "Nullable_double",
|
||||
"type": "number",
|
||||
"format": "double",
|
||||
"nullable": true,
|
||||
"definitions": {
|
||||
"Solid": {
|
||||
"type": "object",
|
||||
@ -330832,9 +330838,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true,
|
||||
"required": false,
|
||||
"includeInSnippet": true,
|
||||
"description": "The amount to move the solid or sketch along the z axis.",
|
||||
"description": "The amount to move the solid or sketch along the z axis. Defaults to 0 if not provided.",
|
||||
"labelRequired": true
|
||||
},
|
||||
{
|
||||
@ -334106,8 +334112,8 @@
|
||||
"// Move a pipe.\n\n// Create a path for the sweep.\nsweepPath = startSketchOn(XZ)\n |> startProfileAt([0.05, 0.05], %)\n |> line(end = [0, 7])\n |> tangentialArc({ offset = 90, radius = 5 }, %)\n |> line(end = [-3, 0])\n |> tangentialArc({ offset = -90, radius = 5 }, %)\n |> line(end = [0, 7])\n\n// Create a hole for the pipe.\npipeHole = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 1.5)\n\nsweepSketch = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 2)\n |> hole(pipeHole, %)\n |> sweep(path = sweepPath)\n |> translate(x = 1.0, y = 1.0, z = 2.5)",
|
||||
"// Move an imported model.\n\n\nimport \"tests/inputs/cube.sldprt\" as cube\n\ncube\n |> translate(x = 1.0, y = 1.0, z = 2.5)",
|
||||
"// Sweep two sketches along the same path.\n\n\nsketch001 = startSketchOn(XY)\nrectangleSketch = startProfileAt([-200, 23.86], sketch001)\n |> angledLine([0, 73.47], %, $rectangleSegmentA001)\n |> angledLine([\n segAng(rectangleSegmentA001) - 90,\n 50.61\n ], %)\n |> angledLine([\n segAng(rectangleSegmentA001),\n -segLen(rectangleSegmentA001)\n ], %)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)\n\nsketch002 = startSketchOn(YZ)\nsweepPath = startProfileAt([0, 0], sketch002)\n |> yLine(length = 231.81)\n |> tangentialArc({ radius = 80, offset = -90 }, %)\n |> xLine(length = 384.93)\n\nparts = sweep([rectangleSketch, circleSketch], path = sweepPath)\n\n// Move the sweeps.\ntranslate(\n parts,\n x = 1.0,\n y = 1.0,\n z = 2.5,\n)",
|
||||
"// Move a sketch.\n\n\nfn square(length) {\n l = length / 2\n p0 = [-l, -l]\n p1 = [-l, l]\n p2 = [l, l]\n p3 = [l, -l]\n\n return startSketchOn(XY)\n |> startProfileAt(p0, %)\n |> line(endAbsolute = p1)\n |> line(endAbsolute = p2)\n |> line(endAbsolute = p3)\n |> close()\n}\n\nsquare(10)\n |> translate(x = 5, y = 5, z = 0)\n |> extrude(length = 10)",
|
||||
"// Translate and rotate a sketch to create a loft.\nsketch001 = startSketchOn(XY)\n\nfn square() {\n return startProfileAt([-10, 10], sketch001)\n |> xLine(length = 20)\n |> yLine(length = -20)\n |> xLine(length = -20)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n}\n\nprofile001 = square()\n\nprofile002 = square()\n |> translate(x = 0, y = 0, z = 20)\n |> rotate(axis = [0, 0, 1.0], angle = 45)\n\nloft([profile001, profile002])"
|
||||
"// Move a sketch.\n\n\nfn square(length) {\n l = length / 2\n p0 = [-l, -l]\n p1 = [-l, l]\n p2 = [l, l]\n p3 = [l, -l]\n\n return startSketchOn(XY)\n |> startProfileAt(p0, %)\n |> line(endAbsolute = p1)\n |> line(endAbsolute = p2)\n |> line(endAbsolute = p3)\n |> close()\n}\n\nsquare(10)\n |> translate(x = 5, y = 5)\n |> extrude(length = 10)",
|
||||
"// Translate and rotate a sketch to create a loft.\nsketch001 = startSketchOn(XY)\n\nfn square() {\n return startProfileAt([-10, 10], sketch001)\n |> xLine(length = 20)\n |> yLine(length = -20)\n |> xLine(length = -20)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n}\n\nprofile001 = square()\n\nprofile002 = square()\n |> translate(z = 20)\n |> rotate(axis = [0, 0, 1.0], angle = 45)\n\nloft([profile001, profile002])"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -13,9 +13,9 @@ Translate is really useful for sketches if you want to move a sketch and then ro
|
||||
```js
|
||||
translate(
|
||||
objects: SolidOrSketchOrImportedGeometry,
|
||||
x: number,
|
||||
y: number,
|
||||
z: number,
|
||||
x?: number,
|
||||
y?: number,
|
||||
z?: number,
|
||||
global?: bool,
|
||||
): SolidOrSketchOrImportedGeometry
|
||||
```
|
||||
@ -26,9 +26,9 @@ translate(
|
||||
| Name | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `objects` | [`SolidOrSketchOrImportedGeometry`](/docs/kcl/types/SolidOrSketchOrImportedGeometry) | The solid, sketch, or set of solids or sketches to move. | Yes |
|
||||
| `x` | [`number`](/docs/kcl/types/number) | The amount to move the solid or sketch along the x axis. | Yes |
|
||||
| `y` | [`number`](/docs/kcl/types/number) | The amount to move the solid or sketch along the y axis. | Yes |
|
||||
| `z` | [`number`](/docs/kcl/types/number) | The amount to move the solid or sketch along the z axis. | Yes |
|
||||
| `x` | [`number`](/docs/kcl/types/number) | The amount to move the solid or sketch along the x axis. Defaults to 0 if not provided. | No |
|
||||
| `y` | [`number`](/docs/kcl/types/number) | The amount to move the solid or sketch along the y axis. Defaults to 0 if not provided. | No |
|
||||
| `z` | [`number`](/docs/kcl/types/number) | The amount to move the solid or sketch along the z axis. Defaults to 0 if not provided. | No |
|
||||
| `global` | [`bool`](/docs/kcl/types/bool) | If true, the transform is applied in global space. The origin of the model will move. By default, the transform is applied in local sketch axis, therefore the origin will not move. | No |
|
||||
|
||||
### Returns
|
||||
@ -134,7 +134,7 @@ fn square(length) {
|
||||
}
|
||||
|
||||
square(10)
|
||||
|> translate(x = 5, y = 5, z = 0)
|
||||
|> translate(x = 5, y = 5)
|
||||
|> extrude(length = 10)
|
||||
```
|
||||
|
||||
@ -156,7 +156,7 @@ fn square() {
|
||||
profile001 = square()
|
||||
|
||||
profile002 = square()
|
||||
|> translate(x = 0, y = 0, z = 20)
|
||||
|> translate(z = 20)
|
||||
|> rotate(axis = [0, 0, 1.0], angle = 45)
|
||||
|
||||
loft([profile001, profile002])
|
||||
|
@ -28,11 +28,19 @@ pub async fn scale(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
]),
|
||||
exec_state,
|
||||
)?;
|
||||
let scale_x = args.get_kw_arg("x")?;
|
||||
let scale_y = args.get_kw_arg("y")?;
|
||||
let scale_z = args.get_kw_arg("z")?;
|
||||
let scale_x = args.get_kw_arg_opt("x")?;
|
||||
let scale_y = args.get_kw_arg_opt("y")?;
|
||||
let scale_z = args.get_kw_arg_opt("z")?;
|
||||
let global = args.get_kw_arg_opt("global")?;
|
||||
|
||||
// Ensure at least one scale value is provided.
|
||||
if scale_x.is_none() && scale_y.is_none() && scale_z.is_none() {
|
||||
return Err(KclError::Semantic(KclErrorDetails {
|
||||
message: "Expected `x`, `y`, or `z` to be provided.".to_string(),
|
||||
source_ranges: vec![args.source_range],
|
||||
}));
|
||||
}
|
||||
|
||||
let objects = inner_scale(objects, scale_x, scale_y, scale_z, global, exec_state, args).await?;
|
||||
Ok(objects.into())
|
||||
}
|
||||
@ -85,8 +93,6 @@ pub async fn scale(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// |> hole(pipeHole, %)
|
||||
/// |> sweep(path = sweepPath)
|
||||
/// |> scale(
|
||||
/// x = 1.0,
|
||||
/// y = 1.0,
|
||||
/// z = 2.5,
|
||||
/// )
|
||||
/// ```
|
||||
@ -98,8 +104,6 @@ pub async fn scale(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
///
|
||||
/// cube
|
||||
/// |> scale(
|
||||
/// x = 1.0,
|
||||
/// y = 1.0,
|
||||
/// z = 2.5,
|
||||
/// )
|
||||
/// ```
|
||||
@ -135,7 +139,7 @@ pub async fn scale(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// parts = sweep([rectangleSketch, circleSketch], path = sweepPath)
|
||||
///
|
||||
/// // Scale the sweep.
|
||||
/// scale(parts, x = 1.0, y = 1.0, z = 0.5)
|
||||
/// scale(parts, z = 0.5)
|
||||
/// ```
|
||||
#[stdlib {
|
||||
name = "scale",
|
||||
@ -144,17 +148,17 @@ pub async fn scale(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
unlabeled_first = true,
|
||||
args = {
|
||||
objects = {docs = "The solid, sketch, or set of solids or sketches to scale."},
|
||||
x = {docs = "The scale factor for the x axis."},
|
||||
y = {docs = "The scale factor for the y axis."},
|
||||
z = {docs = "The scale factor for the z axis."},
|
||||
x = {docs = "The scale factor for the x axis. Default is 1 if not provided.", include_in_snippet = true},
|
||||
y = {docs = "The scale factor for the y axis. Default is 1 if not provided.", include_in_snippet = true},
|
||||
z = {docs = "The scale factor for the z axis. Default is 1 if not provided.", include_in_snippet = true},
|
||||
global = {docs = "If true, the transform is applied in global space. The origin of the model will move. By default, the transform is applied in local sketch axis, therefore the origin will not move."}
|
||||
}
|
||||
}]
|
||||
async fn inner_scale(
|
||||
objects: SolidOrSketchOrImportedGeometry,
|
||||
x: f64,
|
||||
y: f64,
|
||||
z: f64,
|
||||
x: Option<f64>,
|
||||
y: Option<f64>,
|
||||
z: Option<f64>,
|
||||
global: Option<bool>,
|
||||
exec_state: &mut ExecState,
|
||||
args: Args,
|
||||
@ -174,7 +178,11 @@ async fn inner_scale(
|
||||
object_id,
|
||||
transforms: vec![shared::ComponentTransform {
|
||||
scale: Some(shared::TransformBy::<Point3d<f64>> {
|
||||
property: Point3d { x, y, z },
|
||||
property: Point3d {
|
||||
x: x.unwrap_or(1.0),
|
||||
y: y.unwrap_or(1.0),
|
||||
z: z.unwrap_or(1.0),
|
||||
},
|
||||
set: false,
|
||||
is_local: !global.unwrap_or(false),
|
||||
}),
|
||||
@ -201,11 +209,19 @@ pub async fn translate(exec_state: &mut ExecState, args: Args) -> Result<KclValu
|
||||
]),
|
||||
exec_state,
|
||||
)?;
|
||||
let translate_x = args.get_kw_arg("x")?;
|
||||
let translate_y = args.get_kw_arg("y")?;
|
||||
let translate_z = args.get_kw_arg("z")?;
|
||||
let translate_x = args.get_kw_arg_opt("x")?;
|
||||
let translate_y = args.get_kw_arg_opt("y")?;
|
||||
let translate_z = args.get_kw_arg_opt("z")?;
|
||||
let global = args.get_kw_arg_opt("global")?;
|
||||
|
||||
// Ensure at least one translation value is provided.
|
||||
if translate_x.is_none() && translate_y.is_none() && translate_z.is_none() {
|
||||
return Err(KclError::Semantic(KclErrorDetails {
|
||||
message: "Expected `x`, `y`, or `z` to be provided.".to_string(),
|
||||
source_ranges: vec![args.source_range],
|
||||
}));
|
||||
}
|
||||
|
||||
let objects = inner_translate(objects, translate_x, translate_y, translate_z, global, exec_state, args).await?;
|
||||
Ok(objects.into())
|
||||
}
|
||||
@ -326,7 +342,6 @@ pub async fn translate(exec_state: &mut ExecState, args: Args) -> Result<KclValu
|
||||
/// |> translate(
|
||||
/// x = 5,
|
||||
/// y = 5,
|
||||
/// z = 0,
|
||||
/// )
|
||||
/// |> extrude(
|
||||
/// length = 10,
|
||||
@ -349,7 +364,7 @@ pub async fn translate(exec_state: &mut ExecState, args: Args) -> Result<KclValu
|
||||
/// profile001 = square()
|
||||
///
|
||||
/// profile002 = square()
|
||||
/// |> translate(x = 0, y = 0, z = 20)
|
||||
/// |> translate(z = 20)
|
||||
/// |> rotate(axis = [0, 0, 1.0], angle = 45)
|
||||
///
|
||||
/// loft([profile001, profile002])
|
||||
@ -361,17 +376,17 @@ pub async fn translate(exec_state: &mut ExecState, args: Args) -> Result<KclValu
|
||||
unlabeled_first = true,
|
||||
args = {
|
||||
objects = {docs = "The solid, sketch, or set of solids or sketches to move."},
|
||||
x = {docs = "The amount to move the solid or sketch along the x axis."},
|
||||
y = {docs = "The amount to move the solid or sketch along the y axis."},
|
||||
z = {docs = "The amount to move the solid or sketch along the z axis."},
|
||||
x = {docs = "The amount to move the solid or sketch along the x axis. Defaults to 0 if not provided.", include_in_snippet = true},
|
||||
y = {docs = "The amount to move the solid or sketch along the y axis. Defaults to 0 if not provided.", include_in_snippet = true},
|
||||
z = {docs = "The amount to move the solid or sketch along the z axis. Defaults to 0 if not provided.", include_in_snippet = true},
|
||||
global = {docs = "If true, the transform is applied in global space. The origin of the model will move. By default, the transform is applied in local sketch axis, therefore the origin will not move."}
|
||||
}
|
||||
}]
|
||||
async fn inner_translate(
|
||||
objects: SolidOrSketchOrImportedGeometry,
|
||||
x: f64,
|
||||
y: f64,
|
||||
z: f64,
|
||||
x: Option<f64>,
|
||||
y: Option<f64>,
|
||||
z: Option<f64>,
|
||||
global: Option<bool>,
|
||||
exec_state: &mut ExecState,
|
||||
args: Args,
|
||||
@ -392,9 +407,9 @@ async fn inner_translate(
|
||||
transforms: vec![shared::ComponentTransform {
|
||||
translate: Some(shared::TransformBy::<Point3d<LengthUnit>> {
|
||||
property: shared::Point3d {
|
||||
x: LengthUnit(x),
|
||||
y: LengthUnit(y),
|
||||
z: LengthUnit(z),
|
||||
x: LengthUnit(x.unwrap_or_default()),
|
||||
y: LengthUnit(y.unwrap_or_default()),
|
||||
z: LengthUnit(z.unwrap_or_default()),
|
||||
},
|
||||
set: false,
|
||||
is_local: !global.unwrap_or(false),
|
||||
@ -1001,4 +1016,34 @@ sweepSketch = startSketchOn('XY')
|
||||
.to_string()
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_translate_no_args() {
|
||||
let ast = PIPE.to_string()
|
||||
+ r#"
|
||||
|> translate(
|
||||
)
|
||||
"#;
|
||||
let result = parse_execute(&ast).await;
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
result.unwrap_err().message(),
|
||||
r#"Expected `x`, `y`, or `z` to be provided."#.to_string()
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_scale_no_args() {
|
||||
let ast = PIPE.to_string()
|
||||
+ r#"
|
||||
|> scale(
|
||||
)
|
||||
"#;
|
||||
let result = parse_execute(&ast).await;
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
result.unwrap_err().message(),
|
||||
r#"Expected `x`, `y`, or `z` to be provided."#.to_string()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user