Remove some deprecated functions from std (#6531)

Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
Nick Cameron
2025-04-29 12:24:18 +12:00
committed by GitHub
parent 8867258e47
commit aca5fdb521
60 changed files with 3632 additions and 4759 deletions

View File

@ -9,7 +9,7 @@ The value of `pi`, Archimedes constant (π).
```js
std::math::PI: number = 3.14159265358979323846264338327950288_
std::math::PI: number(_?) = 3.14159265358979323846264338327950288_?
```
### Examples
@ -18,7 +18,7 @@ std::math::PI: number = 3.14159265358979323846264338327950288_
circumference = 70
exampleSketch = startSketchOn(XZ)
|> circle(center = [0, 0], radius = circumference / (2 * PI))
|> circle(center = [0, 0], radius = (circumference / (2 * PI)): number(mm))
example = extrude(exampleSketch, length = 5)
```

View File

@ -178,7 +178,7 @@ t = 0.005 // taper factor [0-1)
// Defines how to modify each layer of the vase.
// Each replica is shifted up the Z axis, and has a smoothly-varying radius
fn transform(replicaId) {
scale = r * abs(1 - (t * replicaId)) * (5 + cos(replicaId / 8: number(rad)))
scale = r * abs(1 - (t * replicaId)) * (5 + cos((replicaId / 8): number(rad)))
return {
translate = [0, 0, replicaId * 10],
scale = [scale, scale, 0]

View File

@ -74095,34 +74095,6 @@
"exampleSketch = startSketchOn(-XZ)\n |> startProfile(at = [0, 0])\n |> line(end = [10, 0])\n |> line(end = [0, 10])\n |> close()\n\nexample = extrude(exampleSketch, length = 10)"
]
},
{
"name": "e",
"summary": "Return the value of Eulers number `e`.",
"description": "**DEPRECATED** use the constant E",
"tags": [
"math"
],
"keywordArguments": false,
"args": [],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": true,
"examples": [
"exampleSketch = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> angledLine(angle = 30, length = 2 * e() ^ 2)\n |> yLine(endAbsolute = 0)\n |> close()\n\nexample = extrude(exampleSketch, length = 10)"
]
},
{
"name": "extrude",
"summary": "Extend a 2-dimensional sketch through a third dimension in order to create new 3-dimensional volume, or if extruded into an existing volume, cut into an existing solid.",
@ -85429,258 +85401,6 @@
"sketch001 = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> line(endAbsolute = [12, 10])\n |> line(end = [floor(7.02986), 0])\n |> yLine(endAbsolute = 0)\n |> close()\n\nextrude001 = extrude(sketch001, length = 5)"
]
},
{
"name": "fromCm",
"summary": "Converts a number from centimeters to the current default unit.",
"description": "*DEPRECATED* prefer using explicit numeric suffixes (e.g., `42cm`) or the `to...` conversion functions.\n\nNo matter what units the current file uses, this function will always return a number equivalent to the input in centimeters.\n\nFor example, if the current file uses inches, `fromCm(1)` will return `0.393701`. If the current file uses millimeters, `fromCm(1)` will return `10`. If the current file uses centimeters, `fromCm(1)` will return `1`.\n\n**Caution**: This function is only intended to be used when you absolutely MUST have different units in your code than the file settings. Otherwise, it is a bad pattern to use this function.\n\nWe merely provide these functions for convenience and readability, as `fromCm(10)` is more readable that your intent is \"I want 10 centimeters\" than `10 * 10`, if the file settings are in millimeters.",
"tags": [
"units"
],
"keywordArguments": false,
"args": [
{
"name": "input",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": true,
"examples": [
"totalWidth = fromCm(10)"
]
},
{
"name": "fromFt",
"summary": "Converts a number from feet to the current default unit.",
"description": "*DEPRECATED* prefer using explicit numeric suffixes (e.g., `42ft`) or the `to...` conversion functions.\n\nNo matter what units the current file uses, this function will always return a number equivalent to the input in feet.\n\nFor example, if the current file uses inches, `fromFt(1)` will return `12`. If the current file uses millimeters, `fromFt(1)` will return `304.8`. If the current file uses feet, `fromFt(1)` will return `1`.\n\n**Caution**: This function is only intended to be used when you absolutely MUST have different units in your code than the file settings. Otherwise, it is a bad pattern to use this function.\n\nWe merely provide these functions for convenience and readability, as `fromFt(10)` is more readable that your intent is \"I want 10 feet\" than `10 * 304.8`, if the file settings are in millimeters.",
"tags": [
"units"
],
"keywordArguments": false,
"args": [
{
"name": "input",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": true,
"examples": [
"totalWidth = fromFt(10)"
]
},
{
"name": "fromInches",
"summary": "Converts a number from inches to the current default unit.",
"description": "*DEPRECATED* prefer using explicit numeric suffixes (e.g., `42inch`) or the `to...` conversion functions.\n\nNo matter what units the current file uses, this function will always return a number equivalent to the input in inches.\n\nFor example, if the current file uses inches, `fromInches(1)` will return `1`. If the current file uses millimeters, `fromInches(1)` will return `25.4`.\n\n**Caution**: This function is only intended to be used when you absolutely MUST have different units in your code than the file settings. Otherwise, it is a bad pattern to use this function.\n\nWe merely provide these functions for convenience and readability, as `fromInches(10)` is more readable that your intent is \"I want 10 inches\" than `10 * 25.4`, if the file settings are in millimeters.",
"tags": [
"units"
],
"keywordArguments": false,
"args": [
{
"name": "input",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": true,
"examples": [
"totalWidth = fromInches(10)"
]
},
{
"name": "fromM",
"summary": "Converts a number from meters to the current default unit.",
"description": "*DEPRECATED* prefer using explicit numeric suffixes (e.g., `42m`) or the `to...` conversion functions.\n\nNo matter what units the current file uses, this function will always return a number equivalent to the input in meters.\n\nFor example, if the current file uses inches, `fromM(1)` will return `39.3701`. If the current file uses millimeters, `fromM(1)` will return `1000`. If the current file uses meters, `fromM(1)` will return `1`.\n\n**Caution**: This function is only intended to be used when you absolutely MUST have different units in your code than the file settings. Otherwise, it is a bad pattern to use this function.\n\nWe merely provide these functions for convenience and readability, as `fromM(10)` is more readable that your intent is \"I want 10 meters\" than `10 * 1000`, if the file settings are in millimeters.",
"tags": [
"units"
],
"keywordArguments": false,
"args": [
{
"name": "input",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": true,
"examples": [
"totalWidth = 10 * fromM(10)"
]
},
{
"name": "fromMm",
"summary": "Converts a number from mm to the current default unit.",
"description": "*DEPRECATED* prefer using explicit numeric suffixes (e.g., `42mm`) or the `to...` conversion functions.\n\nNo matter what units the current file uses, this function will always return a number equivalent to the input in millimeters.\n\nFor example, if the current file uses inches, `fromMm(1)` will return `1/25.4`. If the current file uses millimeters, `fromMm(1)` will return `1`.\n\n**Caution**: This function is only intended to be used when you absolutely MUST have different units in your code than the file settings. Otherwise, it is a bad pattern to use this function.\n\nWe merely provide these functions for convenience and readability, as `fromMm(10)` is more readable that your intent is \"I want 10 millimeters\" than `10 * (1/25.4)`, if the file settings are in inches.",
"tags": [
"units"
],
"keywordArguments": false,
"args": [
{
"name": "input",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": true,
"examples": [
"totalWidth = fromMm(10)"
]
},
{
"name": "fromYd",
"summary": "Converts a number from yards to the current default unit.",
"description": "*DEPRECATED* prefer using explicit numeric suffixes (e.g., `42yd`) or the `to...` conversion functions.\n\nNo matter what units the current file uses, this function will always return a number equivalent to the input in yards.\n\nFor example, if the current file uses inches, `fromYd(1)` will return `36`. If the current file uses millimeters, `fromYd(1)` will return `914.4`. If the current file uses yards, `fromYd(1)` will return `1`.\n\n**Caution**: This function is only intended to be used when you absolutely MUST have different units in your code than the file settings. Otherwise, it is a bad pattern to use this function.\n\nWe merely provide these functions for convenience and readability, as `fromYd(10)` is more readable that your intent is \"I want 10 yards\" than `10 * 914.4`, if the file settings are in millimeters.",
"tags": [
"units"
],
"keywordArguments": false,
"args": [
{
"name": "input",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": true,
"examples": [
"totalWidth = fromYd(10)"
]
},
{
"name": "getCommonEdge",
"summary": "Get the shared edge between two faces.",
@ -85881,48 +85601,6 @@
"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)])"
]
},
{
"name": "int",
"summary": "Convert a number to an integer.",
"description": "DEPRECATED use floor(), ceil(), or round().",
"tags": [
"convert"
],
"keywordArguments": false,
"args": [
{
"name": "num",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": true,
"examples": [
"n = int(ceil(5 / 2))\nassert(n, isEqualTo = 3, error = \"5/2 = 2.5, rounded up makes 3\")\n// Draw n cylinders.\nstartSketchOn(XZ)\n |> circle(center = [0, 0], radius = 2)\n |> extrude(length = 5)\n |> patternTransform(\n instances = n,\n transform = fn(id) {\n return { translate = [4 * id, 0, 0] }\n },\n )"
]
},
{
"name": "intersect",
"summary": "Intersect returns the shared volume between multiple solids, preserving only overlapping regions.",
@ -185998,7 +185676,7 @@
"// Each instance will be shifted along the X axis,\n// with a gap between the original (at x = 0) and the first replica\n// (at x = 8). This is because `id` starts at 1.\nfn transform(id) {\n return { translate = [4 * (1 + id), 0, 0] }\n}\n\nsketch001 = startSketchOn(XZ)\n |> circle(center = [0, 0], radius = 2)\n |> extrude(length = 5)\n |> patternTransform(instances = 4, transform = transform)",
"fn cube(length, center) {\n l = length / 2\n x = center[0]\n y = center[1]\n p0 = [-l + x, -l + y]\n p1 = [-l + x, l + y]\n p2 = [l + x, l + y]\n p3 = [l + x, -l + y]\n\n return startSketchOn(XY)\n |> startProfile(at = p0)\n |> line(endAbsolute = p1)\n |> line(endAbsolute = p2)\n |> line(endAbsolute = p3)\n |> line(endAbsolute = p0)\n |> close()\n |> extrude(length = length)\n}\n\nwidth = 20\nfn transform(i) {\n return {\n // Move down each time.\n translate = [0, 0, -i * width],\n // Make the cube longer, wider and flatter each time.\n scale = [\n pow(1.1, exp = i),\n pow(1.1, exp = i),\n pow(0.9, exp = i)\n ],\n // Turn by 15 degrees each time.\n rotation = { angle = 15 * i, origin = \"local\" }\n }\n}\n\nmyCubes = cube(width, [100, 0])\n |> patternTransform(instances = 25, transform = transform)",
"fn cube(length, center) {\n l = length / 2\n x = center[0]\n y = center[1]\n p0 = [-l + x, -l + y]\n p1 = [-l + x, l + y]\n p2 = [l + x, l + y]\n p3 = [l + x, -l + y]\n\n return startSketchOn(XY)\n |> startProfile(at = p0)\n |> line(endAbsolute = p1)\n |> line(endAbsolute = p2)\n |> line(endAbsolute = p3)\n |> line(endAbsolute = p0)\n |> close()\n |> extrude(length = length)\n}\n\nwidth = 20\nfn transform(i) {\n return {\n translate = [0, 0, -i * width],\n rotation = {\n angle = 90 * i,\n // Rotate around the overall scene's origin.\n origin = \"global\"\n }\n }\n}\nmyCubes = cube(width, [100, 100])\n |> patternTransform(instances = 4, transform = transform)",
"// Parameters\nr = 50 // base radius\nh = 10 // layer height\nt = 0.005 // taper factor [0-1)\n// Defines how to modify each layer of the vase.\n// Each replica is shifted up the Z axis, and has a smoothly-varying radius\nfn transform(replicaId) {\n scale = r * abs(1 - (t * replicaId)) * (5 + cos(replicaId / 8: number(rad)))\n return {\n translate = [0, 0, replicaId * 10],\n scale = [scale, scale, 0]\n }\n}\n// Each layer is just a pretty thin cylinder.\nfn layer() {\n return startSketchOn(XY)\n // or some other plane idk\n |> circle(center = [0, 0], radius = 1, tag = $tag1)\n |> extrude(length = h)\n}\n// The vase is 100 layers tall.\n// The 100 layers are replica of each other, with a slight transformation applied to each.\nvase = layer()\n |> patternTransform(instances = 100, transform = transform)",
"// Parameters\nr = 50 // base radius\nh = 10 // layer height\nt = 0.005 // taper factor [0-1)\n// Defines how to modify each layer of the vase.\n// Each replica is shifted up the Z axis, and has a smoothly-varying radius\nfn transform(replicaId) {\n scale = r * abs(1 - (t * replicaId)) * (5 + cos((replicaId / 8): number(rad)))\n return {\n translate = [0, 0, replicaId * 10],\n scale = [scale, scale, 0]\n }\n}\n// Each layer is just a pretty thin cylinder.\nfn layer() {\n return startSketchOn(XY)\n // or some other plane idk\n |> circle(center = [0, 0], radius = 1, tag = $tag1)\n |> extrude(length = h)\n}\n// The vase is 100 layers tall.\n// The 100 layers are replica of each other, with a slight transformation applied to each.\nvase = layer()\n |> patternTransform(instances = 100, transform = transform)",
"fn transform(i) {\n // Transform functions can return multiple transforms. They'll be applied in order.\n return [\n { translate = [30 * i, 0, 0] },\n { rotation = { angle = 45 * i } }\n ]\n}\nstartSketchOn(XY)\n |> startProfile(at = [0, 0])\n |> polygon(\n radius = 10,\n numSides = 4,\n center = [0, 0],\n inscribed = false,\n )\n |> extrude(length = 4)\n |> patternTransform(instances = 3, transform = transform)"
]
},
@ -194043,34 +193721,6 @@
"// Each instance will be shifted along the X axis.\nfn transform(id) {\n return { translate = [4 * id, 0] }\n}\n\n// Sketch 4 circles.\nsketch001 = startSketchOn(XZ)\n |> circle(center = [0, 0], radius = 2)\n |> patternTransform2d(instances = 4, transform = transform)"
]
},
{
"name": "pi",
"summary": "Return the value of `pi`. Archimedes constant (π).",
"description": "**DEPRECATED** use the constant PI",
"tags": [
"math"
],
"keywordArguments": false,
"args": [],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": true,
"examples": [
"circumference = 70\n\nexampleSketch = startSketchOn(XZ)\n |> circle(center = [0, 0], radius = circumference / (2 * pi()))\n\nexample = extrude(exampleSketch, length = 5)"
]
},
{
"name": "polygon",
"summary": "Create a regular polygon with the specified number of sides that is either inscribed or circumscribed around a circle of the specified radius.",
@ -302826,34 +302476,6 @@
"exampleSketch = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> angledLine(angle = 60, length = 10)\n |> tangentialArc(radius = 10, angle = -120)\n |> angledLine(angle = -60, length = 10)\n |> close()\n\nexample = extrude(exampleSketch, length = 10)"
]
},
{
"name": "tau",
"summary": "Return the value of `tau`. The full circle constant (τ). Equal to 2π.",
"description": "**DEPRECATED** use the constant TAU",
"tags": [
"math"
],
"keywordArguments": false,
"args": [],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": true,
"examples": [
"exampleSketch = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> angledLine(angle = 50, length = 10 * tau())\n |> yLine(endAbsolute = 0)\n |> close()\n\nexample = extrude(exampleSketch, length = 5)"
]
},
{
"name": "translate",
"summary": "Move a solid or a sketch.",

View File

@ -32,7 +32,7 @@ lugClearance = startSketchOn(lugExtrusion, face = END)
// Create the circular pattern for the lug holes
lugHoles = startSketchOn(lugBase, face = END)
|> circle(center = [lugSpacing / 2, 0], radius = fromMm(16) / 2)
|> circle(center = [lugSpacing / 2, 0], radius = 16mm / 2)
|> patternCircular2d(
arcDegrees = 360,
center = [0, 0],

View File

@ -8,11 +8,7 @@
import lugDiameter, lugHeadLength, lugThreadDiameter, lugLength, lugThreadDepth, lugSpacing from "parameters.kcl"
customPlane = {
origin = {
x = lugSpacing / 2,
y = fromMm(-30),
z = 0
},
origin = { x = lugSpacing / 2, y = -30mm, z = 0 },
xAxis = { x = 1, y = 0, z = 0 },
yAxis = { x = 0, y = -1, z = 0 },
zAxis = { x = 0, y = 0, z = 1 }
@ -24,7 +20,7 @@ fn lug(plane, length, diameter) {
|> angledLine(angle = 70, lengthY = lugHeadLength)
|> xLine(endAbsolute = lugDiameter / 2)
|> yLine(endAbsolute = lugLength)
|> tangentialArc(angle = 90, radius = fromMm(3))
|> tangentialArc(angle = 90, radius = 3mm)
|> xLine(endAbsolute = 0 + .001, tag = $c1)
|> yLine(endAbsolute = lugThreadDepth)
|> xLine(endAbsolute = lugThreadDiameter)

View File

@ -5,8 +5,8 @@
// Car wheel
export lugCount = 5
export lugSpacing = fromMm(114.3)
export offset = fromMm(-35)
export lugSpacing = 114.3mm
export offset = -35mm
export backSpacing = 6.38
export wheelWidth = 9.5
export wheelDiameter = 19
@ -16,11 +16,11 @@ export spokeAngle = 0.02
export spokeThickness = 0.95
// Lug Nut
export lugDiameter = fromMm(24)
export lugDiameter = 24mm
export lugHeadLength = lugDiameter * .5
export lugThreadDiameter = lugDiameter / 2 * .85
export lugLength = fromMm(30)
export lugThreadDepth = lugLength - fromMm(12.7)
export lugLength = 30mm
export lugThreadDepth = lugLength - 12.7mm
// Car rotor
export rotorDiameter = 12

View File

@ -5,7 +5,7 @@
@settings(defaultLengthUnit = in)
// Define parameters
beamLength = fromFt(6)
beamLength = 6ft
beamHeight = 4
flangeWidth = 2.663
flangeThickness = 0.293

View File

@ -6,7 +6,7 @@
// Define parameters
routerDiameter = 12.7
templateDiameter = fromInches(11 / 16)
templateDiameter = (11 / 16): number(in)
slateWidthHalf = 41.5 / 2
minClampingDistance = 50 + 30
templateThickness = 10

View File

@ -6,7 +6,7 @@
// Define parameters
routerDiameter = 12.7
templateDiameter = fromInches(11 / 16)
templateDiameter = (11 / 16): number(in)
slateWidthHalf = 41.5 / 2
minClampingDistance = 50 + 30
templateThickness = 10

View File

@ -25,8 +25,6 @@ fn Gte = (a, b) => { return Not(Lt(a, b)) }
// Note: it was most concise to encode productions directly in axioms.
// Change them as you need.
deg = pi()*2 / 360
fn setSketch = (state, q) => {
return {
depthMax: state.depthMax,
@ -77,8 +75,8 @@ fn setLength = (state, q) => {
fn Gt2 = (state) => { return setLength(state, state.currentLength * state.factor) }
fn Lt2 = (state) => { return setLength(state, state.currentLength / state.factor) }
fn Add = (state) => { return setAngle(state, rem(int(state.currentAngle - state.angle), divisor = 360)) }
fn Sub = (state) => { return setAngle(state, rem(int(state.currentAngle + state.angle), divisor = 360)) }
fn Add = (state) => { return setAngle(state, rem(state.currentAngle - state.angle, divisor = 360)) }
fn Sub = (state) => { return setAngle(state, rem(state.currentAngle + state.angle, divisor = 360)) }
// Only necessary to get around recursion limitations...
fn F = (state, F) => {

View File

@ -1047,7 +1047,7 @@ mod test {
if let DocData::Const(d) = d {
if d.name == "PI" {
assert!(d.value.unwrap().starts_with('3'));
assert_eq!(d.ty, Some("number".to_owned()));
assert_eq!(d.ty, Some("number(_?)".to_owned()));
assert_eq!(d.qual_name, "std::math::PI");
assert!(d.summary.is_some());
assert!(!d.examples.is_empty());

View File

@ -1041,12 +1041,12 @@ impl Node<BinaryExpression> {
let value = match self.operator {
BinaryOperator::Add => {
let (l, r, ty) = NumericType::combine_eq(left, right);
let (l, r, ty) = NumericType::combine_eq_coerce(left, right);
self.warn_on_unknown(&ty, "Adding", exec_state);
KclValue::Number { value: l + r, meta, ty }
}
BinaryOperator::Sub => {
let (l, r, ty) = NumericType::combine_eq(left, right);
let (l, r, ty) = NumericType::combine_eq_coerce(left, right);
self.warn_on_unknown(&ty, "Subtracting", exec_state);
KclValue::Number { value: l - r, meta, ty }
}

View File

@ -19,6 +19,8 @@ use crate::{
CompilationError, KclError, ModuleId, SourceRange,
};
use super::types::UnitType;
pub type KclObjectFields = HashMap<String, KclValue>;
/// Any KCL value.
@ -299,6 +301,18 @@ impl KclValue {
KclValue::Plane { .. } => "Plane",
KclValue::Face { .. } => "Face",
KclValue::Bool { .. } => "boolean (true/false value)",
KclValue::Number {
ty: NumericType::Unknown,
..
} => "number(unknown units)",
KclValue::Number {
ty: NumericType::Known(UnitType::Length(_)),
..
} => "number(Length)",
KclValue::Number {
ty: NumericType::Known(UnitType::Angle(_)),
..
} => "number(Angle)",
KclValue::Number { .. } => "number",
KclValue::String { .. } => "string (text)",
KclValue::MixedArray { .. } => "array (list)",

View File

@ -1295,20 +1295,6 @@ mod tests {
);
}
#[tokio::test(flavor = "multi_thread")]
async fn test_warn_on_deprecated() {
let text = "p = pi()";
let result = parse_execute(text).await.unwrap();
let errs = result.exec_state.errors();
assert_eq!(errs.len(), 1);
assert_eq!(errs[0].severity, crate::errors::Severity::Warning);
assert!(
errs[0].message.contains("`pi` is deprecated"),
"unexpected warning message: {}",
errs[0].message
);
}
#[tokio::test(flavor = "multi_thread")]
async fn test_execute_fn_definitions() {
let ast = r#"fn def = (x) => {
@ -1777,67 +1763,6 @@ let shape = layer() |> patternTransform(instances = 10, transform = transform)
);
}
#[tokio::test(flavor = "multi_thread")]
async fn test_unit_default() {
let ast = r#"const inMm = fromMm(25.4)
const inInches = fromInches(1)"#;
let result = parse_execute(ast).await.unwrap();
assert_eq!(
25.4,
mem_get_json(result.exec_state.stack(), result.mem_env, "inMm")
.as_f64()
.unwrap()
);
assert_eq!(
25.4,
mem_get_json(result.exec_state.stack(), result.mem_env, "inInches")
.as_f64()
.unwrap()
);
}
#[tokio::test(flavor = "multi_thread")]
async fn test_unit_overriden() {
let ast = r#"@settings(defaultLengthUnit = inch)
const inMm = fromMm(25.4)
const inInches = fromInches(1)"#;
let result = parse_execute(ast).await.unwrap();
assert_eq!(
1.0,
mem_get_json(result.exec_state.stack(), result.mem_env, "inMm")
.as_f64()
.unwrap()
.round()
);
assert_eq!(
1.0,
mem_get_json(result.exec_state.stack(), result.mem_env, "inInches")
.as_f64()
.unwrap()
);
}
#[tokio::test(flavor = "multi_thread")]
async fn test_unit_overriden_in() {
let ast = r#"@settings(defaultLengthUnit = in)
const inMm = fromMm(25.4)
const inInches = fromInches(2)"#;
let result = parse_execute(ast).await.unwrap();
assert_eq!(
1.0,
mem_get_json(result.exec_state.stack(), result.mem_env, "inMm")
.as_f64()
.unwrap()
.round()
);
assert_eq!(
2.0,
mem_get_json(result.exec_state.stack(), result.mem_env, "inInches")
.as_f64()
.unwrap()
);
}
#[tokio::test(flavor = "multi_thread")]
async fn test_zero_param_fn() {
let ast = r#"const sigmaAllow = 35000 // psi

View File

@ -381,7 +381,8 @@ impl fmt::Display for PrimitiveType {
match self {
PrimitiveType::Number(NumericType::Known(unit)) => write!(f, "number({unit})"),
PrimitiveType::Number(NumericType::Unknown) => write!(f, "number(unknown units)"),
PrimitiveType::Number(_) => write!(f, "number"),
PrimitiveType::Number(NumericType::Default { .. }) => write!(f, "number(default units)"),
PrimitiveType::Number(NumericType::Any) => write!(f, "number(any units)"),
PrimitiveType::String => write!(f, "string"),
PrimitiveType::Boolean => write!(f, "bool"),
PrimitiveType::Tag => write!(f, "tag"),
@ -455,7 +456,7 @@ impl NumericType {
/// Combine two types when we expect them to be equal, erring on the side of less coercion. To be
/// precise, only adjusting one number or the other when they are of known types.
///
/// This combinator function is suitable for comparisons or arithmetic where uncertainty should
/// This combinator function is suitable for comparisons where uncertainty should
/// be handled by the user.
pub fn combine_eq(a: TyF64, b: TyF64) -> (f64, f64, NumericType) {
use NumericType::*;
@ -525,7 +526,9 @@ impl NumericType {
continue;
}
// The cases where we check the values for 0.0 are so we don't crash out where a conversion would always be safe
match (&ty, &i.ty) {
(Any, Default { .. }) if i.n == 0.0 => {}
(Any, t) => {
ty = t.clone();
}
@ -535,8 +538,8 @@ impl NumericType {
ty = Known(UnitType::Count);
}
(Known(UnitType::Length(l1)), Default { len: l2, .. }) if l1 == l2 => {}
(Known(UnitType::Angle(a1)), Default { angle: a2, .. }) if a1 == a2 => {}
(Known(UnitType::Length(l1)), Default { len: l2, .. }) if l1 == l2 || i.n == 0.0 => {}
(Known(UnitType::Angle(a1)), Default { angle: a2, .. }) if a1 == a2 || i.n == 0.0 => {}
(Default { len: l1, .. }, Known(UnitType::Length(l2))) if l1 == l2 => {
ty = Known(UnitType::Length(*l2));
@ -549,6 +552,10 @@ impl NumericType {
}
}
if ty == Any && !input.is_empty() {
ty = input[0].ty.clone();
}
(result, ty)
}
@ -597,6 +604,7 @@ impl NumericType {
NumericSuffix::Yd => NumericType::Known(UnitType::Length(UnitLen::Yards)),
NumericSuffix::Deg => NumericType::Known(UnitType::Angle(UnitAngle::Degrees)),
NumericSuffix::Rad => NumericType::Known(UnitType::Angle(UnitAngle::Radians)),
NumericSuffix::Unknown => NumericType::Unknown,
}
}

View File

@ -950,7 +950,7 @@ startSketchOn(XY)
match hover.unwrap().contents {
tower_lsp::lsp_types::HoverContents::Markup(tower_lsp::lsp_types::MarkupContent { value, .. }) => {
assert!(value.contains("foo: number = 42"));
assert!(value.contains("foo: number(default units) = 42"));
}
_ => unreachable!(),
}
@ -3480,7 +3480,7 @@ startSketchOn(XY)
match hover.unwrap().contents {
tower_lsp::lsp_types::HoverContents::Markup(tower_lsp::lsp_types::MarkupContent { value, .. }) => {
assert!(value.contains("foo: number = 42"));
assert!(value.contains("foo: number(default units) = 42"));
}
_ => unreachable!(),
}

View File

@ -27,7 +27,7 @@ mod tokeniser;
pub(crate) use tokeniser::RESERVED_WORDS;
// Note the ordering, it's important that `m` comes after `mm` and `cm`.
pub const NUM_SUFFIXES: [&str; 9] = ["mm", "cm", "m", "inch", "in", "ft", "yd", "deg", "rad"];
pub const NUM_SUFFIXES: [&str; 10] = ["mm", "cm", "m", "inch", "in", "ft", "yd", "deg", "rad", "?"];
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, ts_rs::TS, JsonSchema)]
#[repr(u32)]
@ -44,6 +44,7 @@ pub enum NumericSuffix {
Yd,
Deg,
Rad,
Unknown,
}
impl NumericSuffix {
@ -60,6 +61,7 @@ impl NumericSuffix {
match self {
NumericSuffix::None => &[],
NumericSuffix::Count => b"_",
NumericSuffix::Unknown => b"?",
NumericSuffix::Length => b"Length",
NumericSuffix::Angle => b"Angle",
NumericSuffix::Mm => b"mm",
@ -90,6 +92,7 @@ impl FromStr for NumericSuffix {
"yd" | "yards" => Ok(NumericSuffix::Yd),
"deg" | "degrees" => Ok(NumericSuffix::Deg),
"rad" | "radians" => Ok(NumericSuffix::Rad),
"?" => Ok(NumericSuffix::Unknown),
_ => Err(CompilationError::err(SourceRange::default(), "invalid unit of measure")),
}
}
@ -100,6 +103,7 @@ impl fmt::Display for NumericSuffix {
match self {
NumericSuffix::None => Ok(()),
NumericSuffix::Count => write!(f, "_"),
NumericSuffix::Unknown => write!(f, "_?"),
NumericSuffix::Length => write!(f, "Length"),
NumericSuffix::Angle => write!(f, "Angle"),
NumericSuffix::Mm => write!(f, "mm"),

View File

@ -419,7 +419,7 @@ mod tests {
("1.1 abv", true),
("1", false),
(".1", false),
("5?", true),
("5!", true),
("5 + 6", true),
("5 + a", true),
("5.5", false),
@ -429,7 +429,7 @@ mod tests {
assert_eq!(expected, remaining, "`{valid}` expected another token to be {expected}");
}
for invalid in ["a", "?", "?5"] {
for invalid in ["a", "!", "!5"] {
assert_parse_err(number, invalid);
}

View File

@ -571,33 +571,6 @@ impl Args {
)
}
pub(crate) fn get_number_with_type(&self) -> Result<TyF64, KclError> {
FromArgs::from_args(self, 0)
}
pub(crate) fn get_number_typed(&self, ty: &RuntimeType, exec_state: &mut ExecState) -> Result<f64, KclError> {
let Some(arg) = self.args.first() else {
return Err(KclError::Semantic(KclErrorDetails {
message: "Expected an argument".to_owned(),
source_ranges: vec![self.source_range],
}));
};
arg.value.coerce(ty, exec_state).map_err(|_| {
let actual_type_name = arg.value.human_friendly_type();
let message = format!(
"This function expected the input argument to be {} but it's actually of type {actual_type_name}",
ty.human_friendly_type(),
);
KclError::Semantic(KclErrorDetails {
source_ranges: arg.source_ranges(),
message,
})
})?;
Ok(TyF64::from_kcl_val(&arg.value).unwrap().n)
}
pub(crate) async fn get_adjacent_face_to_tag(
&self,
exec_state: &mut ExecState,
@ -975,6 +948,7 @@ impl<'a> FromKclValue<'a> for crate::execution::Point3d {
let_field_of!(obj, x, TyF64);
let_field_of!(obj, y, TyF64);
let_field_of!(obj, z, TyF64);
// TODO here and below we could use coercing combination.
let (a, ty) = NumericType::combine_eq_array(&[x, y, z]);
return Some(Self {
x: a[0],

View File

@ -1,41 +0,0 @@
//! Conversions between types.
use kcl_derive_docs::stdlib;
use crate::{
errors::KclError,
execution::{ExecState, KclValue},
std::Args,
};
/// Converts a number to integer.
pub async fn int(_exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let num = args.get_number_with_type()?;
let converted = inner_int(num.n)?;
Ok(args.make_user_val_from_f64_with_type(num.map_value(converted)))
}
/// Convert a number to an integer.
///
/// DEPRECATED use floor(), ceil(), or round().
///
/// ```no_run
/// n = int(ceil(5/2))
/// assert(n, isEqualTo = 3, error = "5/2 = 2.5, rounded up makes 3")
/// // Draw n cylinders.
/// startSketchOn('XZ')
/// |> circle(center = [0, 0], radius = 2 )
/// |> extrude(length = 5)
/// |> patternTransform(instances = n, transform = fn(id) {
/// return { translate = [4 * id, 0, 0] }
/// })
/// ```
#[stdlib {
name = "int",
tags = ["convert"],
deprecated = true,
}]
fn inner_int(num: f64) -> Result<f64, KclError> {
Ok(num)
}

