Move edge functions to KCL (#7259)
Signed-off-by: Nick Cameron <nrc@ncameron.org>
@ -8,7 +8,7 @@ layout: manual
 | 
			
		||||
Get the shared edge between two faces.
 | 
			
		||||
 | 
			
		||||
```kcl
 | 
			
		||||
getCommonEdge(faces: [TagIdentifier]): Uuid
 | 
			
		||||
getCommonEdge(faces: [tag; 2]): Edge
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -17,11 +17,11 @@ getCommonEdge(faces: [TagIdentifier]): Uuid
 | 
			
		||||
 | 
			
		||||
| Name | Type | Description | Required |
 | 
			
		||||
|----------|------|-------------|----------|
 | 
			
		||||
| `faces` | [`[TagIdentifier]`](/docs/kcl-lang/types#TagIdentifier) | The tags of the faces you want to find the common edge between | Yes |
 | 
			
		||||
| `faces` | `[tag; 2]` | The tags of the faces you want to find the common edge between. | Yes |
 | 
			
		||||
 | 
			
		||||
### Returns
 | 
			
		||||
 | 
			
		||||
`Uuid`
 | 
			
		||||
[`Edge`](/docs/kcl-std/types/std-types-Edge) - An edge of a solid.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Examples
 | 
			
		||||
@ -29,17 +29,16 @@ getCommonEdge(faces: [TagIdentifier]): Uuid
 | 
			
		||||
```kcl
 | 
			
		||||
// Get an edge shared between two faces, created after a chamfer.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
scale = 20
 | 
			
		||||
part001 = startSketchOn(XY)
 | 
			
		||||
  |> startProfile(at = [0, 0])
 | 
			
		||||
  |> line(end = [0, scale])
 | 
			
		||||
  |> line(end = [scale, 0])
 | 
			
		||||
  |> line(end = [0, -scale])
 | 
			
		||||
  |> close(tag = $line0)
 | 
			
		||||
  |> extrude(length = 20, tagEnd = $end0)
 | 
			
		||||
  // We tag the chamfer to reference it later.
 | 
			
		||||
  |> chamfer(length = 10, tags = [getOppositeEdge(line0)], tag = $chamfer0)
 | 
			
		||||
    |> startProfile(at = [0, 0])
 | 
			
		||||
    |> line(end = [0, scale])
 | 
			
		||||
    |> line(end = [scale, 0])
 | 
			
		||||
    |> line(end = [0, -scale])
 | 
			
		||||
    |> close(tag = $line0)
 | 
			
		||||
    |> extrude(length = 20, tagEnd = $end0)
 | 
			
		||||
    // We tag the chamfer to reference it later.
 | 
			
		||||
    |> chamfer(length = 10, tags = [getOppositeEdge(line0)], tag = $chamfer0)
 | 
			
		||||
 | 
			
		||||
// Get the shared edge between the chamfer and the extrusion.
 | 
			
		||||
commonEdge = getCommonEdge(faces = [chamfer0, end0])
 | 
			
		||||
@ -56,10 +56,10 @@ layout: manual
 | 
			
		||||
  * [`circleThreePoint`](/docs/kcl-std/circleThreePoint)
 | 
			
		||||
  * [`close`](/docs/kcl-std/close)
 | 
			
		||||
  * [`extrude`](/docs/kcl-std/extrude)
 | 
			
		||||
  * [`getCommonEdge`](/docs/kcl-std/getCommonEdge)
 | 
			
		||||
  * [`getNextAdjacentEdge`](/docs/kcl-std/getNextAdjacentEdge)
 | 
			
		||||
  * [`getOppositeEdge`](/docs/kcl-std/getOppositeEdge)
 | 
			
		||||
  * [`getPreviousAdjacentEdge`](/docs/kcl-std/getPreviousAdjacentEdge)
 | 
			
		||||
  * [`getCommonEdge`](/docs/kcl-std/functions/std-sketch-getCommonEdge)
 | 
			
		||||
  * [`getNextAdjacentEdge`](/docs/kcl-std/functions/std-sketch-getNextAdjacentEdge)
 | 
			
		||||
  * [`getOppositeEdge`](/docs/kcl-std/functions/std-sketch-getOppositeEdge)
 | 
			
		||||
  * [`getPreviousAdjacentEdge`](/docs/kcl-std/functions/std-sketch-getPreviousAdjacentEdge)
 | 
			
		||||
  * [`involuteCircular`](/docs/kcl-std/involuteCircular)
 | 
			
		||||
  * [`lastSegX`](/docs/kcl-std/lastSegX)
 | 
			
		||||
  * [`lastSegY`](/docs/kcl-std/lastSegY)
 | 
			
		||||
 | 
			
		||||
@ -20,10 +20,10 @@ This module contains functions for creating and manipulating sketches, and makin
 | 
			
		||||
* [`circleThreePoint`](/docs/kcl-std/circleThreePoint)
 | 
			
		||||
* [`close`](/docs/kcl-std/close)
 | 
			
		||||
* [`extrude`](/docs/kcl-std/extrude)
 | 
			
		||||
* [`getCommonEdge`](/docs/kcl-std/getCommonEdge)
 | 
			
		||||
* [`getNextAdjacentEdge`](/docs/kcl-std/getNextAdjacentEdge)
 | 
			
		||||
* [`getOppositeEdge`](/docs/kcl-std/getOppositeEdge)
 | 
			
		||||
* [`getPreviousAdjacentEdge`](/docs/kcl-std/getPreviousAdjacentEdge)
 | 
			
		||||
* [`getCommonEdge`](/docs/kcl-std/functions/std-sketch-getCommonEdge)
 | 
			
		||||
* [`getNextAdjacentEdge`](/docs/kcl-std/functions/std-sketch-getNextAdjacentEdge)
 | 
			
		||||
* [`getOppositeEdge`](/docs/kcl-std/functions/std-sketch-getOppositeEdge)
 | 
			
		||||
* [`getPreviousAdjacentEdge`](/docs/kcl-std/functions/std-sketch-getPreviousAdjacentEdge)
 | 
			
		||||
* [`involuteCircular`](/docs/kcl-std/involuteCircular)
 | 
			
		||||
* [`lastSegX`](/docs/kcl-std/lastSegX)
 | 
			
		||||
* [`lastSegY`](/docs/kcl-std/lastSegY)
 | 
			
		||||
 | 
			
		||||
@ -79822,222 +79822,6 @@
 | 
			
		||||
      ]
 | 
			
		||||
    ]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "name": "getCommonEdge",
 | 
			
		||||
    "summary": "Get the shared edge between two faces.",
 | 
			
		||||
    "description": "",
 | 
			
		||||
    "tags": [
 | 
			
		||||
      "sketch"
 | 
			
		||||
    ],
 | 
			
		||||
    "args": [
 | 
			
		||||
      {
 | 
			
		||||
        "name": "faces",
 | 
			
		||||
        "type": "[TagIdentifier]",
 | 
			
		||||
        "schema": {
 | 
			
		||||
          "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
 | 
			
		||||
          "title": "Array_of_TagIdentifier",
 | 
			
		||||
          "type": "array",
 | 
			
		||||
          "items": {
 | 
			
		||||
            "$ref": "#/components/schemas/TagIdentifier"
 | 
			
		||||
          },
 | 
			
		||||
          "definitions": {
 | 
			
		||||
            "TagIdentifier": {
 | 
			
		||||
              "type": "object",
 | 
			
		||||
              "required": [
 | 
			
		||||
                "value"
 | 
			
		||||
              ],
 | 
			
		||||
              "properties": {
 | 
			
		||||
                "value": {
 | 
			
		||||
                  "type": "string"
 | 
			
		||||
                }
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        },
 | 
			
		||||
        "required": true,
 | 
			
		||||
        "includeInSnippet": true,
 | 
			
		||||
        "description": "The tags of the faces you want to find the common edge between",
 | 
			
		||||
        "labelRequired": true
 | 
			
		||||
      }
 | 
			
		||||
    ],
 | 
			
		||||
    "returnValue": {
 | 
			
		||||
      "name": "",
 | 
			
		||||
      "type": "Uuid",
 | 
			
		||||
      "schema": {
 | 
			
		||||
        "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
 | 
			
		||||
        "title": "Uuid",
 | 
			
		||||
        "type": "string",
 | 
			
		||||
        "format": "uuid"
 | 
			
		||||
      },
 | 
			
		||||
      "required": true,
 | 
			
		||||
      "includeInSnippet": true,
 | 
			
		||||
      "labelRequired": true
 | 
			
		||||
    },
 | 
			
		||||
    "unpublished": false,
 | 
			
		||||
    "deprecated": false,
 | 
			
		||||
    "examples": [
 | 
			
		||||
      [
 | 
			
		||||
        "// Get an edge shared between two faces, created after a chamfer.\n\n\nscale = 20\npart001 = startSketchOn(XY)\n  |> startProfile(at = [0, 0])\n  |> line(end = [0, scale])\n  |> line(end = [scale, 0])\n  |> line(end = [0, -scale])\n  |> close(tag = $line0)\n  |> extrude(length = 20, tagEnd = $end0)\n  // We tag the chamfer to reference it later.\n  |> chamfer(length = 10, tags = [getOppositeEdge(line0)], tag = $chamfer0)\n\n// Get the shared edge between the chamfer and the extrusion.\ncommonEdge = getCommonEdge(faces = [chamfer0, end0])\n\n// Chamfer the shared edge.\n// TODO: uncomment this when ssi for fillets lands\n// chamfer(part001, length = 5, tags = [commonEdge])",
 | 
			
		||||
        false
 | 
			
		||||
      ]
 | 
			
		||||
    ]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "name": "getNextAdjacentEdge",
 | 
			
		||||
    "summary": "Get the next adjacent edge to the edge given.",
 | 
			
		||||
    "description": "",
 | 
			
		||||
    "tags": [
 | 
			
		||||
      "sketch"
 | 
			
		||||
    ],
 | 
			
		||||
    "args": [
 | 
			
		||||
      {
 | 
			
		||||
        "name": "edge",
 | 
			
		||||
        "type": "TagIdentifier",
 | 
			
		||||
        "schema": {
 | 
			
		||||
          "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
 | 
			
		||||
          "title": "TagIdentifier",
 | 
			
		||||
          "type": "object",
 | 
			
		||||
          "required": [
 | 
			
		||||
            "value"
 | 
			
		||||
          ],
 | 
			
		||||
          "properties": {
 | 
			
		||||
            "value": {
 | 
			
		||||
              "type": "string"
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        },
 | 
			
		||||
        "required": true,
 | 
			
		||||
        "includeInSnippet": true,
 | 
			
		||||
        "description": "The tag of the edge you want to find the next adjacent edge of.",
 | 
			
		||||
        "labelRequired": false
 | 
			
		||||
      }
 | 
			
		||||
    ],
 | 
			
		||||
    "returnValue": {
 | 
			
		||||
      "name": "",
 | 
			
		||||
      "type": "Uuid",
 | 
			
		||||
      "schema": {
 | 
			
		||||
        "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
 | 
			
		||||
        "title": "Uuid",
 | 
			
		||||
        "type": "string",
 | 
			
		||||
        "format": "uuid"
 | 
			
		||||
      },
 | 
			
		||||
      "required": true,
 | 
			
		||||
      "includeInSnippet": true,
 | 
			
		||||
      "labelRequired": true
 | 
			
		||||
    },
 | 
			
		||||
    "unpublished": false,
 | 
			
		||||
    "deprecated": false,
 | 
			
		||||
    "examples": [
 | 
			
		||||
      [
 | 
			
		||||
        "exampleSketch = startSketchOn(XZ)\n  |> startProfile(at = [0, 0])\n  |> line(end = [10, 0])\n  |> angledLine(angle = 60, length = 10)\n  |> angledLine(angle = 120, length = 10)\n  |> line(end = [-10, 0])\n  |> angledLine(angle = 240, length = 10, tag = $referenceEdge)\n  |> close()\n\nexample = extrude(exampleSketch, length = 5)\n  |> fillet(radius = 3, tags = [getNextAdjacentEdge(referenceEdge)])",
 | 
			
		||||
        false
 | 
			
		||||
      ]
 | 
			
		||||
    ]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "name": "getOppositeEdge",
 | 
			
		||||
    "summary": "Get the opposite edge to the edge given.",
 | 
			
		||||
    "description": "",
 | 
			
		||||
    "tags": [
 | 
			
		||||
      "sketch"
 | 
			
		||||
    ],
 | 
			
		||||
    "args": [
 | 
			
		||||
      {
 | 
			
		||||
        "name": "edge",
 | 
			
		||||
        "type": "TagIdentifier",
 | 
			
		||||
        "schema": {
 | 
			
		||||
          "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
 | 
			
		||||
          "title": "TagIdentifier",
 | 
			
		||||
          "type": "object",
 | 
			
		||||
          "required": [
 | 
			
		||||
            "value"
 | 
			
		||||
          ],
 | 
			
		||||
          "properties": {
 | 
			
		||||
            "value": {
 | 
			
		||||
              "type": "string"
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        },
 | 
			
		||||
        "required": true,
 | 
			
		||||
        "includeInSnippet": true,
 | 
			
		||||
        "description": "The tag of the edge you want to find the opposite edge of.",
 | 
			
		||||
        "labelRequired": false
 | 
			
		||||
      }
 | 
			
		||||
    ],
 | 
			
		||||
    "returnValue": {
 | 
			
		||||
      "name": "",
 | 
			
		||||
      "type": "Uuid",
 | 
			
		||||
      "schema": {
 | 
			
		||||
        "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
 | 
			
		||||
        "title": "Uuid",
 | 
			
		||||
        "type": "string",
 | 
			
		||||
        "format": "uuid"
 | 
			
		||||
      },
 | 
			
		||||
      "required": true,
 | 
			
		||||
      "includeInSnippet": true,
 | 
			
		||||
      "labelRequired": true
 | 
			
		||||
    },
 | 
			
		||||
    "unpublished": false,
 | 
			
		||||
    "deprecated": false,
 | 
			
		||||
    "examples": [
 | 
			
		||||
      [
 | 
			
		||||
        "exampleSketch = startSketchOn(XZ)\n  |> startProfile(at = [0, 0])\n  |> line(end = [10, 0])\n  |> angledLine(angle = 60, length = 10)\n  |> angledLine(angle = 120, length = 10)\n  |> line(end = [-10, 0])\n  |> angledLine(angle = 240, length = 10, tag = $referenceEdge)\n  |> close()\n\nexample = extrude(exampleSketch, length = 5)\n  |> fillet(radius = 3, tags = [getOppositeEdge(referenceEdge)])",
 | 
			
		||||
        false
 | 
			
		||||
      ]
 | 
			
		||||
    ]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "name": "getPreviousAdjacentEdge",
 | 
			
		||||
    "summary": "Get the previous adjacent edge to the edge given.",
 | 
			
		||||
    "description": "",
 | 
			
		||||
    "tags": [
 | 
			
		||||
      "sketch"
 | 
			
		||||
    ],
 | 
			
		||||
    "args": [
 | 
			
		||||
      {
 | 
			
		||||
        "name": "edge",
 | 
			
		||||
        "type": "TagIdentifier",
 | 
			
		||||
        "schema": {
 | 
			
		||||
          "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
 | 
			
		||||
          "title": "TagIdentifier",
 | 
			
		||||
          "type": "object",
 | 
			
		||||
          "required": [
 | 
			
		||||
            "value"
 | 
			
		||||
          ],
 | 
			
		||||
          "properties": {
 | 
			
		||||
            "value": {
 | 
			
		||||
              "type": "string"
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        },
 | 
			
		||||
        "required": true,
 | 
			
		||||
        "includeInSnippet": true,
 | 
			
		||||
        "description": "The tag of the edge you want to find the previous adjacent edge of.",
 | 
			
		||||
        "labelRequired": false
 | 
			
		||||
      }
 | 
			
		||||
    ],
 | 
			
		||||
    "returnValue": {
 | 
			
		||||
      "name": "",
 | 
			
		||||
      "type": "Uuid",
 | 
			
		||||
      "schema": {
 | 
			
		||||
        "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
 | 
			
		||||
        "title": "Uuid",
 | 
			
		||||
        "type": "string",
 | 
			
		||||
        "format": "uuid"
 | 
			
		||||
      },
 | 
			
		||||
      "required": true,
 | 
			
		||||
      "includeInSnippet": true,
 | 
			
		||||
      "labelRequired": true
 | 
			
		||||
    },
 | 
			
		||||
    "unpublished": false,
 | 
			
		||||
    "deprecated": false,
 | 
			
		||||
    "examples": [
 | 
			
		||||
      [
 | 
			
		||||
        "exampleSketch = startSketchOn(XZ)\n  |> startProfile(at = [0, 0])\n  |> line(end = [10, 0])\n  |> angledLine(angle = 60, length = 10)\n  |> angledLine(angle = 120, length = 10)\n  |> line(end = [-10, 0])\n  |> angledLine(angle = 240, length = 10, tag = $referenceEdge)\n  |> close()\n\nexample = extrude(exampleSketch, length = 5)\n  |> fillet(radius = 3, tags = [getPreviousAdjacentEdge(referenceEdge)])",
 | 
			
		||||
        false
 | 
			
		||||
      ]
 | 
			
		||||
    ]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "name": "involuteCircular",
 | 
			
		||||
    "summary": "Extend the current sketch with a new involute circular curve.",
 | 
			
		||||
 | 
			
		||||
@ -113,6 +113,10 @@ pub const TEST_NAMES: &[&str] = &[
 | 
			
		||||
    "std-sketch-revolve-7",
 | 
			
		||||
    "std-sketch-revolve-8",
 | 
			
		||||
    "std-sketch-revolve-9",
 | 
			
		||||
    "std-sketch-getCommonEdge-0",
 | 
			
		||||
    "std-sketch-getOppositeEdge-0",
 | 
			
		||||
    "std-sketch-getPreviousAdjacentEdge-0",
 | 
			
		||||
    "std-sketch-getNextAdjacentEdge-0",
 | 
			
		||||
    "std-solid-appearance-0",
 | 
			
		||||
    "std-solid-appearance-1",
 | 
			
		||||
    "std-solid-appearance-2",
 | 
			
		||||
 | 
			
		||||
@ -827,6 +827,10 @@ impl ArgData {
 | 
			
		||||
            Some("Edge") => Some((index, format!(r#"{label}${{{index}:tag_or_edge_fn}}"#))),
 | 
			
		||||
            Some("[Edge; 1+]") => Some((index, format!(r#"{label}[${{{index}:tag_or_edge_fn}}]"#))),
 | 
			
		||||
            Some("Plane") => Some((index, format!(r#"{label}${{{}:XY}}"#, index))),
 | 
			
		||||
            Some("[tag; 2]") => Some((
 | 
			
		||||
                index + 1,
 | 
			
		||||
                format!(r#"{label}[${{{}:tag}}, ${{{}:tag}}]"#, index, index + 1),
 | 
			
		||||
            )),
 | 
			
		||||
 | 
			
		||||
            Some("string") => {
 | 
			
		||||
                if self.name == "color" {
 | 
			
		||||
 | 
			
		||||
@ -1148,14 +1148,12 @@ mod tests {
 | 
			
		||||
 | 
			
		||||
    #[test]
 | 
			
		||||
    fn get_autocomplete_snippet_get_common_edge() {
 | 
			
		||||
        let get_common_edge_fn: Box<dyn StdLibFn> = Box::new(crate::std::edge::GetCommonEdge);
 | 
			
		||||
        let snippet = get_common_edge_fn.to_autocomplete_snippet().unwrap();
 | 
			
		||||
        assert_eq!(
 | 
			
		||||
            snippet,
 | 
			
		||||
            r#"getCommonEdge(faces = [{
 | 
			
		||||
	value = ${0:"string"},
 | 
			
		||||
}])"#
 | 
			
		||||
        );
 | 
			
		||||
        let data = kcl_doc::walk_prelude();
 | 
			
		||||
        let DocData::Fn(data) = data.find_by_name("getCommonEdge").unwrap() else {
 | 
			
		||||
            panic!();
 | 
			
		||||
        };
 | 
			
		||||
        let snippet = data.to_autocomplete_snippet();
 | 
			
		||||
        assert_eq!(snippet, r#"getCommonEdge(faces = [${0:tag}, ${1:tag}])"#);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #[test]
 | 
			
		||||
 | 
			
		||||
@ -1,14 +1,16 @@
 | 
			
		||||
//! Edge helper functions.
 | 
			
		||||
 | 
			
		||||
use anyhow::Result;
 | 
			
		||||
use kcl_derive_docs::stdlib;
 | 
			
		||||
use kcmc::{each_cmd as mcmd, ok_response::OkModelingCmdResponse, websocket::OkWebSocketResponseData, ModelingCmd};
 | 
			
		||||
use kittycad_modeling_cmds as kcmc;
 | 
			
		||||
use uuid::Uuid;
 | 
			
		||||
 | 
			
		||||
use crate::{
 | 
			
		||||
    errors::{KclError, KclErrorDetails},
 | 
			
		||||
    execution::{types::RuntimeType, ExecState, ExtrudeSurface, KclValue, TagIdentifier},
 | 
			
		||||
    execution::{
 | 
			
		||||
        types::{ArrayLen, RuntimeType},
 | 
			
		||||
        ExecState, ExtrudeSurface, KclValue, TagIdentifier,
 | 
			
		||||
    },
 | 
			
		||||
    std::Args,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -23,42 +25,6 @@ pub async fn get_opposite_edge(exec_state: &mut ExecState, args: Args) -> Result
 | 
			
		||||
    })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Get the opposite edge to the edge given.
 | 
			
		||||
///
 | 
			
		||||
/// ```no_run
 | 
			
		||||
/// exampleSketch = startSketchOn(XZ)
 | 
			
		||||
///   |> startProfile(at = [0, 0])
 | 
			
		||||
///   |> line(end = [10, 0])
 | 
			
		||||
///   |> angledLine(
 | 
			
		||||
///        angle = 60,
 | 
			
		||||
///        length = 10,
 | 
			
		||||
///      )
 | 
			
		||||
///   |> angledLine(
 | 
			
		||||
///        angle = 120,
 | 
			
		||||
///        length = 10,
 | 
			
		||||
///      )
 | 
			
		||||
///   |> line(end = [-10, 0])
 | 
			
		||||
///   |> angledLine(
 | 
			
		||||
///        angle = 240,
 | 
			
		||||
///        length = 10,
 | 
			
		||||
///        tag = $referenceEdge,
 | 
			
		||||
///      )
 | 
			
		||||
///   |> close()
 | 
			
		||||
///
 | 
			
		||||
/// example = extrude(exampleSketch, length = 5)
 | 
			
		||||
///   |> fillet(
 | 
			
		||||
///     radius = 3,
 | 
			
		||||
///     tags = [getOppositeEdge(referenceEdge)],
 | 
			
		||||
///   )
 | 
			
		||||
/// ```
 | 
			
		||||
#[stdlib {
 | 
			
		||||
    name = "getOppositeEdge",
 | 
			
		||||
    unlabeled_first = true,
 | 
			
		||||
    args = {
 | 
			
		||||
        edge = { docs = "The tag of the edge you want to find the opposite edge of." },
 | 
			
		||||
    },
 | 
			
		||||
    tags = ["sketch"]
 | 
			
		||||
}]
 | 
			
		||||
async fn inner_get_opposite_edge(
 | 
			
		||||
    edge: TagIdentifier,
 | 
			
		||||
    exec_state: &mut ExecState,
 | 
			
		||||
@ -106,42 +72,6 @@ pub async fn get_next_adjacent_edge(exec_state: &mut ExecState, args: Args) -> R
 | 
			
		||||
    })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Get the next adjacent edge to the edge given.
 | 
			
		||||
///
 | 
			
		||||
/// ```no_run
 | 
			
		||||
/// exampleSketch = startSketchOn(XZ)
 | 
			
		||||
///   |> startProfile(at = [0, 0])
 | 
			
		||||
///   |> line(end = [10, 0])
 | 
			
		||||
///   |> angledLine(
 | 
			
		||||
///        angle = 60,
 | 
			
		||||
///        length = 10,
 | 
			
		||||
///      )
 | 
			
		||||
///   |> angledLine(
 | 
			
		||||
///        angle = 120,
 | 
			
		||||
///        length = 10,
 | 
			
		||||
///      )
 | 
			
		||||
///   |> line(end = [-10, 0])
 | 
			
		||||
///   |> angledLine(
 | 
			
		||||
///        angle = 240,
 | 
			
		||||
///        length = 10,
 | 
			
		||||
///        tag = $referenceEdge,
 | 
			
		||||
///      )
 | 
			
		||||
///   |> close()
 | 
			
		||||
///
 | 
			
		||||
/// example = extrude(exampleSketch, length = 5)
 | 
			
		||||
///   |> fillet(
 | 
			
		||||
///     radius = 3,
 | 
			
		||||
///     tags = [getNextAdjacentEdge(referenceEdge)],
 | 
			
		||||
///   )
 | 
			
		||||
/// ```
 | 
			
		||||
#[stdlib {
 | 
			
		||||
    name = "getNextAdjacentEdge",
 | 
			
		||||
    unlabeled_first = true,
 | 
			
		||||
    args = {
 | 
			
		||||
        edge = { docs = "The tag of the edge you want to find the next adjacent edge of." },
 | 
			
		||||
    },
 | 
			
		||||
    tags = ["sketch"]
 | 
			
		||||
}]
 | 
			
		||||
async fn inner_get_next_adjacent_edge(
 | 
			
		||||
    edge: TagIdentifier,
 | 
			
		||||
    exec_state: &mut ExecState,
 | 
			
		||||
@ -198,42 +128,6 @@ pub async fn get_previous_adjacent_edge(exec_state: &mut ExecState, args: Args)
 | 
			
		||||
    })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Get the previous adjacent edge to the edge given.
 | 
			
		||||
///
 | 
			
		||||
/// ```no_run
 | 
			
		||||
/// exampleSketch = startSketchOn(XZ)
 | 
			
		||||
///   |> startProfile(at = [0, 0])
 | 
			
		||||
///   |> line(end = [10, 0])
 | 
			
		||||
///   |> angledLine(
 | 
			
		||||
///        angle = 60,
 | 
			
		||||
///        length = 10,
 | 
			
		||||
///      )
 | 
			
		||||
///   |> angledLine(
 | 
			
		||||
///        angle = 120,
 | 
			
		||||
///        length = 10,
 | 
			
		||||
///      )
 | 
			
		||||
///   |> line(end = [-10, 0])
 | 
			
		||||
///   |> angledLine(
 | 
			
		||||
///        angle = 240,
 | 
			
		||||
///        length = 10,
 | 
			
		||||
///        tag = $referenceEdge,
 | 
			
		||||
///      )
 | 
			
		||||
///   |> close()
 | 
			
		||||
///
 | 
			
		||||
/// example = extrude(exampleSketch, length = 5)
 | 
			
		||||
///   |> fillet(
 | 
			
		||||
///     radius = 3,
 | 
			
		||||
///     tags = [getPreviousAdjacentEdge(referenceEdge)],
 | 
			
		||||
///   )
 | 
			
		||||
/// ```
 | 
			
		||||
#[stdlib {
 | 
			
		||||
    name = "getPreviousAdjacentEdge",
 | 
			
		||||
    unlabeled_first = true,
 | 
			
		||||
    args = {
 | 
			
		||||
        edge = { docs = "The tag of the edge you want to find the previous adjacent edge of." },
 | 
			
		||||
    },
 | 
			
		||||
    tags = ["sketch"]
 | 
			
		||||
}]
 | 
			
		||||
async fn inner_get_previous_adjacent_edge(
 | 
			
		||||
    edge: TagIdentifier,
 | 
			
		||||
    exec_state: &mut ExecState,
 | 
			
		||||
@ -280,7 +174,11 @@ async fn inner_get_previous_adjacent_edge(
 | 
			
		||||
 | 
			
		||||
/// Get the shared edge between two faces.
 | 
			
		||||
pub async fn get_common_edge(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
 | 
			
		||||
    let faces: Vec<TagIdentifier> = args.get_kw_arg("faces")?;
 | 
			
		||||
    let faces: Vec<TagIdentifier> = args.get_kw_arg_typed(
 | 
			
		||||
        "faces",
 | 
			
		||||
        &RuntimeType::Array(Box::new(RuntimeType::tag_identifier()), ArrayLen::Known(2)),
 | 
			
		||||
        exec_state,
 | 
			
		||||
    )?;
 | 
			
		||||
 | 
			
		||||
    let edge = inner_get_common_edge(faces, exec_state, args.clone()).await?;
 | 
			
		||||
    Ok(KclValue::Uuid {
 | 
			
		||||
@ -289,38 +187,6 @@ pub async fn get_common_edge(exec_state: &mut ExecState, args: Args) -> Result<K
 | 
			
		||||
    })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Get the shared edge between two faces.
 | 
			
		||||
///
 | 
			
		||||
/// ```no_run
 | 
			
		||||
/// // Get an edge shared between two faces, created after a chamfer.
 | 
			
		||||
///
 | 
			
		||||
/// scale = 20
 | 
			
		||||
/// part001 = startSketchOn(XY)
 | 
			
		||||
///     |> startProfile(at = [0, 0])
 | 
			
		||||
///     |> line(end = [0, scale])
 | 
			
		||||
///     |> line(end = [scale, 0])
 | 
			
		||||
///     |> line(end = [0, -scale])
 | 
			
		||||
///     |> close(tag = $line0)
 | 
			
		||||
///     |> extrude(length = 20, tagEnd = $end0)
 | 
			
		||||
///     // We tag the chamfer to reference it later.
 | 
			
		||||
///     |> chamfer(length = 10, tags = [getOppositeEdge(line0)], tag = $chamfer0)
 | 
			
		||||
///
 | 
			
		||||
/// // Get the shared edge between the chamfer and the extrusion.
 | 
			
		||||
/// commonEdge = getCommonEdge(faces = [chamfer0, end0])
 | 
			
		||||
///
 | 
			
		||||
/// // Chamfer the shared edge.
 | 
			
		||||
/// // TODO: uncomment this when ssi for fillets lands
 | 
			
		||||
/// // chamfer(part001, length = 5, tags = [commonEdge])
 | 
			
		||||
/// ```
 | 
			
		||||
#[stdlib {
 | 
			
		||||
    name = "getCommonEdge",
 | 
			
		||||
    feature_tree_operation = false,
 | 
			
		||||
    unlabeled_first = false,
 | 
			
		||||
    args = {
 | 
			
		||||
        faces = { docs = "The tags of the faces you want to find the common edge between" },
 | 
			
		||||
    },
 | 
			
		||||
    tags = ["sketch"]
 | 
			
		||||
}]
 | 
			
		||||
async fn inner_get_common_edge(
 | 
			
		||||
    faces: Vec<TagIdentifier>,
 | 
			
		||||
    exec_state: &mut ExecState,
 | 
			
		||||
 | 
			
		||||
@ -77,10 +77,6 @@ lazy_static! {
 | 
			
		||||
        Box::new(crate::std::sketch::Subtract2D),
 | 
			
		||||
        Box::new(crate::std::patterns::PatternLinear2D),
 | 
			
		||||
        Box::new(crate::std::patterns::PatternCircular2D),
 | 
			
		||||
        Box::new(crate::std::edge::GetOppositeEdge),
 | 
			
		||||
        Box::new(crate::std::edge::GetNextAdjacentEdge),
 | 
			
		||||
        Box::new(crate::std::edge::GetPreviousAdjacentEdge),
 | 
			
		||||
        Box::new(crate::std::edge::GetCommonEdge),
 | 
			
		||||
        Box::new(crate::std::sweep::Sweep),
 | 
			
		||||
        Box::new(crate::std::loft::Loft),
 | 
			
		||||
        Box::new(crate::std::assert::Assert),
 | 
			
		||||
@ -213,10 +209,6 @@ pub(crate) fn std_fn(path: &str, fn_name: &str) -> (crate::std::StdFn, StdFnProp
 | 
			
		||||
            |e, a| Box::pin(crate::std::math::leg_angle_y(e, a)),
 | 
			
		||||
            StdFnProps::default("std::math::legAngY"),
 | 
			
		||||
        ),
 | 
			
		||||
        ("sketch", "circle") => (
 | 
			
		||||
            |e, a| Box::pin(crate::std::shapes::circle(e, a)),
 | 
			
		||||
            StdFnProps::default("std::sketch::circle"),
 | 
			
		||||
        ),
 | 
			
		||||
        ("prelude", "helix") => (
 | 
			
		||||
            |e, a| Box::pin(crate::std::helix::helix(e, a)),
 | 
			
		||||
            StdFnProps::default("std::helix").include_in_feature_tree(),
 | 
			
		||||
@ -237,10 +229,6 @@ pub(crate) fn std_fn(path: &str, fn_name: &str) -> (crate::std::StdFn, StdFnProp
 | 
			
		||||
            |e, a| Box::pin(crate::std::transform::scale(e, a)),
 | 
			
		||||
            StdFnProps::default("std::transform::scale"),
 | 
			
		||||
        ),
 | 
			
		||||
        ("sketch", "revolve") => (
 | 
			
		||||
            |e, a| Box::pin(crate::std::revolve::revolve(e, a)),
 | 
			
		||||
            StdFnProps::default("std::sketch::revolve").include_in_feature_tree(),
 | 
			
		||||
        ),
 | 
			
		||||
        ("prelude", "offsetPlane") => (
 | 
			
		||||
            |e, a| Box::pin(crate::std::planes::offset_plane(e, a)),
 | 
			
		||||
            StdFnProps::default("std::offsetPlane").include_in_feature_tree(),
 | 
			
		||||
@ -309,10 +297,34 @@ pub(crate) fn std_fn(path: &str, fn_name: &str) -> (crate::std::StdFn, StdFnProp
 | 
			
		||||
            |e, a| Box::pin(crate::std::clone::clone(e, a)),
 | 
			
		||||
            StdFnProps::default("std::clone").include_in_feature_tree(),
 | 
			
		||||
        ),
 | 
			
		||||
        ("sketch", "circle") => (
 | 
			
		||||
            |e, a| Box::pin(crate::std::shapes::circle(e, a)),
 | 
			
		||||
            StdFnProps::default("std::sketch::circle"),
 | 
			
		||||
        ),
 | 
			
		||||
        ("sketch", "patternTransform2d") => (
 | 
			
		||||
            |e, a| Box::pin(crate::std::patterns::pattern_transform_2d(e, a)),
 | 
			
		||||
            StdFnProps::default("std::sketch::patternTransform2d"),
 | 
			
		||||
        ),
 | 
			
		||||
        ("sketch", "revolve") => (
 | 
			
		||||
            |e, a| Box::pin(crate::std::revolve::revolve(e, a)),
 | 
			
		||||
            StdFnProps::default("std::sketch::revolve").include_in_feature_tree(),
 | 
			
		||||
        ),
 | 
			
		||||
        ("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"),
 | 
			
		||||
        ),
 | 
			
		||||
        ("appearance", "hexString") => (
 | 
			
		||||
            |e, a| Box::pin(crate::std::appearance::hex_string(e, a)),
 | 
			
		||||
            StdFnProps::default("std::appearance::hexString"),
 | 
			
		||||
 | 
			
		||||
@ -307,3 +307,134 @@ export fn patternTransform2d(
 | 
			
		||||
  /// If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid.
 | 
			
		||||
  useOriginal?: boolean = false,
 | 
			
		||||
): [Sketch; 1+] {}
 | 
			
		||||
 | 
			
		||||
/// Get the opposite edge to the edge given.
 | 
			
		||||
///
 | 
			
		||||
/// ```kcl
 | 
			
		||||
/// exampleSketch = startSketchOn(XZ)
 | 
			
		||||
///   |> startProfile(at = [0, 0])
 | 
			
		||||
///   |> line(end = [10, 0])
 | 
			
		||||
///   |> angledLine(
 | 
			
		||||
///        angle = 60,
 | 
			
		||||
///        length = 10,
 | 
			
		||||
///      )
 | 
			
		||||
///   |> angledLine(
 | 
			
		||||
///        angle = 120,
 | 
			
		||||
///        length = 10,
 | 
			
		||||
///      )
 | 
			
		||||
///   |> line(end = [-10, 0])
 | 
			
		||||
///   |> angledLine(
 | 
			
		||||
///        angle = 240,
 | 
			
		||||
///        length = 10,
 | 
			
		||||
///        tag = $referenceEdge,
 | 
			
		||||
///      )
 | 
			
		||||
///   |> close()
 | 
			
		||||
///
 | 
			
		||||
/// example = extrude(exampleSketch, length = 5)
 | 
			
		||||
///   |> fillet(
 | 
			
		||||
///     radius = 3,
 | 
			
		||||
///     tags = [getOppositeEdge(referenceEdge)],
 | 
			
		||||
///   )
 | 
			
		||||
/// ```
 | 
			
		||||
@(impl = std_rust)
 | 
			
		||||
export fn getOppositeEdge(
 | 
			
		||||
  /// The tag of the edge you want to find the opposite edge of.
 | 
			
		||||
  @edge: tag,
 | 
			
		||||
): Edge {}
 | 
			
		||||
 | 
			
		||||
/// Get the next adjacent edge to the edge given.
 | 
			
		||||
///
 | 
			
		||||
/// ```kcl
 | 
			
		||||
/// exampleSketch = startSketchOn(XZ)
 | 
			
		||||
///   |> startProfile(at = [0, 0])
 | 
			
		||||
///   |> line(end = [10, 0])
 | 
			
		||||
///   |> angledLine(
 | 
			
		||||
///        angle = 60,
 | 
			
		||||
///        length = 10,
 | 
			
		||||
///      )
 | 
			
		||||
///   |> angledLine(
 | 
			
		||||
///        angle = 120,
 | 
			
		||||
///        length = 10,
 | 
			
		||||
///      )
 | 
			
		||||
///   |> line(end = [-10, 0])
 | 
			
		||||
///   |> angledLine(
 | 
			
		||||
///        angle = 240,
 | 
			
		||||
///        length = 10,
 | 
			
		||||
///        tag = $referenceEdge,
 | 
			
		||||
///      )
 | 
			
		||||
///   |> close()
 | 
			
		||||
///
 | 
			
		||||
/// example = extrude(exampleSketch, length = 5)
 | 
			
		||||
///   |> fillet(
 | 
			
		||||
///     radius = 3,
 | 
			
		||||
///     tags = [getNextAdjacentEdge(referenceEdge)],
 | 
			
		||||
///   )
 | 
			
		||||
/// ```
 | 
			
		||||
@(impl = std_rust)
 | 
			
		||||
export fn getNextAdjacentEdge(
 | 
			
		||||
  /// The tag of the edge you want to find the next adjacent edge of.
 | 
			
		||||
  @edge: tag,
 | 
			
		||||
): Edge {}
 | 
			
		||||
 | 
			
		||||
/// Get the previous adjacent edge to the edge given.
 | 
			
		||||
///
 | 
			
		||||
/// ```kcl
 | 
			
		||||
/// exampleSketch = startSketchOn(XZ)
 | 
			
		||||
///   |> startProfile(at = [0, 0])
 | 
			
		||||
///   |> line(end = [10, 0])
 | 
			
		||||
///   |> angledLine(
 | 
			
		||||
///        angle = 60,
 | 
			
		||||
///        length = 10,
 | 
			
		||||
///      )
 | 
			
		||||
///   |> angledLine(
 | 
			
		||||
///        angle = 120,
 | 
			
		||||
///        length = 10,
 | 
			
		||||
///      )
 | 
			
		||||
///   |> line(end = [-10, 0])
 | 
			
		||||
///   |> angledLine(
 | 
			
		||||
///        angle = 240,
 | 
			
		||||
///        length = 10,
 | 
			
		||||
///        tag = $referenceEdge,
 | 
			
		||||
///      )
 | 
			
		||||
///   |> close()
 | 
			
		||||
///
 | 
			
		||||
/// example = extrude(exampleSketch, length = 5)
 | 
			
		||||
///   |> fillet(
 | 
			
		||||
///     radius = 3,
 | 
			
		||||
///     tags = [getPreviousAdjacentEdge(referenceEdge)],
 | 
			
		||||
///   )
 | 
			
		||||
/// ```
 | 
			
		||||
@(impl = std_rust)
 | 
			
		||||
export fn getPreviousAdjacentEdge(
 | 
			
		||||
  /// The tag of the edge you want to find the previous adjacent edge of.
 | 
			
		||||
  @edge: tag,
 | 
			
		||||
): Edge {}
 | 
			
		||||
 | 
			
		||||
/// Get the shared edge between two faces.
 | 
			
		||||
///
 | 
			
		||||
/// ```kcl
 | 
			
		||||
/// // Get an edge shared between two faces, created after a chamfer.
 | 
			
		||||
///
 | 
			
		||||
/// scale = 20
 | 
			
		||||
/// part001 = startSketchOn(XY)
 | 
			
		||||
///     |> startProfile(at = [0, 0])
 | 
			
		||||
///     |> line(end = [0, scale])
 | 
			
		||||
///     |> line(end = [scale, 0])
 | 
			
		||||
///     |> line(end = [0, -scale])
 | 
			
		||||
///     |> close(tag = $line0)
 | 
			
		||||
///     |> extrude(length = 20, tagEnd = $end0)
 | 
			
		||||
///     // We tag the chamfer to reference it later.
 | 
			
		||||
///     |> chamfer(length = 10, tags = [getOppositeEdge(line0)], tag = $chamfer0)
 | 
			
		||||
///
 | 
			
		||||
/// // Get the shared edge between the chamfer and the extrusion.
 | 
			
		||||
/// commonEdge = getCommonEdge(faces = [chamfer0, end0])
 | 
			
		||||
///
 | 
			
		||||
/// // Chamfer the shared edge.
 | 
			
		||||
/// // TODO: uncomment this when ssi for fillets lands
 | 
			
		||||
/// // chamfer(part001, length = 5, tags = [commonEdge])
 | 
			
		||||
/// ```
 | 
			
		||||
@(impl = std_rust)
 | 
			
		||||
export fn getCommonEdge(
 | 
			
		||||
  /// The tags of the faces you want to find the common edge between.
 | 
			
		||||
  faces: [tag; 2],
 | 
			
		||||
): Edge {}
 | 
			
		||||
 | 
			
		||||
| 
		 Before Width: | Height: | Size: 140 KiB After Width: | Height: | Size: 140 KiB  | 
| 
		 Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB  | 
| 
		 Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB  | 
| 
		 Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 65 KiB  | 
@ -6,10 +6,23 @@ KCL Semantic error
 | 
			
		||||
 | 
			
		||||
  × semantic: This function expected the input argument to be tag identifier
 | 
			
		||||
  │ but it's actually of type tag
 | 
			
		||||
    ╭─[43:25]
 | 
			
		||||
    ╭─[43:5]
 | 
			
		||||
 42 │     // these double wrapped functions are the point of this test
 | 
			
		||||
 43 │     getNextAdjacentEdge(getNextAdjacentEdge(seg01)),
 | 
			
		||||
    ·                         ─────────────┬────────────
 | 
			
		||||
    ·                                      ╰── tests/panic_repro_cube/input.kcl
 | 
			
		||||
    ·     ───────────────────────┬───────────────────────┬
 | 
			
		||||
    ·                            │                       ╰── tests/panic_repro_cube/input.kcl
 | 
			
		||||
    ·                            ╰── tests/panic_repro_cube/input.kcl
 | 
			
		||||
 44 │     getNextAdjacentEdge(getNextAdjacentEdge(seg02))
 | 
			
		||||
    ╰────
 | 
			
		||||
  ╰─▶ KCL Semantic error
 | 
			
		||||
      
 | 
			
		||||
        × semantic: This function expected the input argument to be tag
 | 
			
		||||
        │ identifier but it's actually of type tag
 | 
			
		||||
          ╭─[43:25]
 | 
			
		||||
       42 │     // these double wrapped functions are the point of this test
 | 
			
		||||
       43 │     getNextAdjacentEdge(getNextAdjacentEdge(seg01)),
 | 
			
		||||
          ·                         ─────────────┬────────────
 | 
			
		||||
          ·                                      ╰── tests/panic_repro_cube/
 | 
			
		||||
      input.kcl
 | 
			
		||||
       44 │     getNextAdjacentEdge(getNextAdjacentEdge(seg02))
 | 
			
		||||
          ╰────
 | 
			
		||||
 | 
			
		||||