View File

@ -117,34 +117,6 @@ pub async fn tan(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kcl
Ok(args.make_user_val_from_f64_with_type(TyF64::count(num.tan())))
}
/// Return the value of `pi`. Archimedes constant (π).
pub async fn pi(_exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let result = inner_pi()?;
Ok(args.make_user_val_from_f64_with_type(TyF64::count(result)))
}
/// Return the value of `pi`. Archimedes constant (π).
///
/// **DEPRECATED** use the constant PI
///
/// ```no_run
/// circumference = 70
///
/// exampleSketch = startSketchOn("XZ")
/// |> circle( center = [0, 0], radius = circumference/ (2 * pi()) )
///
/// example = extrude(exampleSketch, length = 5)
/// ```
#[stdlib {
name = "pi",
tags = ["math"],
deprecated = true,
}]
fn inner_pi() -> Result<f64, KclError> {
Ok(std::f64::consts::PI)
}
/// Compute the square root of a number.
pub async fn sqrt(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input: TyF64 = args.get_unlabeled_kw_arg_typed("input", &RuntimeType::num_any(), exec_state)?;
@ -747,70 +719,6 @@ fn inner_ln(input: f64) -> f64 {
input.ln()
}
/// Return the value of Eulers number `e`.
pub async fn e(_exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let result = inner_e()?;
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, NumericType::count())))
}
/// Return the value of Eulers number `e`.
///
/// **DEPRECATED** use the constant E
///
/// ```no_run
/// exampleSketch = startSketchOn("XZ")
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = 30,
/// length = 2 * e() ^ 2,
/// )
/// |> yLine(endAbsolute = 0)
/// |> close()
///
/// example = extrude(exampleSketch, length = 10)
/// ```
#[stdlib {
name = "e",
tags = ["math"],
deprecated = true,
}]
fn inner_e() -> Result<f64, KclError> {
Ok(std::f64::consts::E)
}
/// Return the value of `tau`. The full circle constant (τ). Equal to 2π.
pub async fn tau(_exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let result = inner_tau()?;
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, NumericType::count())))
}
/// Return the value of `tau`. The full circle constant (τ). Equal to 2π.
///
/// **DEPRECATED** use the constant TAU
///
/// ```no_run
/// exampleSketch = startSketchOn("XZ")
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = 50,
/// length = 10 * tau(),
/// )
/// |> yLine(endAbsolute = 0)
/// |> close()
///
/// example = extrude(exampleSketch, length = 5)
/// ```
#[stdlib {
name = "tau",
tags = ["math"],
deprecated = true,
}]
fn inner_tau() -> Result<f64, KclError> {
Ok(std::f64::consts::TAU)
}
#[cfg(test)]
mod tests {
use pretty_assertions::assert_eq;

View File

@ -7,7 +7,6 @@ pub mod assert;
pub mod axis_or_reference;
pub mod chamfer;
pub mod clone;
pub mod convert;
pub mod csg;
pub mod edge;
pub mod extrude;
@ -25,7 +24,6 @@ pub mod shell;
pub mod sketch;
pub mod sweep;
pub mod transform;
pub mod units;
pub mod utils;
use anyhow::Result;
@ -59,7 +57,6 @@ lazy_static! {
Box::new(LegAngX),
Box::new(LegAngY),
Box::new(crate::std::appearance::Appearance),
Box::new(crate::std::convert::Int),
Box::new(crate::std::extrude::Extrude),
Box::new(crate::std::segment::SegEnd),
Box::new(crate::std::segment::SegEndX),
@ -111,9 +108,6 @@ lazy_static! {
Box::new(crate::std::math::Asin),
Box::new(crate::std::math::Atan),
Box::new(crate::std::math::Atan2),
Box::new(crate::std::math::Pi),
Box::new(crate::std::math::E),
Box::new(crate::std::math::Tau),
Box::new(crate::std::math::Sqrt),
Box::new(crate::std::math::Abs),
Box::new(crate::std::math::Rem),
@ -127,12 +121,6 @@ lazy_static! {
Box::new(crate::std::math::Log2),
Box::new(crate::std::math::Log10),
Box::new(crate::std::math::Ln),
Box::new(crate::std::units::FromMm),
Box::new(crate::std::units::FromInches),
Box::new(crate::std::units::FromFt),
Box::new(crate::std::units::FromM),
Box::new(crate::std::units::FromCm),
Box::new(crate::std::units::FromYd),
Box::new(crate::std::assert::Assert),
Box::new(crate::std::assert::AssertIs),
Box::new(crate::std::transform::Scale),

View File

@ -1177,6 +1177,12 @@ async fn inner_start_sketch_on(
}
SketchData::Plane(plane) => {
if plane.value == crate::exec::PlaneType::Uninit {
if plane.origin.units == UnitLen::Unknown {
return Err(KclError::Semantic(KclErrorDetails {
message: "Origin of plane has unknown units".to_string(),
source_ranges: vec![args.source_range],
}));
}
let plane = make_sketch_plane_from_orientation(plane.into_plane_data(), exec_state, args).await?;
Ok(SketchSurface::Plane(plane))
} else {
@ -1272,7 +1278,7 @@ async fn make_sketch_plane_from_orientation(
pub async fn start_profile(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
// let (start, sketch_surface, tag) = args.get_data_and_sketch_surface()?;
let sketch_surface = args.get_unlabeled_kw_arg("startProfileOn")?;
let start: [TyF64; 2] = args.get_kw_arg("at")?;
let start: [TyF64; 2] = args.get_kw_arg_typed("at", &RuntimeType::point2d(), exec_state)?;
let tag = args.get_kw_arg_opt(NEW_TAG_KW)?;
let sketch = inner_start_profile(sketch_surface, start, tag, exec_state, args).await?;

View File

@ -1,311 +0,0 @@
//! Functions related to unitsematics.
use anyhow::Result;
use kcl_derive_docs::stdlib;
use crate::{
errors::KclError,
execution::{
types::{RuntimeType, UnitLen},
ExecState, KclValue,
},
std::{args::TyF64, Args},
};
/// Millimeters conversion factor for current files units.
pub async fn from_mm(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input = args.get_number_typed(&RuntimeType::known_length(UnitLen::Mm), exec_state)?;
let result = inner_from_mm(input, exec_state)?;
Ok(args.make_user_val_from_f64_with_type(TyF64::new(
result,
exec_state.current_default_units().expect_default_length(),
)))
}
/// Converts a number from mm to the current default unit.
///
/// *DEPRECATED* prefer using explicit numeric suffixes (e.g., `42mm`) or the `to...` conversion functions.
///
/// No matter what units the current file uses, this function will always return a number equivalent
/// to the input in millimeters.
///
/// For example, if the current file uses inches, `fromMm(1)` will return `1/25.4`.
/// If the current file uses millimeters, `fromMm(1)` will return `1`.
///
/// **Caution**: This function is only intended to be used when you absolutely MUST
/// have different units in your code than the file settings. Otherwise, it is
/// a bad pattern to use this function.
///
/// We merely provide these functions for convenience and readability, as
/// `fromMm(10)` is more readable that your intent is "I want 10 millimeters" than
/// `10 * (1/25.4)`, if the file settings are in inches.
///
/// ```no_run
/// totalWidth = fromMm(10)
/// ```
#[stdlib {
name = "fromMm",
tags = ["units"],
deprecated = true,
}]
fn inner_from_mm(input: f64, exec_state: &ExecState) -> Result<f64, KclError> {
Ok(match exec_state.length_unit() {
UnitLen::Mm => input,
UnitLen::Inches => measurements::Length::from_millimeters(input).as_inches(),
UnitLen::Feet => measurements::Length::from_millimeters(input).as_feet(),
UnitLen::M => measurements::Length::from_millimeters(input).as_meters(),
UnitLen::Cm => measurements::Length::from_millimeters(input).as_centimeters(),
UnitLen::Yards => measurements::Length::from_millimeters(input).as_yards(),
UnitLen::Unknown => unreachable!(),
})
}
/// Inches conversion factor for current files units.
pub async fn from_inches(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input = args.get_number_typed(&RuntimeType::known_length(UnitLen::Inches), exec_state)?;
let result = inner_from_inches(input, exec_state)?;
Ok(args.make_user_val_from_f64_with_type(TyF64::new(
result,
exec_state.current_default_units().expect_default_length(),
)))
}
/// Converts a number from inches to the current default unit.
///
/// *DEPRECATED* prefer using explicit numeric suffixes (e.g., `42inch`) or the `to...` conversion functions.
///
/// No matter what units the current file uses, this function will always return a number equivalent
/// to the input in inches.
///
/// For example, if the current file uses inches, `fromInches(1)` will return `1`.
/// If the current file uses millimeters, `fromInches(1)` will return `25.4`.
///
/// **Caution**: This function is only intended to be used when you absolutely MUST
/// have different units in your code than the file settings. Otherwise, it is
/// a bad pattern to use this function.
///
/// We merely provide these functions for convenience and readability, as
/// `fromInches(10)` is more readable that your intent is "I want 10 inches" than
/// `10 * 25.4`, if the file settings are in millimeters.
///
/// ```no_run
/// totalWidth = fromInches(10)
/// ```
#[stdlib {
name = "fromInches",
tags = ["units"],
deprecated = true,
}]
fn inner_from_inches(input: f64, exec_state: &ExecState) -> Result<f64, KclError> {
match exec_state.length_unit() {
UnitLen::Mm => Ok(measurements::Length::from_inches(input).as_millimeters()),
UnitLen::Inches => Ok(input),
UnitLen::Feet => Ok(measurements::Length::from_inches(input).as_feet()),
UnitLen::M => Ok(measurements::Length::from_inches(input).as_meters()),
UnitLen::Cm => Ok(measurements::Length::from_inches(input).as_centimeters()),
UnitLen::Yards => Ok(measurements::Length::from_inches(input).as_yards()),
UnitLen::Unknown => unreachable!(),
}
}
/// Feet conversion factor for current files units.
pub async fn from_ft(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input = args.get_number_typed(&RuntimeType::known_length(UnitLen::Feet), exec_state)?;
let result = inner_from_ft(input, exec_state)?;
Ok(args.make_user_val_from_f64_with_type(TyF64::new(
result,
exec_state.current_default_units().expect_default_length(),
)))
}
/// Converts a number from feet to the current default unit.
///
/// *DEPRECATED* prefer using explicit numeric suffixes (e.g., `42ft`) or the `to...` conversion functions.
///
/// No matter what units the current file uses, this function will always return a number equivalent
/// to the input in feet.
///
/// For example, if the current file uses inches, `fromFt(1)` will return `12`.
/// If the current file uses millimeters, `fromFt(1)` will return `304.8`.
/// If the current file uses feet, `fromFt(1)` will return `1`.
///
/// **Caution**: This function is only intended to be used when you absolutely MUST
/// have different units in your code than the file settings. Otherwise, it is
/// a bad pattern to use this function.
///
/// We merely provide these functions for convenience and readability, as
/// `fromFt(10)` is more readable that your intent is "I want 10 feet" than
/// `10 * 304.8`, if the file settings are in millimeters.
///
/// ```no_run
/// totalWidth = fromFt(10)
/// ```
#[stdlib {
name = "fromFt",
tags = ["units"],
deprecated = true,
}]
fn inner_from_ft(input: f64, exec_state: &ExecState) -> Result<f64, KclError> {
match exec_state.length_unit() {
UnitLen::Mm => Ok(measurements::Length::from_feet(input).as_millimeters()),
UnitLen::Inches => Ok(measurements::Length::from_feet(input).as_inches()),
UnitLen::Feet => Ok(input),
UnitLen::M => Ok(measurements::Length::from_feet(input).as_meters()),
UnitLen::Cm => Ok(measurements::Length::from_feet(input).as_centimeters()),
UnitLen::Yards => Ok(measurements::Length::from_feet(input).as_yards()),
UnitLen::Unknown => unreachable!(),
}
}
/// Meters conversion factor for current files units.
pub async fn from_m(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input = args.get_number_typed(&RuntimeType::known_length(UnitLen::M), exec_state)?;
let result = inner_from_m(input, exec_state)?;
Ok(args.make_user_val_from_f64_with_type(TyF64::new(
result,
exec_state.current_default_units().expect_default_length(),
)))
}
/// Converts a number from meters to the current default unit.
///
/// *DEPRECATED* prefer using explicit numeric suffixes (e.g., `42m`) or the `to...` conversion functions.
///
/// No matter what units the current file uses, this function will always return a number equivalent
/// to the input in meters.
///
/// For example, if the current file uses inches, `fromM(1)` will return `39.3701`.
/// If the current file uses millimeters, `fromM(1)` will return `1000`.
/// If the current file uses meters, `fromM(1)` will return `1`.
///
/// **Caution**: This function is only intended to be used when you absolutely MUST
/// have different units in your code than the file settings. Otherwise, it is
/// a bad pattern to use this function.
///
/// We merely provide these functions for convenience and readability, as
/// `fromM(10)` is more readable that your intent is "I want 10 meters" than
/// `10 * 1000`, if the file settings are in millimeters.
///
/// ```no_run
/// totalWidth = 10 * fromM(10)
/// ```
#[stdlib {
name = "fromM",
tags = ["units"],
deprecated = true,
}]
fn inner_from_m(input: f64, exec_state: &ExecState) -> Result<f64, KclError> {
match exec_state.length_unit() {
UnitLen::Mm => Ok(measurements::Length::from_meters(input).as_millimeters()),
UnitLen::Inches => Ok(measurements::Length::from_meters(input).as_inches()),
UnitLen::Feet => Ok(measurements::Length::from_meters(input).as_feet()),
UnitLen::M => Ok(input),
UnitLen::Cm => Ok(measurements::Length::from_meters(input).as_centimeters()),
UnitLen::Yards => Ok(measurements::Length::from_meters(input).as_yards()),
UnitLen::Unknown => unreachable!(),
}
}
/// Centimeters conversion factor for current files units.
pub async fn from_cm(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input = args.get_number_typed(&RuntimeType::known_length(UnitLen::Cm), exec_state)?;
let result = inner_from_cm(input, exec_state)?;
Ok(args.make_user_val_from_f64_with_type(TyF64::new(
result,
exec_state.current_default_units().expect_default_length(),
)))
}
/// Converts a number from centimeters to the current default unit.
///
/// *DEPRECATED* prefer using explicit numeric suffixes (e.g., `42cm`) or the `to...` conversion functions.
///
/// No matter what units the current file uses, this function will always return a number equivalent
/// to the input in centimeters.
///
/// For example, if the current file uses inches, `fromCm(1)` will return `0.393701`.
/// If the current file uses millimeters, `fromCm(1)` will return `10`.
/// If the current file uses centimeters, `fromCm(1)` will return `1`.
///
/// **Caution**: This function is only intended to be used when you absolutely MUST
/// have different units in your code than the file settings. Otherwise, it is
/// a bad pattern to use this function.
///
/// We merely provide these functions for convenience and readability, as
/// `fromCm(10)` is more readable that your intent is "I want 10 centimeters" than
/// `10 * 10`, if the file settings are in millimeters.
///
/// ```no_run
/// totalWidth = fromCm(10)
/// ```
#[stdlib {
name = "fromCm",
tags = ["units"],
deprecated = true,
}]
fn inner_from_cm(input: f64, exec_state: &ExecState) -> Result<f64, KclError> {
match exec_state.length_unit() {
UnitLen::Mm => Ok(measurements::Length::from_centimeters(input).as_millimeters()),
UnitLen::Inches => Ok(measurements::Length::from_centimeters(input).as_inches()),
UnitLen::Feet => Ok(measurements::Length::from_centimeters(input).as_feet()),
UnitLen::M => Ok(measurements::Length::from_centimeters(input).as_meters()),
UnitLen::Cm => Ok(input),
UnitLen::Yards => Ok(measurements::Length::from_centimeters(input).as_yards()),
UnitLen::Unknown => unreachable!(),
}
}
/// Yards conversion factor for current files units.
pub async fn from_yd(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input = args.get_number_typed(&RuntimeType::known_length(UnitLen::Yards), exec_state)?;
let result = inner_from_yd(input, exec_state)?;
Ok(args.make_user_val_from_f64_with_type(TyF64::new(
result,
exec_state.current_default_units().expect_default_length(),
)))
}
/// Converts a number from yards to the current default unit.
///
/// *DEPRECATED* prefer using explicit numeric suffixes (e.g., `42yd`) or the `to...` conversion functions.
///
/// No matter what units the current file uses, this function will always return a number equivalent
/// to the input in yards.
///
/// For example, if the current file uses inches, `fromYd(1)` will return `36`.
/// If the current file uses millimeters, `fromYd(1)` will return `914.4`.
/// If the current file uses yards, `fromYd(1)` will return `1`.
///
/// **Caution**: This function is only intended to be used when you absolutely MUST
/// have different units in your code than the file settings. Otherwise, it is
/// a bad pattern to use this function.
///
/// We merely provide these functions for convenience and readability, as
/// `fromYd(10)` is more readable that your intent is "I want 10 yards" than
/// `10 * 914.4`, if the file settings are in millimeters.
///
/// ```no_run
/// totalWidth = fromYd(10)
/// ```
#[stdlib {
name = "fromYd",
tags = ["units"],
deprecated = true,
}]
fn inner_from_yd(input: f64, exec_state: &ExecState) -> Result<f64, KclError> {
match exec_state.length_unit() {
UnitLen::Mm => Ok(measurements::Length::from_yards(input).as_millimeters()),
UnitLen::Inches => Ok(measurements::Length::from_yards(input).as_inches()),
UnitLen::Feet => Ok(measurements::Length::from_yards(input).as_feet()),
UnitLen::M => Ok(measurements::Length::from_yards(input).as_meters()),
UnitLen::Cm => Ok(measurements::Length::from_yards(input).as_centimeters()),
UnitLen::Yards => Ok(input),
UnitLen::Unknown => unreachable!(),
}
}

View File

@ -6,7 +6,7 @@ use super::args::TyF64;
use crate::execution::types::{NumericType, UnitLen};
pub(crate) fn untype_point(p: [TyF64; 2]) -> ([f64; 2], NumericType) {
let (x, y, ty) = NumericType::combine_eq(p[0].clone(), p[1].clone());
let (x, y, ty) = NumericType::combine_eq_coerce(p[0].clone(), p[1].clone());
([x, y], ty)
}

View File

@ -313,6 +313,12 @@ impl Expr {
}
Expr::AscribedExpression(e) => {
let mut result = e.expr.recast(options, indentation_level, ctxt);
if matches!(
e.expr,
Expr::BinaryExpression(..) | Expr::PipeExpression(..) | Expr::UnaryExpression(..)
) {
result = format!("({result})");
}
result += ": ";
result += &e.ty.to_string();
result

View File

@ -9,11 +9,11 @@ import Point2d from "std::types"
/// circumference = 70
///
/// exampleSketch = startSketchOn(XZ)
/// |> circle(center = [0, 0], radius = circumference / (2 * PI))
/// |> circle(center = [0, 0], radius = (circumference / (2 * PI)): number(mm))
///
/// example = extrude(exampleSketch, length = 5)
/// ```
export PI = 3.14159265358979323846264338327950288_
export PI = 3.14159265358979323846264338327950288_?
/// The value of Eulers number `e`.
///

View File

@ -398,64 +398,40 @@ description: Result of parsing array_range_expr.kcl
"type": "Identifier"
},
"init": {
"arguments": [
{
"commentStart": 0,
"end": 0,
"left": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "four",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"operator": "+",
"right": {
"commentStart": 0,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
],
"callee": {
"commentStart": 0,
"end": 0,
"left": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "int",
"name": "four",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"commentStart": 0,
"end": 0,
"operator": "+",
"right": {
"commentStart": 0,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 0,
"type": "VariableDeclarator"
@ -743,126 +719,78 @@ description: Result of parsing array_range_expr.kcl
"commentStart": 0,
"end": 0,
"endElement": {
"arguments": [
{
"commentStart": 0,
"end": 0,
"left": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "five",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"operator": "-",
"right": {
"commentStart": 0,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
],
"callee": {
"commentStart": 0,
"end": 0,
"left": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "int",
"name": "five",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"commentStart": 0,
"end": 0,
"operator": "-",
"right": {
"commentStart": 0,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"endInclusive": true,
"start": 0,
"startElement": {
"arguments": [
{
"commentStart": 0,
"end": 0,
"left": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "zero",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"operator": "+",
"right": {
"commentStart": 0,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
],
"callee": {
"commentStart": 0,
"end": 0,
"left": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "int",
"name": "zero",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"commentStart": 0,
"end": 0,
"operator": "+",
"right": {
"commentStart": 0,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"type": "ArrayRangeExpression",
"type": "ArrayRangeExpression"

View File

@ -6,12 +6,12 @@ zero = 0
r2 = [zero..four]
assert(r2[4], isEqualTo = 4, error = "last element is included")
five = int(four + 1)
five = four + 1
r3 = [zero..five]
assert(r3[4], isEqualTo = 4, error = "second-to-last element is included")
assert(r3[5], isEqualTo = 5, error = "last element is included")
r4 = [int(zero + 1) .. int(five - 1)]
r4 = [zero + 1 .. five - 1]
assert(r4[0], isEqualTo = 1, error = "first element is 1")
assert(r4[2], isEqualTo = 3, error = "second-to-last element is 3")
assert(r4[3], isEqualTo = 4, error = "last element is 4")

View File

@ -10,12 +10,12 @@ zero = 0
r2 = [zero..four]
assert(r2[4], isEqualTo = 4, error = "last element is included")
five = int(four + 1)
five = four + 1
r3 = [zero..five]
assert(r3[4], isEqualTo = 4, error = "second-to-last element is included")
assert(r3[5], isEqualTo = 5, error = "last element is included")
r4 = [int(zero + 1) .. int(five - 1)]
r4 = [zero + 1 .. five - 1]
assert(r4[0], isEqualTo = 1, error = "first element is 1")
assert(r4[2], isEqualTo = 3, error = "second-to-last element is 3")
assert(r4[3], isEqualTo = 4, error = "last element is 4")

View File

@ -35,48 +35,24 @@ description: Result of parsing array_range_negative_expr.kcl
"endInclusive": true,
"start": 0,
"startElement": {
"arguments": [
{
"argument": {
"commentStart": 0,
"end": 0,
"raw": "5",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 5.0,
"suffix": "None"
}
},
"commentStart": 0,
"end": 0,
"operator": "-",
"start": 0,
"type": "UnaryExpression",
"type": "UnaryExpression"
}
],
"callee": {
"abs_path": false,
"argument": {
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "int",
"start": 0,
"type": "Identifier"
},
"path": [],
"raw": "5",
"start": 0,
"type": "Name"
"type": "Literal",
"type": "Literal",
"value": {
"value": 5.0,
"suffix": "None"
}
},
"commentStart": 0,
"end": 0,
"operator": "-",
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "UnaryExpression",
"type": "UnaryExpression"
},
"type": "ArrayRangeExpression",
"type": "ArrayRangeExpression"

View File

@ -1,2 +1,2 @@
xs = [int(-5) .. 5]
xs = [-5 .. 5]
assert(xs[0], isEqualTo = -5, error = "first element is -5")

View File

@ -2,5 +2,5 @@
source: kcl-lib/src/simulation_tests.rs
description: Result of unparsing array_range_negative_expr.kcl
---
xs = [int(-5) .. 5]
xs = [-5 .. 5]
assert(xs[0], isEqualTo = -5, error = "first element is -5")

View File

@ -589,38 +589,53 @@ description: Result of parsing computed_var.kcl
{
"commentStart": 0,
"end": 0,
"left": {
"expr": {
"commentStart": 0,
"end": 0,
"raw": "2",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 2.0,
"suffix": "None"
}
},
"operator": "*",
"right": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"left": {
"commentStart": 0,
"end": 0,
"name": "PI",
"raw": "2",
"start": 0,
"type": "Identifier"
"type": "Literal",
"type": "Literal",
"value": {
"value": 2.0,
"suffix": "None"
}
},
"operator": "*",
"right": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "PI",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
"ty": {
"Rad": null,
"commentStart": 0,
"end": 0,
"p_type": "Number",
"start": 0,
"type": "Primitive"
},
"type": "AscribedExpression",
"type": "AscribedExpression"
}
],
"callee": {

View File

@ -14,5 +14,5 @@ assert(one, isEqualTo = 1, error = "oops")
assert(PI, isEqualTo = 3, tolerance = 0.2, error = "oops pi")
x = cos(2 * PI)
x = cos((2 * PI): number(rad))
assert(x, isEqualTo = 1, tolerance = 0.000001, error = "oops cos")

View File

@ -23,7 +23,7 @@ assert(
error = "oops pi",
)
x = cos(2 * PI)
x = cos((2 * PI): number(rad))
assert(
x,
isEqualTo = 1,

View File

@ -309,60 +309,36 @@ description: Result of parsing index_of_array.kcl
"type": "Identifier"
},
"init": {
"arguments": [
{
"commentStart": 0,
"end": 0,
"left": {
"commentStart": 0,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
"operator": "+",
"right": {
"commentStart": 0,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "int",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"left": {
"commentStart": 0,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
"operator": "+",
"right": {
"commentStart": 0,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 0,
"type": "VariableDeclarator"

View File

@ -14,7 +14,7 @@ assert(result0, isGreaterThanOrEqual = 91, error = "Literal property lookup")
// Test: computed index.
i = int(1 + 0)
i = 1 + 0
result1 = arr[i]
assert(result1, isLessThanOrEqual = 91, error = "Computed property lookup")

View File

@ -18,7 +18,7 @@ assert(result0, isGreaterThanOrEqual = 91, error = "Literal property lookup")
// Test: computed index.
i = int(1 + 0)
i = 1 + 0
result1 = arr[i]
assert(result1, isLessThanOrEqual = 91, error = "Computed property lookup")

View File

@ -325,7 +325,7 @@ description: Artifact commands car-wheel-assembly.kcl
"type": "move_path_pen",
"path": "[uuid]",
"to": {
"x": 38.099999999999994,
"x": 38.1,
"y": 0.0,
"z": 0.0
}
@ -350,7 +350,7 @@ description: Artifact commands car-wheel-assembly.kcl
"x": 0.0,
"y": 0.0
},
"radius": 38.099999999999994,
"radius": 38.1,
"start": {
"unit": "degrees",
"value": 0.0
@ -632,7 +632,7 @@ description: Artifact commands car-wheel-assembly.kcl
"type": "move_path_pen",
"path": "[uuid]",
"to": {
"x": 38.099999999999994,
"x": 38.1,
"y": 0.0,
"z": 0.0
}
@ -657,7 +657,7 @@ description: Artifact commands car-wheel-assembly.kcl
"x": 0.0,
"y": 0.0
},
"radius": 38.099999999999994,
"radius": 38.1,
"start": {
"unit": "degrees",
"value": 0.0
@ -1426,7 +1426,7 @@ description: Artifact commands car-wheel-assembly.kcl
"type": "move_path_pen",
"path": "[uuid]",
"to": {
"x": 65.14999999999999,
"x": 65.15,
"y": 0.0,
"z": 0.0
}
@ -1451,7 +1451,7 @@ description: Artifact commands car-wheel-assembly.kcl
"x": 57.15,
"y": 0.0
},
"radius": 7.999999999999999,
"radius": 8.0,
"start": {
"unit": "degrees",
"value": 0.0
@ -2103,7 +2103,7 @@ description: Artifact commands car-wheel-assembly.kcl
"type": "move_path_pen",
"path": "[uuid]",
"to": {
"x": 38.099999999999994,
"x": 38.1,
"y": 0.0,
"z": 0.0
}
@ -13008,7 +13008,7 @@ description: Artifact commands car-wheel-assembly.kcl
"type": "make_plane",
"origin": {
"x": 57.15,
"y": -29.999999999999996,
"y": -30.0,
"z": 0.0
},
"x_axis": {

View File

@ -79,85 +79,85 @@ flowchart LR
158[Solid2d]
end
subgraph path167 [Path]
167["Path<br>[1276, 1337, 8]"]
168["Segment<br>[1276, 1337, 8]"]
167["Path<br>[1276, 1331, 8]"]
168["Segment<br>[1276, 1331, 8]"]
169[Solid2d]
end
subgraph path179 [Path]
179["Path<br>[1695, 1741, 8]"]
180["Segment<br>[1747, 1799, 8]"]
181["Segment<br>[1805, 1878, 8]"]
182["Segment<br>[1884, 1906, 8]"]
183["Segment<br>[1912, 1968, 8]"]
184["Segment<br>[1974, 1981, 8]"]
179["Path<br>[1689, 1735, 8]"]
180["Segment<br>[1741, 1793, 8]"]
181["Segment<br>[1799, 1872, 8]"]
182["Segment<br>[1878, 1900, 8]"]
183["Segment<br>[1906, 1962, 8]"]
184["Segment<br>[1968, 1975, 8]"]
185[Solid2d]
end
subgraph path195 [Path]
195["Path<br>[2113, 2159, 8]"]
196["Segment<br>[2165, 2217, 8]"]
197["Segment<br>[2223, 2298, 8]"]
198["Segment<br>[2304, 2341, 8]"]
199["Segment<br>[2347, 2403, 8]"]
200["Segment<br>[2409, 2416, 8]"]
195["Path<br>[2107, 2153, 8]"]
196["Segment<br>[2159, 2211, 8]"]
197["Segment<br>[2217, 2292, 8]"]
198["Segment<br>[2298, 2335, 8]"]
199["Segment<br>[2341, 2397, 8]"]
200["Segment<br>[2403, 2410, 8]"]
201[Solid2d]
end
subgraph path212 [Path]
212["Path<br>[2897, 2944, 8]"]
213["Segment<br>[2952, 3289, 8]"]
214["Segment<br>[3297, 3329, 8]"]
215["Segment<br>[3337, 3678, 8]"]
216["Segment<br>[3686, 3742, 8]"]
217["Segment<br>[3750, 3757, 8]"]
212["Path<br>[2891, 2938, 8]"]
213["Segment<br>[2946, 3283, 8]"]
214["Segment<br>[3291, 3323, 8]"]
215["Segment<br>[3331, 3672, 8]"]
216["Segment<br>[3680, 3736, 8]"]
217["Segment<br>[3744, 3751, 8]"]
218[Solid2d]
end
subgraph path235 [Path]
235["Path<br>[2897, 2944, 8]"]
236["Segment<br>[2952, 3289, 8]"]
237["Segment<br>[3297, 3329, 8]"]
238["Segment<br>[3337, 3678, 8]"]
239["Segment<br>[3686, 3742, 8]"]
240["Segment<br>[3750, 3757, 8]"]
235["Path<br>[2891, 2938, 8]"]
236["Segment<br>[2946, 3283, 8]"]
237["Segment<br>[3291, 3323, 8]"]
238["Segment<br>[3331, 3672, 8]"]
239["Segment<br>[3680, 3736, 8]"]
240["Segment<br>[3744, 3751, 8]"]
241[Solid2d]
end
subgraph path258 [Path]
258["Path<br>[4285, 4380, 8]"]
259["Segment<br>[4386, 4419, 8]"]
260["Segment<br>[4425, 4476, 8]"]
261["Segment<br>[4482, 4515, 8]"]
262["Segment<br>[4521, 4571, 8]"]
263["Segment<br>[4577, 4618, 8]"]
264["Segment<br>[4624, 4673, 8]"]
265["Segment<br>[4679, 4712, 8]"]
266["Segment<br>[4718, 4752, 8]"]
267["Segment<br>[4758, 4792, 8]"]
268["Segment<br>[4798, 4850, 8]"]
269["Segment<br>[4856, 4890, 8]"]
270["Segment<br>[4896, 4972, 8]"]
271["Segment<br>[4978, 5011, 8]"]
272["Segment<br>[5017, 5093, 8]"]
273["Segment<br>[5099, 5133, 8]"]
274["Segment<br>[5139, 5213, 8]"]
275["Segment<br>[5219, 5253, 8]"]
276["Segment<br>[5259, 5310, 8]"]
277["Segment<br>[5316, 5378, 8]"]
278["Segment<br>[5384, 5435, 8]"]
279["Segment<br>[5441, 5475, 8]"]
280["Segment<br>[5481, 5514, 8]"]
281["Segment<br>[5520, 5553, 8]"]
282["Segment<br>[5559, 5566, 8]"]
258["Path<br>[4279, 4374, 8]"]
259["Segment<br>[4380, 4413, 8]"]
260["Segment<br>[4419, 4470, 8]"]
261["Segment<br>[4476, 4509, 8]"]
262["Segment<br>[4515, 4565, 8]"]
263["Segment<br>[4571, 4612, 8]"]
264["Segment<br>[4618, 4667, 8]"]
265["Segment<br>[4673, 4706, 8]"]
266["Segment<br>[4712, 4746, 8]"]
267["Segment<br>[4752, 4786, 8]"]
268["Segment<br>[4792, 4844, 8]"]
269["Segment<br>[4850, 4884, 8]"]
270["Segment<br>[4890, 4966, 8]"]
271["Segment<br>[4972, 5005, 8]"]
272["Segment<br>[5011, 5087, 8]"]
273["Segment<br>[5093, 5127, 8]"]
274["Segment<br>[5133, 5207, 8]"]
275["Segment<br>[5213, 5247, 8]"]
276["Segment<br>[5253, 5304, 8]"]
277["Segment<br>[5310, 5372, 8]"]
278["Segment<br>[5378, 5429, 8]"]
279["Segment<br>[5435, 5469, 8]"]
280["Segment<br>[5475, 5508, 8]"]
281["Segment<br>[5514, 5547, 8]"]
282["Segment<br>[5553, 5560, 8]"]
283[Solid2d]
end
subgraph path334 [Path]
334["Path<br>[713, 753, 11]"]
335["Segment<br>[761, 808, 11]"]
336["Segment<br>[816, 852, 11]"]
337["Segment<br>[860, 890, 11]"]
338["Segment<br>[898, 943, 11]"]
339["Segment<br>[951, 991, 11]"]
340["Segment<br>[999, 1034, 11]"]
341["Segment<br>[1042, 1080, 11]"]
342["Segment<br>[1088, 1110, 11]"]
343["Segment<br>[1118, 1125, 11]"]
334["Path<br>[693, 733, 11]"]
335["Segment<br>[741, 788, 11]"]
336["Segment<br>[796, 832, 11]"]
337["Segment<br>[840, 870, 11]"]
338["Segment<br>[878, 917, 11]"]
339["Segment<br>[925, 965, 11]"]
340["Segment<br>[973, 1008, 11]"]
341["Segment<br>[1016, 1054, 11]"]
342["Segment<br>[1062, 1084, 11]"]
343["Segment<br>[1092, 1099, 11]"]
344[Solid2d]
end
subgraph path365 [Path]
@ -315,16 +315,16 @@ flowchart LR
164["Sweep Extrusion<br>[1140, 1174, 8]"]
165["Sweep Extrusion<br>[1140, 1174, 8]"]
166["Sweep Extrusion<br>[1140, 1174, 8]"]
170["Sweep Extrusion<br>[1484, 1518, 8]"]
170["Sweep Extrusion<br>[1478, 1512, 8]"]
171[Wall]
172["SweepEdge Opposite"]
173["SweepEdge Adjacent"]
174["Sweep Extrusion<br>[1484, 1518, 8]"]
175["Sweep Extrusion<br>[1484, 1518, 8]"]
176["Sweep Extrusion<br>[1484, 1518, 8]"]
177["Sweep Extrusion<br>[1484, 1518, 8]"]
178["Plane<br>[1672, 1689, 8]"]
186["Sweep Revolve<br>[1987, 2004, 8]"]
174["Sweep Extrusion<br>[1478, 1512, 8]"]
175["Sweep Extrusion<br>[1478, 1512, 8]"]
176["Sweep Extrusion<br>[1478, 1512, 8]"]
177["Sweep Extrusion<br>[1478, 1512, 8]"]
178["Plane<br>[1666, 1683, 8]"]
186["Sweep Revolve<br>[1981, 1998, 8]"]
187[Wall]
188[Wall]
189[Wall]
@ -332,8 +332,8 @@ flowchart LR
191["SweepEdge Adjacent"]
192["SweepEdge Adjacent"]
193["SweepEdge Adjacent"]
194["Plane<br>[2090, 2107, 8]"]
202["Sweep Revolve<br>[2422, 2439, 8]"]
194["Plane<br>[2084, 2101, 8]"]
202["Sweep Revolve<br>[2416, 2433, 8]"]
203[Wall]
204[Wall]
205[Wall]
@ -342,8 +342,8 @@ flowchart LR
208["SweepEdge Adjacent"]
209["SweepEdge Adjacent"]
210["SweepEdge Adjacent"]
211["Plane<br>[2866, 2889, 8]"]
219["Sweep Extrusion<br>[3805, 3851, 8]"]
211["Plane<br>[2860, 2883, 8]"]
219["Sweep Extrusion<br>[3799, 3845, 8]"]
220[Wall]
221[Wall]
222[Wall]
@ -358,8 +358,8 @@ flowchart LR
231["SweepEdge Adjacent"]
232["SweepEdge Opposite"]
233["SweepEdge Adjacent"]
234["Plane<br>[2866, 2889, 8]"]
242["Sweep Extrusion<br>[3805, 3851, 8]"]
234["Plane<br>[2860, 2883, 8]"]
242["Sweep Extrusion<br>[3799, 3845, 8]"]
243[Wall]
244[Wall]
245[Wall]
@ -374,8 +374,8 @@ flowchart LR
254["SweepEdge Adjacent"]
255["SweepEdge Opposite"]
256["SweepEdge Adjacent"]
257["Plane<br>[4262, 4279, 8]"]
284["Sweep Revolve<br>[5572, 5589, 8]"]
257["Plane<br>[4256, 4273, 8]"]
284["Sweep Revolve<br>[5566, 5583, 8]"]
285[Wall]
286[Wall]
287[Wall]
@ -424,8 +424,8 @@ flowchart LR
330["SweepEdge Adjacent"]
331["SweepEdge Adjacent"]
332["SweepEdge Adjacent"]
333["Plane<br>[679, 705, 11]"]
345["Sweep Revolve<br>[1133, 1150, 11]"]
333["Plane<br>[659, 685, 11]"]
345["Sweep Revolve<br>[1107, 1124, 11]"]
346[Wall]
347[Wall]
348[Wall]

View File

@ -2153,20 +2153,20 @@ description: Operations executed car-wheel-assembly.kcl
"value": {
"x": {
"type": "Number",
"value": 2.25,
"value": 57.15,
"ty": {
"type": "Known",
"type": "Length",
"type": "Inches"
"type": "Mm"
}
},
"y": {
"type": "Number",
"value": -1.1811023622047243,
"value": -30.0,
"ty": {
"type": "Known",
"type": "Length",
"type": "Inches"
"type": "Mm"
}
},
"z": {

View File

@ -143,20 +143,20 @@ description: Variables in memory after executing car-wheel-assembly.kcl
},
"lugDiameter": {
"type": "Number",
"value": 0.9449,
"value": 24.0,
"ty": {
"type": "Known",
"type": "Length",
"type": "Inches"
"type": "Mm"
}
},
"lugHeadLength": {
"type": "Number",
"value": 0.4724,
"value": 12.0,
"ty": {
"type": "Known",
"type": "Length",
"type": "Inches"
"type": "Mm"
}
},
"lugHolePatternDia": {
@ -174,11 +174,11 @@ description: Variables in memory after executing car-wheel-assembly.kcl
},
"lugLength": {
"type": "Number",
"value": 1.1811,
"value": 30.0,
"ty": {
"type": "Known",
"type": "Length",
"type": "Inches"
"type": "Mm"
}
},
"lugNut": {
@ -187,38 +187,38 @@ description: Variables in memory after executing car-wheel-assembly.kcl
},
"lugSpacing": {
"type": "Number",
"value": 4.5,
"value": 114.3,
"ty": {
"type": "Known",
"type": "Length",
"type": "Inches"
"type": "Mm"
}
},
"lugThreadDepth": {
"type": "Number",
"value": 0.6811,
"value": 17.3,
"ty": {
"type": "Known",
"type": "Length",
"type": "Inches"
"type": "Mm"
}
},
"lugThreadDiameter": {
"type": "Number",
"value": 0.4016,
"value": 10.2,
"ty": {
"type": "Known",
"type": "Length",
"type": "Inches"
"type": "Mm"
}
},
"offset": {
"type": "Number",
"value": -1.378,
"value": -35.0,
"ty": {
"type": "Known",
"type": "Length",
"type": "Inches"
"type": "Mm"
}
},
"rotorDiameter": {

View File

@ -1,15 +1,15 @@
```mermaid
flowchart LR
subgraph path2 [Path]
2["Path<br>[463, 501, 0]"]
3["Segment<br>[507, 538, 0]"]
4["Segment<br>[544, 576, 0]"]
5["Segment<br>[582, 632, 0]"]
6["Segment<br>[638, 684, 0]"]
7["Segment<br>[690, 712, 0]"]
2["Path<br>[457, 495, 0]"]
3["Segment<br>[501, 532, 0]"]
4["Segment<br>[538, 570, 0]"]
5["Segment<br>[576, 626, 0]"]
6["Segment<br>[632, 678, 0]"]
7["Segment<br>[684, 706, 0]"]
end
1["Plane<br>[439, 457, 0]"]
8["Sweep Extrusion<br>[766, 794, 0]"]
1["Plane<br>[433, 451, 0]"]
8["Sweep Extrusion<br>[760, 788, 0]"]
1 --- 2
2 --- 3
2 --- 4

View File

@ -18,40 +18,16 @@ description: Result of parsing i-beam.kcl
"type": "Identifier"
},
"init": {
"arguments": [
{
"commentStart": 0,
"end": 0,
"raw": "6",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 6.0,
"suffix": "None"
}
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "fromFt",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"raw": "6ft",
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "Literal",
"type": "Literal",
"value": {
"value": 6.0,
"suffix": "Ft"
}
},
"start": 0,
"type": "VariableDeclarator"

View File

@ -23,11 +23,11 @@ description: Operations executed i-beam.kcl
"length": {
"value": {
"type": "Number",
"value": 72.0,
"value": 6.0,
"ty": {
"type": "Known",
"type": "Length",
"type": "Inches"
"type": "Feet"
}
},
"sourceRange": []

View File

@ -18,11 +18,11 @@ description: Variables in memory after executing i-beam.kcl
},
"beamLength": {
"type": "Number",
"value": 72.0,
"value": 6.0,
"ty": {
"type": "Known",
"type": "Length",
"type": "Inches"
"type": "Feet"
}
},
"flangeThickness": {

View File

@ -148,7 +148,7 @@ description: Artifact commands router-template-cross-bar.kcl
"segment": {
"type": "line",
"end": {
"x": 22.6313,
"x": 22.6312,
"y": -10.0,
"z": 0.0
},
@ -182,7 +182,7 @@ description: Artifact commands router-template-cross-bar.kcl
"segment": {
"type": "line",
"end": {
"x": 32.6313,
"x": 32.6312,
"y": 10.9406,
"z": 0.0
},
@ -199,7 +199,7 @@ description: Artifact commands router-template-cross-bar.kcl
"segment": {
"type": "line",
"end": {
"x": 102.6313,
"x": 102.6312,
"y": 10.9406,
"z": 0.0
},
@ -233,7 +233,7 @@ description: Artifact commands router-template-cross-bar.kcl
"segment": {
"type": "line",
"end": {
"x": 32.6313,
"x": 32.6312,
"y": 30.9406,
"z": 0.0
},
@ -250,7 +250,7 @@ description: Artifact commands router-template-cross-bar.kcl
"segment": {
"type": "line",
"end": {
"x": 32.6313,
"x": 32.6312,
"y": 41.8813,
"z": 0.0
},
@ -284,7 +284,7 @@ description: Artifact commands router-template-cross-bar.kcl
"segment": {
"type": "line",
"end": {
"x": -32.6313,
"x": -32.6312,
"y": 0.0,
"z": 0.0
},

View File

@ -1,59 +1,59 @@
```mermaid
flowchart LR
subgraph path2 [Path]
2["Path<br>[538, 581, 0]"]
3["Segment<br>[587, 640, 0]"]
4["Segment<br>[646, 757, 0]"]
5["Segment<br>[763, 816, 0]"]
6["Segment<br>[822, 869, 0]"]
7["Segment<br>[875, 971, 0]"]
8["Segment<br>[977, 1048, 0]"]
9["Segment<br>[1054, 1105, 0]"]
10["Segment<br>[1111, 1164, 0]"]
11["Segment<br>[1170, 1239, 0]"]
12["Segment<br>[1245, 1281, 0]"]
13["Segment<br>[1287, 1317, 0]"]
14["Segment<br>[1323, 1353, 0]"]
15["Segment<br>[1359, 1389, 0]"]
16["Segment<br>[1395, 1425, 0]"]
17["Segment<br>[1431, 1460, 0]"]
18["Segment<br>[1466, 1496, 0]"]
19["Segment<br>[1502, 1531, 0]"]
20["Segment<br>[1537, 1566, 0]"]
21["Segment<br>[1572, 1635, 0]"]
22["Segment<br>[1641, 1697, 0]"]
23["Segment<br>[1703, 1710, 0]"]
2["Path<br>[540, 583, 0]"]
3["Segment<br>[589, 642, 0]"]
4["Segment<br>[648, 759, 0]"]
5["Segment<br>[765, 818, 0]"]
6["Segment<br>[824, 871, 0]"]
7["Segment<br>[877, 973, 0]"]
8["Segment<br>[979, 1050, 0]"]
9["Segment<br>[1056, 1107, 0]"]
10["Segment<br>[1113, 1166, 0]"]
11["Segment<br>[1172, 1241, 0]"]
12["Segment<br>[1247, 1283, 0]"]
13["Segment<br>[1289, 1319, 0]"]
14["Segment<br>[1325, 1355, 0]"]
15["Segment<br>[1361, 1391, 0]"]
16["Segment<br>[1397, 1427, 0]"]
17["Segment<br>[1433, 1462, 0]"]
18["Segment<br>[1468, 1498, 0]"]
19["Segment<br>[1504, 1533, 0]"]
20["Segment<br>[1539, 1568, 0]"]
21["Segment<br>[1574, 1637, 0]"]
22["Segment<br>[1643, 1699, 0]"]
23["Segment<br>[1705, 1712, 0]"]
24[Solid2d]
end
subgraph path85 [Path]
85["Path<br>[1870, 1914, 0]"]
86["Segment<br>[1920, 2000, 0]"]
87["Segment<br>[2006, 2116, 0]"]
88["Segment<br>[2122, 2239, 0]"]
89["Segment<br>[2245, 2301, 0]"]
90["Segment<br>[2307, 2314, 0]"]
85["Path<br>[1872, 1916, 0]"]
86["Segment<br>[1922, 2002, 0]"]
87["Segment<br>[2008, 2118, 0]"]
88["Segment<br>[2124, 2241, 0]"]
89["Segment<br>[2247, 2303, 0]"]
90["Segment<br>[2309, 2316, 0]"]
91[Solid2d]
end
subgraph path107 [Path]
107["Path<br>[2475, 2520, 0]"]
108["Segment<br>[2526, 2604, 0]"]
109["Segment<br>[2610, 2720, 0]"]
110["Segment<br>[2726, 2843, 0]"]
111["Segment<br>[2849, 2905, 0]"]
112["Segment<br>[2911, 2918, 0]"]
107["Path<br>[2477, 2522, 0]"]
108["Segment<br>[2528, 2606, 0]"]
109["Segment<br>[2612, 2722, 0]"]
110["Segment<br>[2728, 2845, 0]"]
111["Segment<br>[2851, 2907, 0]"]
112["Segment<br>[2913, 2920, 0]"]
113[Solid2d]
end
subgraph path129 [Path]
129["Path<br>[3077, 3122, 0]"]
130["Segment<br>[3128, 3213, 0]"]
131["Segment<br>[3219, 3329, 0]"]
132["Segment<br>[3335, 3452, 0]"]
133["Segment<br>[3458, 3514, 0]"]
134["Segment<br>[3520, 3527, 0]"]
129["Path<br>[3079, 3124, 0]"]
130["Segment<br>[3130, 3215, 0]"]
131["Segment<br>[3221, 3331, 0]"]
132["Segment<br>[3337, 3454, 0]"]
133["Segment<br>[3460, 3516, 0]"]
134["Segment<br>[3522, 3529, 0]"]
135[Solid2d]
end
1["Plane<br>[515, 532, 0]"]
25["Sweep Extrusion<br>[1753, 1783, 0]"]
1["Plane<br>[517, 534, 0]"]
25["Sweep Extrusion<br>[1755, 1785, 0]"]
26[Wall]
27[Wall]
28[Wall]
@ -113,7 +113,7 @@ flowchart LR
82["SweepEdge Adjacent"]
83["SweepEdge Opposite"]
84["SweepEdge Adjacent"]
92["Sweep Extrusion<br>[2358, 2389, 0]"]
92["Sweep Extrusion<br>[2360, 2391, 0]"]
93[Wall]
94[Wall]
95[Wall]
@ -128,7 +128,7 @@ flowchart LR
104["SweepEdge Adjacent"]
105["SweepEdge Opposite"]
106["SweepEdge Adjacent"]
114["Sweep Extrusion<br>[2961, 2992, 0]"]
114["Sweep Extrusion<br>[2963, 2994, 0]"]
115[Wall]
116[Wall]
117[Wall]
@ -143,7 +143,7 @@ flowchart LR
126["SweepEdge Adjacent"]
127["SweepEdge Opposite"]
128["SweepEdge Adjacent"]
136["Sweep Extrusion<br>[3571, 3601, 0]"]
136["Sweep Extrusion<br>[3573, 3603, 0]"]
137[Wall]
138[Wall]
139[Wall]
@ -158,9 +158,9 @@ flowchart LR
148["SweepEdge Adjacent"]
149["SweepEdge Opposite"]
150["SweepEdge Adjacent"]
151["StartSketchOnFace<br>[1825, 1864, 0]"]
152["StartSketchOnFace<br>[2430, 2469, 0]"]
153["StartSketchOnFace<br>[3034, 3071, 0]"]
151["StartSketchOnFace<br>[1827, 1866, 0]"]
152["StartSketchOnFace<br>[2432, 2471, 0]"]
153["StartSketchOnFace<br>[3036, 3073, 0]"]
1 --- 2
2 --- 3
2 --- 4

View File

@ -54,60 +54,51 @@ description: Result of parsing router-template-cross-bar.kcl
"type": "Identifier"
},
"init": {
"arguments": [
{
"commentStart": 0,
"end": 0,
"left": {
"commentStart": 0,
"end": 0,
"raw": "11",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 11.0,
"suffix": "None"
}
},
"operator": "/",
"right": {
"commentStart": 0,
"end": 0,
"raw": "16",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 16.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "fromInches",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"expr": {
"commentStart": 0,
"end": 0,
"left": {
"commentStart": 0,
"end": 0,
"raw": "11",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 11.0,
"suffix": "None"
}
},
"operator": "/",
"right": {
"commentStart": 0,
"end": 0,
"raw": "16",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 16.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"ty": {
"Inch": null,
"commentStart": 0,
"end": 0,
"p_type": "Number",
"start": 0,
"type": "Primitive"
},
"type": "AscribedExpression",
"type": "AscribedExpression"
},
"start": 0,
"type": "VariableDeclarator"

View File

@ -85,7 +85,7 @@ description: Artifact commands router-template-slate.kcl
"path": "[uuid]",
"to": {
"x": 0.0,
"y": 28.11875,
"y": 28.118750000000002,
"z": 0.0
}
}
@ -149,7 +149,7 @@ description: Artifact commands router-template-slate.kcl
"type": "line",
"end": {
"x": 18.8688,
"y": -12.4937,
"y": -12.4938,
"z": 0.0
},
"relative": false
@ -166,7 +166,7 @@ description: Artifact commands router-template-slate.kcl
"type": "line",
"end": {
"x": 30.75,
"y": -12.4937,
"y": -12.4938,
"z": 0.0
},
"relative": false
@ -920,7 +920,7 @@ description: Artifact commands router-template-slate.kcl
"path": "[uuid]",
"to": {
"x": -20.75,
"y": -12.493749999999999,
"y": -12.49375,
"z": 0.0
}
}
@ -993,7 +993,7 @@ description: Artifact commands router-template-slate.kcl
"type": "line",
"end": {
"x": -20.75,
"y": -12.4937,
"y": -12.4938,
"z": 0.0
},
"relative": false
@ -1270,7 +1270,7 @@ description: Artifact commands router-template-slate.kcl
"path": "[uuid]",
"to": {
"x": 20.75,
"y": -12.493749999999999,
"y": -12.49375,
"z": 0.0
}
}
@ -1343,7 +1343,7 @@ description: Artifact commands router-template-slate.kcl
"type": "line",
"end": {
"x": 20.75,
"y": -12.4937,
"y": -12.4938,
"z": 0.0
},
"relative": false

View File

@ -1,42 +1,42 @@
```mermaid
flowchart LR
subgraph path2 [Path]
2["Path<br>[537, 580, 0]"]
3["Segment<br>[586, 625, 0]"]
4["Segment<br>[631, 696, 0]"]
5["Segment<br>[702, 778, 0]"]
6["Segment<br>[784, 853, 0]"]
7["Segment<br>[859, 899, 0]"]
8["Segment<br>[905, 941, 0]"]
9["Segment<br>[981, 1011, 0]"]
10["Segment<br>[1017, 1046, 0]"]
11["Segment<br>[1052, 1081, 0]"]
12["Segment<br>[1087, 1116, 0]"]
13["Segment<br>[1122, 1189, 0]"]
14["Segment<br>[1195, 1251, 0]"]
15["Segment<br>[1257, 1264, 0]"]
2["Path<br>[539, 582, 0]"]
3["Segment<br>[588, 627, 0]"]
4["Segment<br>[633, 698, 0]"]
5["Segment<br>[704, 780, 0]"]
6["Segment<br>[786, 855, 0]"]
7["Segment<br>[861, 901, 0]"]
8["Segment<br>[907, 943, 0]"]
9["Segment<br>[983, 1013, 0]"]
10["Segment<br>[1019, 1048, 0]"]
11["Segment<br>[1054, 1083, 0]"]
12["Segment<br>[1089, 1118, 0]"]
13["Segment<br>[1124, 1191, 0]"]
14["Segment<br>[1197, 1253, 0]"]
15["Segment<br>[1259, 1266, 0]"]
16[Solid2d]
end
subgraph path52 [Path]
52["Path<br>[1424, 1524, 0]"]
53["Segment<br>[1530, 1577, 0]"]
54["Segment<br>[1583, 1695, 0]"]
55["Segment<br>[1701, 1818, 0]"]
56["Segment<br>[1824, 1880, 0]"]
57["Segment<br>[1886, 1893, 0]"]
52["Path<br>[1426, 1526, 0]"]
53["Segment<br>[1532, 1579, 0]"]
54["Segment<br>[1585, 1697, 0]"]
55["Segment<br>[1703, 1820, 0]"]
56["Segment<br>[1826, 1882, 0]"]
57["Segment<br>[1888, 1895, 0]"]
58[Solid2d]
end
subgraph path74 [Path]
74["Path<br>[2055, 2154, 0]"]
75["Segment<br>[2160, 2206, 0]"]
76["Segment<br>[2212, 2295, 0]"]
77["Segment<br>[2301, 2389, 0]"]
78["Segment<br>[2395, 2451, 0]"]
79["Segment<br>[2457, 2464, 0]"]
74["Path<br>[2057, 2156, 0]"]
75["Segment<br>[2162, 2208, 0]"]
76["Segment<br>[2214, 2297, 0]"]
77["Segment<br>[2303, 2391, 0]"]
78["Segment<br>[2397, 2453, 0]"]
79["Segment<br>[2459, 2466, 0]"]
80[Solid2d]
end
1["Plane<br>[514, 531, 0]"]
17["Sweep Extrusion<br>[1307, 1337, 0]"]
1["Plane<br>[516, 533, 0]"]
17["Sweep Extrusion<br>[1309, 1339, 0]"]
18[Wall]
19[Wall]
20[Wall]
@ -71,7 +71,7 @@ flowchart LR
49["SweepEdge Opposite"]
50["SweepEdge Adjacent"]
51["SweepEdge Opposite"]
59["Sweep Extrusion<br>[1937, 1969, 0]"]
59["Sweep Extrusion<br>[1939, 1971, 0]"]
60[Wall]
61[Wall]
62[Wall]
@ -86,7 +86,7 @@ flowchart LR
71["SweepEdge Adjacent"]
72["SweepEdge Opposite"]
73["SweepEdge Adjacent"]
81["Sweep Extrusion<br>[2507, 2539, 0]"]
81["Sweep Extrusion<br>[2509, 2541, 0]"]
82[Wall]
83[Wall]
84[Wall]
@ -101,8 +101,8 @@ flowchart LR
93["SweepEdge Adjacent"]
94["SweepEdge Opposite"]
95["SweepEdge Adjacent"]
96["StartSketchOnFace<br>[1379, 1418, 0]"]
97["StartSketchOnFace<br>[2010, 2049, 0]"]
96["StartSketchOnFace<br>[1381, 1420, 0]"]
97["StartSketchOnFace<br>[2012, 2051, 0]"]
1 --- 2
2 --- 3
2 --- 4

View File

@ -54,60 +54,51 @@ description: Result of parsing router-template-slate.kcl
"type": "Identifier"
},
"init": {
"arguments": [
{
"commentStart": 0,
"end": 0,
"left": {
"commentStart": 0,
"end": 0,
"raw": "11",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 11.0,
"suffix": "None"
}
},
"operator": "/",
"right": {
"commentStart": 0,
"end": 0,
"raw": "16",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 16.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "fromInches",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"expr": {
"commentStart": 0,
"end": 0,
"left": {
"commentStart": 0,
"end": 0,
"raw": "11",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 11.0,
"suffix": "None"
}
},
"operator": "/",
"right": {
"commentStart": 0,
"end": 0,
"raw": "16",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 16.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"ty": {
"Inch": null,
"commentStart": 0,
"end": 0,
"p_type": "Number",
"start": 0,
"type": "Primitive"
},
"type": "AscribedExpression",
"type": "AscribedExpression"
},
"start": 0,
"type": "VariableDeclarator"

View File

@ -1,61 +1,61 @@
```mermaid
flowchart LR
subgraph path2 [Path]
2["Path<br>[754, 790, 0]"]
3["Segment<br>[944, 1008, 0]"]
4["Segment<br>[944, 1008, 0]"]
5["Segment<br>[944, 1008, 0]"]
6["Segment<br>[944, 1008, 0]"]
7["Segment<br>[944, 1008, 0]"]
8["Segment<br>[944, 1008, 0]"]
9["Segment<br>[944, 1008, 0]"]
10["Segment<br>[944, 1008, 0]"]
11["Segment<br>[944, 1008, 0]"]
12["Segment<br>[944, 1008, 0]"]
13["Segment<br>[944, 1008, 0]"]
14["Segment<br>[944, 1008, 0]"]
15["Segment<br>[944, 1008, 0]"]
16["Segment<br>[944, 1008, 0]"]
17["Segment<br>[944, 1008, 0]"]
18["Segment<br>[944, 1008, 0]"]
19["Segment<br>[944, 1008, 0]"]
20["Segment<br>[944, 1008, 0]"]
21["Segment<br>[944, 1008, 0]"]
22["Segment<br>[944, 1008, 0]"]
23["Segment<br>[944, 1008, 0]"]
24["Segment<br>[944, 1008, 0]"]
25["Segment<br>[944, 1008, 0]"]
26["Segment<br>[944, 1008, 0]"]
27["Segment<br>[944, 1008, 0]"]
28["Segment<br>[944, 1008, 0]"]
29["Segment<br>[944, 1008, 0]"]
30["Segment<br>[944, 1008, 0]"]
31["Segment<br>[944, 1008, 0]"]
32["Segment<br>[944, 1008, 0]"]
33["Segment<br>[944, 1008, 0]"]
34["Segment<br>[944, 1008, 0]"]
35["Segment<br>[944, 1008, 0]"]
36["Segment<br>[944, 1008, 0]"]
37["Segment<br>[944, 1008, 0]"]
38["Segment<br>[944, 1008, 0]"]
39["Segment<br>[944, 1008, 0]"]
40["Segment<br>[944, 1008, 0]"]
41["Segment<br>[944, 1008, 0]"]
42["Segment<br>[944, 1008, 0]"]
43["Segment<br>[944, 1008, 0]"]
44["Segment<br>[944, 1008, 0]"]
45["Segment<br>[944, 1008, 0]"]
46["Segment<br>[944, 1008, 0]"]
47["Segment<br>[944, 1008, 0]"]
48["Segment<br>[944, 1008, 0]"]
49["Segment<br>[944, 1008, 0]"]
50["Segment<br>[944, 1008, 0]"]
51["Segment<br>[944, 1008, 0]"]
52["Segment<br>[1072, 1090, 0]"]
2["Path<br>[747, 783, 0]"]
3["Segment<br>[937, 1001, 0]"]
4["Segment<br>[937, 1001, 0]"]
5["Segment<br>[937, 1001, 0]"]
6["Segment<br>[937, 1001, 0]"]
7["Segment<br>[937, 1001, 0]"]
8["Segment<br>[937, 1001, 0]"]
9["Segment<br>[937, 1001, 0]"]
10["Segment<br>[937, 1001, 0]"]
11["Segment<br>[937, 1001, 0]"]
12["Segment<br>[937, 1001, 0]"]
13["Segment<br>[937, 1001, 0]"]
14["Segment<br>[937, 1001, 0]"]
15["Segment<br>[937, 1001, 0]"]
16["Segment<br>[937, 1001, 0]"]
17["Segment<br>[937, 1001, 0]"]
18["Segment<br>[937, 1001, 0]"]
19["Segment<br>[937, 1001, 0]"]
20["Segment<br>[937, 1001, 0]"]
21["Segment<br>[937, 1001, 0]"]
22["Segment<br>[937, 1001, 0]"]
23["Segment<br>[937, 1001, 0]"]
24["Segment<br>[937, 1001, 0]"]
25["Segment<br>[937, 1001, 0]"]
26["Segment<br>[937, 1001, 0]"]
27["Segment<br>[937, 1001, 0]"]
28["Segment<br>[937, 1001, 0]"]
29["Segment<br>[937, 1001, 0]"]
30["Segment<br>[937, 1001, 0]"]
31["Segment<br>[937, 1001, 0]"]
32["Segment<br>[937, 1001, 0]"]
33["Segment<br>[937, 1001, 0]"]
34["Segment<br>[937, 1001, 0]"]
35["Segment<br>[937, 1001, 0]"]
36["Segment<br>[937, 1001, 0]"]
37["Segment<br>[937, 1001, 0]"]
38["Segment<br>[937, 1001, 0]"]
39["Segment<br>[937, 1001, 0]"]
40["Segment<br>[937, 1001, 0]"]
41["Segment<br>[937, 1001, 0]"]
42["Segment<br>[937, 1001, 0]"]
43["Segment<br>[937, 1001, 0]"]
44["Segment<br>[937, 1001, 0]"]
45["Segment<br>[937, 1001, 0]"]
46["Segment<br>[937, 1001, 0]"]
47["Segment<br>[937, 1001, 0]"]
48["Segment<br>[937, 1001, 0]"]
49["Segment<br>[937, 1001, 0]"]
50["Segment<br>[937, 1001, 0]"]
51["Segment<br>[937, 1001, 0]"]
52["Segment<br>[1065, 1083, 0]"]
53[Solid2d]
end
1["Plane<br>[731, 748, 0]"]
54["Sweep Extrusion<br>[1144, 1182, 0]"]
1["Plane<br>[724, 741, 0]"]
54["Sweep Extrusion<br>[1137, 1175, 0]"]
55[Wall]
56[Wall]
57[Wall]

View File

@ -122,38 +122,53 @@ description: Result of parsing loop_tag.kcl
"init": {
"commentStart": 0,
"end": 0,
"left": {
"expr": {
"commentStart": 0,
"end": 0,
"raw": "360",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 360.0,
"suffix": "None"
}
},
"operator": "/",
"right": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"left": {
"commentStart": 0,
"end": 0,
"name": "numSides",
"raw": "360",
"start": 0,
"type": "Identifier"
"type": "Literal",
"type": "Literal",
"value": {
"value": 360.0,
"suffix": "None"
}
},
"operator": "/",
"right": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "numSides",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
"ty": {
"Deg": null,
"commentStart": 0,
"end": 0,
"p_type": "Number",
"start": 0,
"type": "Primitive"
},
"type": "AscribedExpression",
"type": "AscribedExpression"
},
"start": 0,
"type": "VariableDeclarator"
@ -275,64 +290,20 @@ description: Result of parsing loop_tag.kcl
"right": {
"arguments": [
{
"abs_path": false,
"commentStart": 0,
"end": 0,
"left": {
"name": {
"commentStart": 0,
"end": 0,
"left": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "angle",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"operator": "*",
"right": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "PI",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"name": "angle",
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"operator": "/",
"right": {
"commentStart": 0,
"end": 0,
"raw": "180",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 180.0,
"suffix": "None"
}
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
"type": "Name",
"type": "Name"
}
],
"callee": {
@ -404,64 +375,20 @@ description: Result of parsing loop_tag.kcl
"right": {
"arguments": [
{
"abs_path": false,
"commentStart": 0,
"end": 0,
"left": {
"name": {
"commentStart": 0,
"end": 0,
"left": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "angle",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"operator": "*",
"right": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "PI",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"name": "angle",
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"operator": "/",
"right": {
"commentStart": 0,
"end": 0,
"raw": "180",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 180.0,
"suffix": "None"
}
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
"type": "Name",
"type": "Name"
}
],
"callee": {

View File

@ -9,13 +9,13 @@
radius = 10
height = 50
numSides = 50
angleIncrement = 360 / numSides
angleIncrement = (360 / numSides): number(deg)
// Function to calculate the coordinates of a point on the circle
fn calculatePoint(index) {
angle = index * angleIncrement
x = radius * cos(angle * PI / 180)
y = radius * sin(angle * PI / 180)
x = radius * cos(angle)
y = radius * sin(angle)
return [x, y]
}

File diff suppressed because it is too large Load Diff

View File

@ -16,13 +16,13 @@ description: Result of unparsing loop_tag.kcl
radius = 10
height = 50
numSides = 50
angleIncrement = 360 / numSides
angleIncrement = (360 / numSides): number(deg)
// Function to calculate the coordinates of a point on the circle
fn calculatePoint(index) {
angle = index * angleIncrement
x = radius * cos(angle * PI / 180)
y = radius * sin(angle * PI / 180)
x = radius * cos(angle)
y = radius * sin(angle)
return [x, y]
}