diff --git a/docs/kcl/patternTransform.md b/docs/kcl/patternTransform.md index 63bcc344b..7ea4da851 100644 --- a/docs/kcl/patternTransform.md +++ b/docs/kcl/patternTransform.md @@ -205,12 +205,12 @@ fn transform(i) { } startSketchOn(XY) |> startProfileAt([0, 0], %) - |> polygon({ + |> polygon( radius = 10, numSides = 4, center = [0, 0], - inscribed = false - }, %) + inscribed = false, + ) |> extrude(length = 4) |> patternTransform(instances = 3, transform = transform) ``` diff --git a/docs/kcl/polygon.md b/docs/kcl/polygon.md index b05fc198b..a8e5da938 100644 --- a/docs/kcl/polygon.md +++ b/docs/kcl/polygon.md @@ -10,9 +10,11 @@ Create a regular polygon with the specified number of sides that is either inscr ```js polygon( - data: PolygonData, sketchSurfaceOrGroup: SketchOrSurface, - tag?: TagDeclarator, + radius: number, + numSides: u64, + center: [number], + inscribed?: bool, ): Sketch ``` @@ -21,9 +23,11 @@ polygon( | Name | Type | Description | Required | |----------|------|-------------|----------| -| `data` | [`PolygonData`](/docs/kcl/types/PolygonData) | Data for drawing a polygon | Yes | -| `sketchSurfaceOrGroup` | [`SketchOrSurface`](/docs/kcl/types/SketchOrSurface) | A sketch surface or a sketch. | Yes | -| [`tag`](/docs/kcl/types/tag) | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No | +| `sketchSurfaceOrGroup` | [`SketchOrSurface`](/docs/kcl/types/SketchOrSurface) | Plane or surface to sketch on | Yes | +| `radius` | [`number`](/docs/kcl/types/number) | The radius of the polygon | Yes | +| `numSides` | `u64` | The number of sides in the polygon | Yes | +| `center` | [`[number]`](/docs/kcl/types/number) | The center point of the polygon | Yes | +| `inscribed` | [`bool`](/docs/kcl/types/bool) | Whether the polygon is inscribed (true, the default) or circumscribed (false) about a circle with the specified radius | No | ### Returns @@ -35,12 +39,12 @@ polygon( ```js // Create a regular hexagon inscribed in a circle of radius 10 hex = startSketchOn(XY) - |> polygon({ + |> polygon( radius = 10, numSides = 6, center = [0, 0], - inscribed = true - }, %) + inscribed = true, + ) example = extrude(hex, length = 5) ``` @@ -50,12 +54,12 @@ example = extrude(hex, length = 5) ```js // Create a square circumscribed around a circle of radius 5 square = startSketchOn(XY) - |> polygon({ + |> polygon( radius = 5.0, numSides = 4, center = [10, 10], - inscribed = false - }, %) + inscribed = false, + ) example = extrude(square, length = 5) ``` diff --git a/docs/kcl/std.json b/docs/kcl/std.json index 9adc56e8b..629cb6ab9 100644 --- a/docs/kcl/std.json +++ b/docs/kcl/std.json @@ -214527,7 +214527,7 @@ "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 |> startProfileAt(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 = [pow(1.1, i), pow(1.1, i), pow(0.9, i)],\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 |> startProfileAt(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))\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 |> startProfileAt([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)" + "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 |> startProfileAt([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)" ] }, { @@ -222664,62 +222664,8 @@ "summary": "Create a regular polygon with the specified number of sides that is either inscribed or circumscribed around a circle of the specified radius.", "description": "", "tags": [], - "keywordArguments": false, + "keywordArguments": true, "args": [ - { - "name": "data", - "type": "PolygonData", - "schema": { - "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", - "title": "PolygonData", - "description": "Data for drawing a polygon", - "type": "object", - "required": [ - "center", - "numSides", - "radius" - ], - "properties": { - "radius": { - "description": "The radius of the polygon", - "allOf": [ - { - "$ref": "#/components/schemas/TyF64" - } - ] - }, - "numSides": { - "description": "The number of sides in the polygon", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "center": { - "description": "The center point of the polygon", - "type": "array", - "items": { - "$ref": "#/components/schemas/TyF64" - }, - "maxItems": 2, - "minItems": 2 - }, - "inscribed": { - "description": "Whether the polygon is inscribed (true) or circumscribed (false) about a circle with the specified radius", - "default": true, - "type": "boolean" - } - }, - "definitions": { - "TyF64": { - "type": "number", - "format": "double" - } - } - }, - "required": true, - "includeInSnippet": true, - "labelRequired": true - }, { "name": "sketchSurfaceOrGroup", "type": "SketchOrSurface", @@ -222736,10 +222682,6 @@ } ], "definitions": { - "TyF64": { - "type": "number", - "format": "double" - }, "SketchSurface": { "description": "A sketch type.", "oneOf": [ @@ -224336,30 +224278,27 @@ } } ] + }, + "TyF64": { + "type": "number", + "format": "double" } } }, "required": true, "includeInSnippet": true, - "labelRequired": true + "description": "Plane or surface to sketch on", + "labelRequired": false }, { - "name": "tag", - "type": "TagNode", + "name": "radius", + "type": "number", "schema": { "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", - "title": "Nullable_TagDeclarator", - "allOf": [ - { - "$ref": "#/components/schemas/TagDeclarator" - } - ], - "nullable": true, + "title": "TyF64", + "type": "number", + "format": "double", "definitions": { - "TyF64": { - "type": "number", - "format": "double" - }, "SketchSurface": { "description": "A sketch type.", "oneOf": [ @@ -225956,10 +225895,4872 @@ } } ] + }, + "TyF64": { + "type": "number", + "format": "double" + } + } + }, + "required": true, + "includeInSnippet": true, + "description": "The radius of the polygon", + "labelRequired": true + }, + { + "name": "numSides", + "type": "u64", + "schema": { + "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", + "title": "uint64", + "type": "integer", + "format": "uint64", + "minimum": 0.0, + "definitions": { + "SketchSurface": { + "description": "A sketch type.", + "oneOf": [ + { + "type": "object", + "required": [ + "artifactId", + "id", + "origin", + "type", + "units", + "value", + "xAxis", + "yAxis", + "zAxis" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "plane" + ] + }, + "id": { + "description": "The id of the plane.", + "type": "string", + "format": "uuid" + }, + "artifactId": { + "description": "The artifact ID.", + "allOf": [ + { + "$ref": "#/components/schemas/ArtifactId" + } + ] + }, + "value": { + "$ref": "#/components/schemas/PlaneType" + }, + "origin": { + "description": "Origin of the plane.", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "xAxis": { + "description": "What should the plane's X axis be?", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "yAxis": { + "description": "What should the plane's Y axis be?", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "zAxis": { + "description": "The z-axis (normal).", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + } + } + }, + { + "description": "A face.", + "type": "object", + "required": [ + "artifactId", + "id", + "solid", + "type", + "units", + "value", + "xAxis", + "yAxis", + "zAxis" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "face" + ] + }, + "id": { + "description": "The id of the face.", + "type": "string", + "format": "uuid" + }, + "artifactId": { + "description": "The artifact ID.", + "allOf": [ + { + "$ref": "#/components/schemas/ArtifactId" + } + ] + }, + "value": { + "description": "The tag of the face.", + "type": "string" + }, + "xAxis": { + "description": "What should the face's X axis be?", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "yAxis": { + "description": "What should the face's Y axis be?", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "zAxis": { + "description": "The z-axis (normal).", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "solid": { + "description": "The solid the face is on.", + "allOf": [ + { + "$ref": "#/components/schemas/Solid" + } + ] + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + } + } + } + ] + }, + "ArtifactId": { + "type": "string", + "format": "uuid" + }, + "PlaneType": { + "description": "Type for a plane.", + "oneOf": [ + { + "type": "string", + "enum": [ + "XY", + "XZ", + "YZ" + ] + }, + { + "description": "A custom plane.", + "type": "string", + "enum": [ + "Custom" + ] + }, + { + "description": "A custom plane which has not been sent to the engine. It must be sent before it is used.", + "type": "string", + "enum": [ + "Uninit" + ] + } + ] + }, + "Point3d": { + "type": "object", + "required": [ + "units", + "x", + "y", + "z" + ], + "properties": { + "x": { + "type": "number", + "format": "double" + }, + "y": { + "type": "number", + "format": "double" + }, + "z": { + "type": "number", + "format": "double" + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + } + } + }, + "UnitLen": { + "description": "A unit of length.", + "oneOf": [ + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Mm" + ] + } + } + }, + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Cm" + ] + } + } + }, + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "M" + ] + } + } + }, + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Inches" + ] + } + } + }, + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Feet" + ] + } + } + }, + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Yards" + ] + } + } + }, + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Unknown" + ] + } + } + } + ] + }, + "Solid": { + "type": "object", + "required": [ + "artifactId", + "height", + "id", + "sketch", + "units", + "value" + ], + "properties": { + "id": { + "description": "The id of the solid.", + "type": "string", + "format": "uuid" + }, + "artifactId": { + "description": "The artifact ID of the solid. Unlike `id`, this doesn't change.", + "allOf": [ + { + "$ref": "#/components/schemas/ArtifactId" + } + ] + }, + "value": { + "description": "The extrude surfaces.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ExtrudeSurface" + } + }, + "sketch": { + "description": "The sketch.", + "allOf": [ + { + "$ref": "#/components/schemas/Sketch" + } + ] + }, + "height": { + "description": "The height of the solid.", + "type": "number", + "format": "double" + }, + "startCapId": { + "description": "The id of the extrusion start cap", + "type": "string", + "format": "uuid", + "nullable": true + }, + "endCapId": { + "description": "The id of the extrusion end cap", + "type": "string", + "format": "uuid", + "nullable": true + }, + "edgeCuts": { + "description": "Chamfers or fillets on this solid.", + "type": "array", + "items": { + "$ref": "#/components/schemas/EdgeCut" + } + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + } + } + }, + "ExtrudeSurface": { + "description": "An extrude surface.", + "oneOf": [ + { + "description": "An extrude plane.", + "type": "object", + "required": [ + "faceId", + "id", + "sourceRange", + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "extrudePlane" + ] + }, + "faceId": { + "description": "The face id for the extrude plane.", + "type": "string", + "format": "uuid" + }, + "tag": { + "description": "The tag.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "id": { + "description": "The id of the geometry.", + "type": "string", + "format": "uuid" + }, + "sourceRange": { + "description": "The source range.", + "allOf": [ + { + "$ref": "#/components/schemas/SourceRange" + } + ] + } + } + }, + { + "description": "An extruded arc.", + "type": "object", + "required": [ + "faceId", + "id", + "sourceRange", + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "extrudeArc" + ] + }, + "faceId": { + "description": "The face id for the extrude plane.", + "type": "string", + "format": "uuid" + }, + "tag": { + "description": "The tag.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "id": { + "description": "The id of the geometry.", + "type": "string", + "format": "uuid" + }, + "sourceRange": { + "description": "The source range.", + "allOf": [ + { + "$ref": "#/components/schemas/SourceRange" + } + ] + } + } + }, + { + "description": "Geometry metadata.", + "type": "object", + "required": [ + "faceId", + "id", + "sourceRange", + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "chamfer" + ] + }, + "faceId": { + "description": "The id for the chamfer surface.", + "type": "string", + "format": "uuid" + }, + "tag": { + "description": "The tag.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "id": { + "description": "The id of the geometry.", + "type": "string", + "format": "uuid" + }, + "sourceRange": { + "description": "The source range.", + "allOf": [ + { + "$ref": "#/components/schemas/SourceRange" + } + ] + } + } + }, + { + "description": "Geometry metadata.", + "type": "object", + "required": [ + "faceId", + "id", + "sourceRange", + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "fillet" + ] + }, + "faceId": { + "description": "The id for the fillet surface.", + "type": "string", + "format": "uuid" + }, + "tag": { + "description": "The tag.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "id": { + "description": "The id of the geometry.", + "type": "string", + "format": "uuid" + }, + "sourceRange": { + "description": "The source range.", + "allOf": [ + { + "$ref": "#/components/schemas/SourceRange" + } + ] + } + } + } + ] + }, + "TagDeclarator": { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "string" + }, + "digest": { + "type": "array", + "items": { + "type": "integer", + "format": "uint8", + "minimum": 0.0 + }, + "maxItems": 32, + "minItems": 32, + "nullable": true + }, + "start": { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + "end": { + "type": "integer", + "format": "uint", + "minimum": 0.0 + } + } + }, + "SourceRange": { + "description": "The first two items are the start and end points (byte offsets from the start of the file). The third item is whether the source range belongs to the 'main' file, i.e., the file currently being rendered/displayed in the editor.", + "type": "array", + "items": { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + "maxItems": 3, + "minItems": 3 + }, + "Sketch": { + "type": "object", + "required": [ + "artifactId", + "id", + "on", + "originalId", + "paths", + "start", + "units" + ], + "properties": { + "id": { + "description": "The id of the sketch (this will change when the engine's reference to it changes).", + "type": "string", + "format": "uuid" + }, + "paths": { + "description": "The paths in the sketch.", + "type": "array", + "items": { + "$ref": "#/components/schemas/Path" + } + }, + "on": { + "description": "What the sketch is on (can be a plane or a face).", + "allOf": [ + { + "$ref": "#/components/schemas/SketchSurface" + } + ] + }, + "start": { + "description": "The starting path.", + "allOf": [ + { + "$ref": "#/components/schemas/BasePath" + } + ] + }, + "tags": { + "description": "Tag identifiers that have been declared in this sketch.", + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/TagIdentifier" + } + }, + "artifactId": { + "description": "The original id of the sketch. This stays the same even if the sketch is is sketched on face etc.", + "allOf": [ + { + "$ref": "#/components/schemas/ArtifactId" + } + ] + }, + "originalId": { + "type": "string", + "format": "uuid" + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + } + } + }, + "Path": { + "description": "A path.", + "oneOf": [ + { + "description": "A path that goes to a point.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "ToPoint" + ] + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A arc that is tangential to the last path segment that goes to a point", + "type": "object", + "required": [ + "__geoMeta", + "ccw", + "center", + "from", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "TangentialArcTo" + ] + }, + "center": { + "description": "the arc's center", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "ccw": { + "description": "arc's direction", + "type": "boolean" + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A arc that is tangential to the last path segment", + "type": "object", + "required": [ + "__geoMeta", + "ccw", + "center", + "from", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "TangentialArc" + ] + }, + "center": { + "description": "the arc's center", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "ccw": { + "description": "arc's direction", + "type": "boolean" + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "a complete arc", + "type": "object", + "required": [ + "__geoMeta", + "ccw", + "center", + "from", + "radius", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Circle" + ] + }, + "center": { + "description": "the arc's center", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "radius": { + "description": "the arc's radius", + "type": "number", + "format": "double" + }, + "ccw": { + "description": "arc's direction This is used to compute the tangential angle.", + "type": "boolean" + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A base path.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "p1", + "p2", + "p3", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "CircleThreePoint" + ] + }, + "p1": { + "description": "Point 1 of the circle", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "p2": { + "description": "Point 2 of the circle", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "p3": { + "description": "Point 3 of the circle", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A base path.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "p1", + "p2", + "p3", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "ArcThreePoint" + ] + }, + "p1": { + "description": "Point 1 of the arc (base on the end of previous segment)", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "p2": { + "description": "Point 2 of the arc (interiorAbsolute kwarg)", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "p3": { + "description": "Point 3 of the arc (endAbsolute kwarg)", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A path that is horizontal.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "to", + "type", + "units", + "x" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Horizontal" + ] + }, + "x": { + "description": "The x coordinate.", + "type": "number", + "format": "double" + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "An angled line to.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "AngledLineTo" + ] + }, + "x": { + "description": "The x coordinate.", + "type": "number", + "format": "double", + "nullable": true + }, + "y": { + "description": "The y coordinate.", + "type": "number", + "format": "double", + "nullable": true + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A base path.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Base" + ] + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A circular arc, not necessarily tangential to the current point.", + "type": "object", + "required": [ + "__geoMeta", + "ccw", + "center", + "from", + "radius", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Arc" + ] + }, + "center": { + "description": "Center of the circle that this arc is drawn on.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "radius": { + "description": "Radius of the circle that this arc is drawn on.", + "type": "number", + "format": "double" + }, + "ccw": { + "description": "True if the arc is counterclockwise.", + "type": "boolean" + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + } + ] + }, + "GeoMeta": { + "description": "Geometry metadata.", + "type": "object", + "required": [ + "id", + "sourceRange" + ], + "properties": { + "id": { + "description": "The id of the geometry.", + "type": "string", + "format": "uuid" + }, + "sourceRange": { + "description": "The source range.", + "allOf": [ + { + "$ref": "#/components/schemas/SourceRange" + } + ] + } + } + }, + "BasePath": { + "description": "A base path.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "to", + "units" + ], + "properties": { + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + "TagIdentifier": { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "string" + } + } + }, + "EdgeCut": { + "description": "A fillet or a chamfer.", + "oneOf": [ + { + "description": "A fillet.", + "type": "object", + "required": [ + "edgeId", + "id", + "radius", + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "fillet" + ] + }, + "id": { + "description": "The id of the engine command that called this fillet.", + "type": "string", + "format": "uuid" + }, + "radius": { + "$ref": "#/components/schemas/TyF64" + }, + "edgeId": { + "description": "The engine id of the edge to fillet.", + "type": "string", + "format": "uuid" + }, + "tag": { + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + } + } + }, + { + "description": "A chamfer.", + "type": "object", + "required": [ + "edgeId", + "id", + "length", + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "chamfer" + ] + }, + "id": { + "description": "The id of the engine command that called this chamfer.", + "type": "string", + "format": "uuid" + }, + "length": { + "$ref": "#/components/schemas/TyF64" + }, + "edgeId": { + "description": "The engine id of the edge to chamfer.", + "type": "string", + "format": "uuid" + }, + "tag": { + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + } + } + } + ] + }, + "TyF64": { + "type": "number", + "format": "double" + } + } + }, + "required": true, + "includeInSnippet": true, + "description": "The number of sides in the polygon", + "labelRequired": true + }, + { + "name": "center", + "type": "[number]", + "schema": { + "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", + "title": "Array_size_2_of_double", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2, + "definitions": { + "SketchSurface": { + "description": "A sketch type.", + "oneOf": [ + { + "type": "object", + "required": [ + "artifactId", + "id", + "origin", + "type", + "units", + "value", + "xAxis", + "yAxis", + "zAxis" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "plane" + ] + }, + "id": { + "description": "The id of the plane.", + "type": "string", + "format": "uuid" + }, + "artifactId": { + "description": "The artifact ID.", + "allOf": [ + { + "$ref": "#/components/schemas/ArtifactId" + } + ] + }, + "value": { + "$ref": "#/components/schemas/PlaneType" + }, + "origin": { + "description": "Origin of the plane.", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "xAxis": { + "description": "What should the plane's X axis be?", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "yAxis": { + "description": "What should the plane's Y axis be?", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "zAxis": { + "description": "The z-axis (normal).", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + } + } + }, + { + "description": "A face.", + "type": "object", + "required": [ + "artifactId", + "id", + "solid", + "type", + "units", + "value", + "xAxis", + "yAxis", + "zAxis" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "face" + ] + }, + "id": { + "description": "The id of the face.", + "type": "string", + "format": "uuid" + }, + "artifactId": { + "description": "The artifact ID.", + "allOf": [ + { + "$ref": "#/components/schemas/ArtifactId" + } + ] + }, + "value": { + "description": "The tag of the face.", + "type": "string" + }, + "xAxis": { + "description": "What should the face's X axis be?", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "yAxis": { + "description": "What should the face's Y axis be?", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "zAxis": { + "description": "The z-axis (normal).", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "solid": { + "description": "The solid the face is on.", + "allOf": [ + { + "$ref": "#/components/schemas/Solid" + } + ] + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + } + } + } + ] + }, + "ArtifactId": { + "type": "string", + "format": "uuid" + }, + "PlaneType": { + "description": "Type for a plane.", + "oneOf": [ + { + "type": "string", + "enum": [ + "XY", + "XZ", + "YZ" + ] + }, + { + "description": "A custom plane.", + "type": "string", + "enum": [ + "Custom" + ] + }, + { + "description": "A custom plane which has not been sent to the engine. It must be sent before it is used.", + "type": "string", + "enum": [ + "Uninit" + ] + } + ] + }, + "Point3d": { + "type": "object", + "required": [ + "units", + "x", + "y", + "z" + ], + "properties": { + "x": { + "type": "number", + "format": "double" + }, + "y": { + "type": "number", + "format": "double" + }, + "z": { + "type": "number", + "format": "double" + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + } + } + }, + "UnitLen": { + "description": "A unit of length.", + "oneOf": [ + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Mm" + ] + } + } + }, + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Cm" + ] + } + } + }, + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "M" + ] + } + } + }, + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Inches" + ] + } + } + }, + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Feet" + ] + } + } + }, + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Yards" + ] + } + } + }, + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Unknown" + ] + } + } + } + ] + }, + "Solid": { + "type": "object", + "required": [ + "artifactId", + "height", + "id", + "sketch", + "units", + "value" + ], + "properties": { + "id": { + "description": "The id of the solid.", + "type": "string", + "format": "uuid" + }, + "artifactId": { + "description": "The artifact ID of the solid. Unlike `id`, this doesn't change.", + "allOf": [ + { + "$ref": "#/components/schemas/ArtifactId" + } + ] + }, + "value": { + "description": "The extrude surfaces.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ExtrudeSurface" + } + }, + "sketch": { + "description": "The sketch.", + "allOf": [ + { + "$ref": "#/components/schemas/Sketch" + } + ] + }, + "height": { + "description": "The height of the solid.", + "type": "number", + "format": "double" + }, + "startCapId": { + "description": "The id of the extrusion start cap", + "type": "string", + "format": "uuid", + "nullable": true + }, + "endCapId": { + "description": "The id of the extrusion end cap", + "type": "string", + "format": "uuid", + "nullable": true + }, + "edgeCuts": { + "description": "Chamfers or fillets on this solid.", + "type": "array", + "items": { + "$ref": "#/components/schemas/EdgeCut" + } + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + } + } + }, + "ExtrudeSurface": { + "description": "An extrude surface.", + "oneOf": [ + { + "description": "An extrude plane.", + "type": "object", + "required": [ + "faceId", + "id", + "sourceRange", + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "extrudePlane" + ] + }, + "faceId": { + "description": "The face id for the extrude plane.", + "type": "string", + "format": "uuid" + }, + "tag": { + "description": "The tag.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "id": { + "description": "The id of the geometry.", + "type": "string", + "format": "uuid" + }, + "sourceRange": { + "description": "The source range.", + "allOf": [ + { + "$ref": "#/components/schemas/SourceRange" + } + ] + } + } + }, + { + "description": "An extruded arc.", + "type": "object", + "required": [ + "faceId", + "id", + "sourceRange", + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "extrudeArc" + ] + }, + "faceId": { + "description": "The face id for the extrude plane.", + "type": "string", + "format": "uuid" + }, + "tag": { + "description": "The tag.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "id": { + "description": "The id of the geometry.", + "type": "string", + "format": "uuid" + }, + "sourceRange": { + "description": "The source range.", + "allOf": [ + { + "$ref": "#/components/schemas/SourceRange" + } + ] + } + } + }, + { + "description": "Geometry metadata.", + "type": "object", + "required": [ + "faceId", + "id", + "sourceRange", + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "chamfer" + ] + }, + "faceId": { + "description": "The id for the chamfer surface.", + "type": "string", + "format": "uuid" + }, + "tag": { + "description": "The tag.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "id": { + "description": "The id of the geometry.", + "type": "string", + "format": "uuid" + }, + "sourceRange": { + "description": "The source range.", + "allOf": [ + { + "$ref": "#/components/schemas/SourceRange" + } + ] + } + } + }, + { + "description": "Geometry metadata.", + "type": "object", + "required": [ + "faceId", + "id", + "sourceRange", + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "fillet" + ] + }, + "faceId": { + "description": "The id for the fillet surface.", + "type": "string", + "format": "uuid" + }, + "tag": { + "description": "The tag.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "id": { + "description": "The id of the geometry.", + "type": "string", + "format": "uuid" + }, + "sourceRange": { + "description": "The source range.", + "allOf": [ + { + "$ref": "#/components/schemas/SourceRange" + } + ] + } + } + } + ] + }, + "TagDeclarator": { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "string" + }, + "digest": { + "type": "array", + "items": { + "type": "integer", + "format": "uint8", + "minimum": 0.0 + }, + "maxItems": 32, + "minItems": 32, + "nullable": true + }, + "start": { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + "end": { + "type": "integer", + "format": "uint", + "minimum": 0.0 + } + } + }, + "SourceRange": { + "description": "The first two items are the start and end points (byte offsets from the start of the file). The third item is whether the source range belongs to the 'main' file, i.e., the file currently being rendered/displayed in the editor.", + "type": "array", + "items": { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + "maxItems": 3, + "minItems": 3 + }, + "Sketch": { + "type": "object", + "required": [ + "artifactId", + "id", + "on", + "originalId", + "paths", + "start", + "units" + ], + "properties": { + "id": { + "description": "The id of the sketch (this will change when the engine's reference to it changes).", + "type": "string", + "format": "uuid" + }, + "paths": { + "description": "The paths in the sketch.", + "type": "array", + "items": { + "$ref": "#/components/schemas/Path" + } + }, + "on": { + "description": "What the sketch is on (can be a plane or a face).", + "allOf": [ + { + "$ref": "#/components/schemas/SketchSurface" + } + ] + }, + "start": { + "description": "The starting path.", + "allOf": [ + { + "$ref": "#/components/schemas/BasePath" + } + ] + }, + "tags": { + "description": "Tag identifiers that have been declared in this sketch.", + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/TagIdentifier" + } + }, + "artifactId": { + "description": "The original id of the sketch. This stays the same even if the sketch is is sketched on face etc.", + "allOf": [ + { + "$ref": "#/components/schemas/ArtifactId" + } + ] + }, + "originalId": { + "type": "string", + "format": "uuid" + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + } + } + }, + "Path": { + "description": "A path.", + "oneOf": [ + { + "description": "A path that goes to a point.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "ToPoint" + ] + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A arc that is tangential to the last path segment that goes to a point", + "type": "object", + "required": [ + "__geoMeta", + "ccw", + "center", + "from", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "TangentialArcTo" + ] + }, + "center": { + "description": "the arc's center", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "ccw": { + "description": "arc's direction", + "type": "boolean" + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A arc that is tangential to the last path segment", + "type": "object", + "required": [ + "__geoMeta", + "ccw", + "center", + "from", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "TangentialArc" + ] + }, + "center": { + "description": "the arc's center", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "ccw": { + "description": "arc's direction", + "type": "boolean" + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "a complete arc", + "type": "object", + "required": [ + "__geoMeta", + "ccw", + "center", + "from", + "radius", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Circle" + ] + }, + "center": { + "description": "the arc's center", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "radius": { + "description": "the arc's radius", + "type": "number", + "format": "double" + }, + "ccw": { + "description": "arc's direction This is used to compute the tangential angle.", + "type": "boolean" + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A base path.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "p1", + "p2", + "p3", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "CircleThreePoint" + ] + }, + "p1": { + "description": "Point 1 of the circle", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "p2": { + "description": "Point 2 of the circle", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "p3": { + "description": "Point 3 of the circle", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A base path.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "p1", + "p2", + "p3", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "ArcThreePoint" + ] + }, + "p1": { + "description": "Point 1 of the arc (base on the end of previous segment)", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "p2": { + "description": "Point 2 of the arc (interiorAbsolute kwarg)", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "p3": { + "description": "Point 3 of the arc (endAbsolute kwarg)", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A path that is horizontal.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "to", + "type", + "units", + "x" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Horizontal" + ] + }, + "x": { + "description": "The x coordinate.", + "type": "number", + "format": "double" + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "An angled line to.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "AngledLineTo" + ] + }, + "x": { + "description": "The x coordinate.", + "type": "number", + "format": "double", + "nullable": true + }, + "y": { + "description": "The y coordinate.", + "type": "number", + "format": "double", + "nullable": true + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A base path.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Base" + ] + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A circular arc, not necessarily tangential to the current point.", + "type": "object", + "required": [ + "__geoMeta", + "ccw", + "center", + "from", + "radius", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Arc" + ] + }, + "center": { + "description": "Center of the circle that this arc is drawn on.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "radius": { + "description": "Radius of the circle that this arc is drawn on.", + "type": "number", + "format": "double" + }, + "ccw": { + "description": "True if the arc is counterclockwise.", + "type": "boolean" + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + } + ] + }, + "GeoMeta": { + "description": "Geometry metadata.", + "type": "object", + "required": [ + "id", + "sourceRange" + ], + "properties": { + "id": { + "description": "The id of the geometry.", + "type": "string", + "format": "uuid" + }, + "sourceRange": { + "description": "The source range.", + "allOf": [ + { + "$ref": "#/components/schemas/SourceRange" + } + ] + } + } + }, + "BasePath": { + "description": "A base path.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "to", + "units" + ], + "properties": { + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + "TagIdentifier": { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "string" + } + } + }, + "EdgeCut": { + "description": "A fillet or a chamfer.", + "oneOf": [ + { + "description": "A fillet.", + "type": "object", + "required": [ + "edgeId", + "id", + "radius", + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "fillet" + ] + }, + "id": { + "description": "The id of the engine command that called this fillet.", + "type": "string", + "format": "uuid" + }, + "radius": { + "$ref": "#/components/schemas/TyF64" + }, + "edgeId": { + "description": "The engine id of the edge to fillet.", + "type": "string", + "format": "uuid" + }, + "tag": { + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + } + } + }, + { + "description": "A chamfer.", + "type": "object", + "required": [ + "edgeId", + "id", + "length", + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "chamfer" + ] + }, + "id": { + "description": "The id of the engine command that called this chamfer.", + "type": "string", + "format": "uuid" + }, + "length": { + "$ref": "#/components/schemas/TyF64" + }, + "edgeId": { + "description": "The engine id of the edge to chamfer.", + "type": "string", + "format": "uuid" + }, + "tag": { + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + } + } + } + ] + }, + "TyF64": { + "type": "number", + "format": "double" + } + } + }, + "required": true, + "includeInSnippet": true, + "description": "The center point of the polygon", + "labelRequired": true + }, + { + "name": "inscribed", + "type": "bool", + "schema": { + "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", + "title": "Nullable_Boolean", + "type": "boolean", + "nullable": true, + "definitions": { + "SketchSurface": { + "description": "A sketch type.", + "oneOf": [ + { + "type": "object", + "required": [ + "artifactId", + "id", + "origin", + "type", + "units", + "value", + "xAxis", + "yAxis", + "zAxis" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "plane" + ] + }, + "id": { + "description": "The id of the plane.", + "type": "string", + "format": "uuid" + }, + "artifactId": { + "description": "The artifact ID.", + "allOf": [ + { + "$ref": "#/components/schemas/ArtifactId" + } + ] + }, + "value": { + "$ref": "#/components/schemas/PlaneType" + }, + "origin": { + "description": "Origin of the plane.", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "xAxis": { + "description": "What should the plane's X axis be?", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "yAxis": { + "description": "What should the plane's Y axis be?", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "zAxis": { + "description": "The z-axis (normal).", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + } + } + }, + { + "description": "A face.", + "type": "object", + "required": [ + "artifactId", + "id", + "solid", + "type", + "units", + "value", + "xAxis", + "yAxis", + "zAxis" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "face" + ] + }, + "id": { + "description": "The id of the face.", + "type": "string", + "format": "uuid" + }, + "artifactId": { + "description": "The artifact ID.", + "allOf": [ + { + "$ref": "#/components/schemas/ArtifactId" + } + ] + }, + "value": { + "description": "The tag of the face.", + "type": "string" + }, + "xAxis": { + "description": "What should the face's X axis be?", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "yAxis": { + "description": "What should the face's Y axis be?", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "zAxis": { + "description": "The z-axis (normal).", + "allOf": [ + { + "$ref": "#/components/schemas/Point3d" + } + ] + }, + "solid": { + "description": "The solid the face is on.", + "allOf": [ + { + "$ref": "#/components/schemas/Solid" + } + ] + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + } + } + } + ] + }, + "ArtifactId": { + "type": "string", + "format": "uuid" + }, + "PlaneType": { + "description": "Type for a plane.", + "oneOf": [ + { + "type": "string", + "enum": [ + "XY", + "XZ", + "YZ" + ] + }, + { + "description": "A custom plane.", + "type": "string", + "enum": [ + "Custom" + ] + }, + { + "description": "A custom plane which has not been sent to the engine. It must be sent before it is used.", + "type": "string", + "enum": [ + "Uninit" + ] + } + ] + }, + "Point3d": { + "type": "object", + "required": [ + "units", + "x", + "y", + "z" + ], + "properties": { + "x": { + "type": "number", + "format": "double" + }, + "y": { + "type": "number", + "format": "double" + }, + "z": { + "type": "number", + "format": "double" + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + } + } + }, + "UnitLen": { + "description": "A unit of length.", + "oneOf": [ + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Mm" + ] + } + } + }, + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Cm" + ] + } + } + }, + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "M" + ] + } + } + }, + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Inches" + ] + } + } + }, + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Feet" + ] + } + } + }, + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Yards" + ] + } + } + }, + { + "type": "object", + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Unknown" + ] + } + } + } + ] + }, + "Solid": { + "type": "object", + "required": [ + "artifactId", + "height", + "id", + "sketch", + "units", + "value" + ], + "properties": { + "id": { + "description": "The id of the solid.", + "type": "string", + "format": "uuid" + }, + "artifactId": { + "description": "The artifact ID of the solid. Unlike `id`, this doesn't change.", + "allOf": [ + { + "$ref": "#/components/schemas/ArtifactId" + } + ] + }, + "value": { + "description": "The extrude surfaces.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ExtrudeSurface" + } + }, + "sketch": { + "description": "The sketch.", + "allOf": [ + { + "$ref": "#/components/schemas/Sketch" + } + ] + }, + "height": { + "description": "The height of the solid.", + "type": "number", + "format": "double" + }, + "startCapId": { + "description": "The id of the extrusion start cap", + "type": "string", + "format": "uuid", + "nullable": true + }, + "endCapId": { + "description": "The id of the extrusion end cap", + "type": "string", + "format": "uuid", + "nullable": true + }, + "edgeCuts": { + "description": "Chamfers or fillets on this solid.", + "type": "array", + "items": { + "$ref": "#/components/schemas/EdgeCut" + } + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + } + } + }, + "ExtrudeSurface": { + "description": "An extrude surface.", + "oneOf": [ + { + "description": "An extrude plane.", + "type": "object", + "required": [ + "faceId", + "id", + "sourceRange", + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "extrudePlane" + ] + }, + "faceId": { + "description": "The face id for the extrude plane.", + "type": "string", + "format": "uuid" + }, + "tag": { + "description": "The tag.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "id": { + "description": "The id of the geometry.", + "type": "string", + "format": "uuid" + }, + "sourceRange": { + "description": "The source range.", + "allOf": [ + { + "$ref": "#/components/schemas/SourceRange" + } + ] + } + } + }, + { + "description": "An extruded arc.", + "type": "object", + "required": [ + "faceId", + "id", + "sourceRange", + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "extrudeArc" + ] + }, + "faceId": { + "description": "The face id for the extrude plane.", + "type": "string", + "format": "uuid" + }, + "tag": { + "description": "The tag.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "id": { + "description": "The id of the geometry.", + "type": "string", + "format": "uuid" + }, + "sourceRange": { + "description": "The source range.", + "allOf": [ + { + "$ref": "#/components/schemas/SourceRange" + } + ] + } + } + }, + { + "description": "Geometry metadata.", + "type": "object", + "required": [ + "faceId", + "id", + "sourceRange", + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "chamfer" + ] + }, + "faceId": { + "description": "The id for the chamfer surface.", + "type": "string", + "format": "uuid" + }, + "tag": { + "description": "The tag.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "id": { + "description": "The id of the geometry.", + "type": "string", + "format": "uuid" + }, + "sourceRange": { + "description": "The source range.", + "allOf": [ + { + "$ref": "#/components/schemas/SourceRange" + } + ] + } + } + }, + { + "description": "Geometry metadata.", + "type": "object", + "required": [ + "faceId", + "id", + "sourceRange", + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "fillet" + ] + }, + "faceId": { + "description": "The id for the fillet surface.", + "type": "string", + "format": "uuid" + }, + "tag": { + "description": "The tag.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "id": { + "description": "The id of the geometry.", + "type": "string", + "format": "uuid" + }, + "sourceRange": { + "description": "The source range.", + "allOf": [ + { + "$ref": "#/components/schemas/SourceRange" + } + ] + } + } + } + ] + }, + "TagDeclarator": { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "string" + }, + "digest": { + "type": "array", + "items": { + "type": "integer", + "format": "uint8", + "minimum": 0.0 + }, + "maxItems": 32, + "minItems": 32, + "nullable": true + }, + "start": { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + "end": { + "type": "integer", + "format": "uint", + "minimum": 0.0 + } + } + }, + "SourceRange": { + "description": "The first two items are the start and end points (byte offsets from the start of the file). The third item is whether the source range belongs to the 'main' file, i.e., the file currently being rendered/displayed in the editor.", + "type": "array", + "items": { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + "maxItems": 3, + "minItems": 3 + }, + "Sketch": { + "type": "object", + "required": [ + "artifactId", + "id", + "on", + "originalId", + "paths", + "start", + "units" + ], + "properties": { + "id": { + "description": "The id of the sketch (this will change when the engine's reference to it changes).", + "type": "string", + "format": "uuid" + }, + "paths": { + "description": "The paths in the sketch.", + "type": "array", + "items": { + "$ref": "#/components/schemas/Path" + } + }, + "on": { + "description": "What the sketch is on (can be a plane or a face).", + "allOf": [ + { + "$ref": "#/components/schemas/SketchSurface" + } + ] + }, + "start": { + "description": "The starting path.", + "allOf": [ + { + "$ref": "#/components/schemas/BasePath" + } + ] + }, + "tags": { + "description": "Tag identifiers that have been declared in this sketch.", + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/TagIdentifier" + } + }, + "artifactId": { + "description": "The original id of the sketch. This stays the same even if the sketch is is sketched on face etc.", + "allOf": [ + { + "$ref": "#/components/schemas/ArtifactId" + } + ] + }, + "originalId": { + "type": "string", + "format": "uuid" + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + } + } + }, + "Path": { + "description": "A path.", + "oneOf": [ + { + "description": "A path that goes to a point.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "ToPoint" + ] + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A arc that is tangential to the last path segment that goes to a point", + "type": "object", + "required": [ + "__geoMeta", + "ccw", + "center", + "from", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "TangentialArcTo" + ] + }, + "center": { + "description": "the arc's center", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "ccw": { + "description": "arc's direction", + "type": "boolean" + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A arc that is tangential to the last path segment", + "type": "object", + "required": [ + "__geoMeta", + "ccw", + "center", + "from", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "TangentialArc" + ] + }, + "center": { + "description": "the arc's center", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "ccw": { + "description": "arc's direction", + "type": "boolean" + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "a complete arc", + "type": "object", + "required": [ + "__geoMeta", + "ccw", + "center", + "from", + "radius", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Circle" + ] + }, + "center": { + "description": "the arc's center", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "radius": { + "description": "the arc's radius", + "type": "number", + "format": "double" + }, + "ccw": { + "description": "arc's direction This is used to compute the tangential angle.", + "type": "boolean" + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A base path.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "p1", + "p2", + "p3", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "CircleThreePoint" + ] + }, + "p1": { + "description": "Point 1 of the circle", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "p2": { + "description": "Point 2 of the circle", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "p3": { + "description": "Point 3 of the circle", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A base path.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "p1", + "p2", + "p3", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "ArcThreePoint" + ] + }, + "p1": { + "description": "Point 1 of the arc (base on the end of previous segment)", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "p2": { + "description": "Point 2 of the arc (interiorAbsolute kwarg)", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "p3": { + "description": "Point 3 of the arc (endAbsolute kwarg)", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A path that is horizontal.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "to", + "type", + "units", + "x" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Horizontal" + ] + }, + "x": { + "description": "The x coordinate.", + "type": "number", + "format": "double" + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "An angled line to.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "AngledLineTo" + ] + }, + "x": { + "description": "The x coordinate.", + "type": "number", + "format": "double", + "nullable": true + }, + "y": { + "description": "The y coordinate.", + "type": "number", + "format": "double", + "nullable": true + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A base path.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Base" + ] + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + { + "description": "A circular arc, not necessarily tangential to the current point.", + "type": "object", + "required": [ + "__geoMeta", + "ccw", + "center", + "from", + "radius", + "to", + "type", + "units" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "Arc" + ] + }, + "center": { + "description": "Center of the circle that this arc is drawn on.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "radius": { + "description": "Radius of the circle that this arc is drawn on.", + "type": "number", + "format": "double" + }, + "ccw": { + "description": "True if the arc is counterclockwise.", + "type": "boolean" + }, + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + } + ] + }, + "GeoMeta": { + "description": "Geometry metadata.", + "type": "object", + "required": [ + "id", + "sourceRange" + ], + "properties": { + "id": { + "description": "The id of the geometry.", + "type": "string", + "format": "uuid" + }, + "sourceRange": { + "description": "The source range.", + "allOf": [ + { + "$ref": "#/components/schemas/SourceRange" + } + ] + } + } + }, + "BasePath": { + "description": "A base path.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "to", + "units" + ], + "properties": { + "from": { + "description": "The from point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "to": { + "description": "The to point.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 2, + "minItems": 2 + }, + "units": { + "$ref": "#/components/schemas/UnitLen" + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + }, + "TagIdentifier": { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "string" + } + } + }, + "EdgeCut": { + "description": "A fillet or a chamfer.", + "oneOf": [ + { + "description": "A fillet.", + "type": "object", + "required": [ + "edgeId", + "id", + "radius", + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "fillet" + ] + }, + "id": { + "description": "The id of the engine command that called this fillet.", + "type": "string", + "format": "uuid" + }, + "radius": { + "$ref": "#/components/schemas/TyF64" + }, + "edgeId": { + "description": "The engine id of the edge to fillet.", + "type": "string", + "format": "uuid" + }, + "tag": { + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + } + } + }, + { + "description": "A chamfer.", + "type": "object", + "required": [ + "edgeId", + "id", + "length", + "type" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "chamfer" + ] + }, + "id": { + "description": "The id of the engine command that called this chamfer.", + "type": "string", + "format": "uuid" + }, + "length": { + "$ref": "#/components/schemas/TyF64" + }, + "edgeId": { + "description": "The engine id of the edge to chamfer.", + "type": "string", + "format": "uuid" + }, + "tag": { + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + } + } + } + ] + }, + "TyF64": { + "type": "number", + "format": "double" } } }, "required": false, + "description": "Whether the polygon is inscribed (true, the default) or circumscribed (false) about a circle with the specified radius", "labelRequired": true } ], @@ -227642,8 +232443,8 @@ "unpublished": false, "deprecated": false, "examples": [ - "// Create a regular hexagon inscribed in a circle of radius 10\nhex = startSketchOn(XY)\n |> polygon({\n radius = 10,\n numSides = 6,\n center = [0, 0],\n inscribed = true\n }, %)\n\nexample = extrude(hex, length = 5)", - "// Create a square circumscribed around a circle of radius 5\nsquare = startSketchOn(XY)\n |> polygon({\n radius = 5.0,\n numSides = 4,\n center = [10, 10],\n inscribed = false\n }, %)\nexample = extrude(square, length = 5)" + "// Create a regular hexagon inscribed in a circle of radius 10\nhex = startSketchOn(XY)\n |> polygon(\n radius = 10,\n numSides = 6,\n center = [0, 0],\n inscribed = true,\n )\n\nexample = extrude(hex, length = 5)", + "// Create a square circumscribed around a circle of radius 5\nsquare = startSketchOn(XY)\n |> polygon(\n radius = 5.0,\n numSides = 4,\n center = [10, 10],\n inscribed = false,\n )\nexample = extrude(square, length = 5)" ] }, { diff --git a/e2e/playwright/native-file-menu.spec.ts b/e2e/playwright/native-file-menu.spec.ts index f8d571ac0..4479e4cca 100644 --- a/e2e/playwright/native-file-menu.spec.ts +++ b/e2e/playwright/native-file-menu.spec.ts @@ -21,8 +21,9 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => { if (!app || !app.applicationMenu) { return false } - const newProject = - app.applicationMenu.getMenuItemById('File.New project') + const newProject = app.applicationMenu.getMenuItemById( + 'File.Create project' + ) if (!newProject) return false newProject.click() return true @@ -484,8 +485,9 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => { await page.waitForTimeout(100) // wait for createModelingPageMenu() to run await tronApp.electron.evaluate(async ({ app }) => { if (!app || !app.applicationMenu) fail() - const newProject = - app.applicationMenu.getMenuItemById('File.New project') + const newProject = app.applicationMenu.getMenuItemById( + 'File.Create project' + ) if (!newProject) fail() newProject.click() }) @@ -608,7 +610,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => { const expected = 'Export' expect(actual).toBe(expected) }) - test('Modeling.File.Share current part (via Zoo link)', async ({ + test('Modeling.File.Share part via Zoo link', async ({ tronApp, cmdBar, page, @@ -629,10 +631,10 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => { throw new Error('app or app.applicationMenu is missing') } const openProject = app.applicationMenu.getMenuItemById( - 'File.Share current part (via Zoo link)' + 'File.Share part via Zoo link' ) if (!openProject) { - throw new Error('File.Share current part (via Zoo link)') + throw new Error('File.Share part via Zoo link') } openProject.click() }) diff --git a/public/kcl-samples/bench/bench-parts.kcl b/public/kcl-samples/bench/bench-parts.kcl index 9fbf48b20..34694e937 100644 --- a/public/kcl-samples/bench/bench-parts.kcl +++ b/public/kcl-samples/bench/bench-parts.kcl @@ -46,12 +46,12 @@ export fn divider(plane) { fn connectorSketch(plane, start) { sketch001 = startSketchOn(plane) |> startProfileAt(start, %) - |> polygon({ + |> polygon( radius = 1.2, numSides = 6, center = profileStart(%), - inscribed = false - }, %) + inscribed = false, + ) return sketch001 } diff --git a/public/kcl-samples/dodecahedron/main.kcl b/public/kcl-samples/dodecahedron/main.kcl index 44522172e..11150fc68 100644 --- a/public/kcl-samples/dodecahedron/main.kcl +++ b/public/kcl-samples/dodecahedron/main.kcl @@ -38,20 +38,20 @@ plane = { // Create a regular pentagon inscribed in a circle of radius pentR bottomFace = startSketchOn(XY) - |> polygon({ + |> polygon( radius = pentR, numSides = 5, center = [0, 0], - inscribed = true - }, %) + inscribed = true, + ) bottomSideFace = startSketchOn(plane) - |> polygon({ + |> polygon( radius = pentR, numSides = 5, center = [0, 0], - inscribed = true - }, %) + inscribed = true, + ) // Extrude the faces in each plane bottom = extrude(bottomFace, length = wallThickness) diff --git a/rust/kcl-lib/src/execution/types.rs b/rust/kcl-lib/src/execution/types.rs index daa4711b8..20ecde9ec 100644 --- a/rust/kcl-lib/src/execution/types.rs +++ b/rust/kcl-lib/src/execution/types.rs @@ -66,6 +66,10 @@ impl RuntimeType { RuntimeType::Primitive(PrimitiveType::Plane) } + pub fn bool() -> Self { + RuntimeType::Primitive(PrimitiveType::Boolean) + } + pub fn string() -> Self { RuntimeType::Primitive(PrimitiveType::String) } diff --git a/rust/kcl-lib/src/std/args.rs b/rust/kcl-lib/src/std/args.rs index 771977896..bfe1f68f4 100644 --- a/rust/kcl-lib/src/std/args.rs +++ b/rust/kcl-lib/src/std/args.rs @@ -775,19 +775,6 @@ impl Args { source_ranges: vec![self.source_range], })) } - - pub(crate) fn get_polygon_args( - &self, - ) -> Result< - ( - crate::std::shapes::PolygonData, - crate::std::shapes::SketchOrSurface, - Option, - ), - KclError, - > { - FromArgs::from_args(self, 0) - } } /// Types which impl this trait can be read out of the `Args` passed into a KCL function. @@ -963,28 +950,6 @@ macro_rules! let_field_of { }; } -impl<'a> FromKclValue<'a> for super::shapes::PolygonData { - fn from_kcl_val(arg: &'a KclValue) -> Option { - let obj = arg.as_object()?; - let_field_of!(obj, radius); - let_field_of!(obj, num_sides "numSides"); - let_field_of!(obj, center); - let_field_of!(obj, inscribed); - let polygon_type = if inscribed { - PolygonType::Inscribed - } else { - PolygonType::Circumscribed - }; - Some(Self { - radius, - num_sides, - center, - polygon_type, - inscribed, - }) - } -} - impl<'a> FromKclValue<'a> for crate::execution::Plane { fn from_kcl_val(arg: &'a KclValue) -> Option { arg.as_plane().cloned() diff --git a/rust/kcl-lib/src/std/patterns.rs b/rust/kcl-lib/src/std/patterns.rs index 2777fe2c6..0aec7e925 100644 --- a/rust/kcl-lib/src/std/patterns.rs +++ b/rust/kcl-lib/src/std/patterns.rs @@ -245,12 +245,12 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res /// } /// startSketchOn('XY') /// |> startProfileAt([0, 0], %) -/// |> polygon({ -/// radius: 10, -/// numSides: 4, -/// center: [0, 0], -/// inscribed: false -/// }, %) +/// |> polygon( +/// radius = 10, +/// numSides = 4, +/// center = [0, 0], +/// inscribed = false, +/// ) /// |> extrude(length = 4) /// |> patternTransform(instances = 3, transform = transform) /// ``` diff --git a/rust/kcl-lib/src/std/shapes.rs b/rust/kcl-lib/src/std/shapes.rs index 0f74cf03b..1aee24435 100644 --- a/rust/kcl-lib/src/std/shapes.rs +++ b/rust/kcl-lib/src/std/shapes.rs @@ -13,6 +13,7 @@ use kittycad_modeling_cmds::shared::PathSegment; use schemars::JsonSchema; use serde::Serialize; +use super::{args::TyF64, utils::untype_point}; use crate::{ errors::{KclError, KclErrorDetails}, execution::{types::RuntimeType, BasePath, ExecState, GeoMeta, KclValue, Path, Sketch, SketchSurface}, @@ -24,8 +25,6 @@ use crate::{ }, }; -use super::{args::TyF64, utils::untype_point}; - /// A sketch surface or a sketch. #[derive(Debug, Clone, Serialize, PartialEq, ts_rs::TS, JsonSchema)] #[ts(export)] @@ -259,35 +258,24 @@ pub enum PolygonType { Circumscribed, } -/// Data for drawing a polygon -#[derive(Debug, Clone, Serialize, PartialEq, ts_rs::TS, JsonSchema)] -#[ts(export)] -#[serde(rename_all = "camelCase")] -pub struct PolygonData { - /// The radius of the polygon - pub radius: TyF64, - /// The number of sides in the polygon - pub num_sides: u64, - /// The center point of the polygon - pub center: [TyF64; 2], - /// The type of the polygon (inscribed or circumscribed) - #[serde(skip)] - pub polygon_type: PolygonType, - /// Whether the polygon is inscribed (true) or circumscribed (false) about a circle with the specified radius - #[serde(default = "default_inscribed")] - pub inscribed: bool, -} - -fn default_inscribed() -> bool { - true -} - /// Create a regular polygon with the specified number of sides and radius. pub async fn polygon(exec_state: &mut ExecState, args: Args) -> Result { - let (data, sketch_surface_or_group, tag): (PolygonData, SketchOrSurface, Option) = - args.get_polygon_args()?; + let sketch_surface_or_group = args.get_unlabeled_kw_arg("sketchOrSurface")?; + let radius: TyF64 = args.get_kw_arg_typed("radius", &RuntimeType::length(), exec_state)?; + let num_sides: TyF64 = args.get_kw_arg_typed("numSides", &RuntimeType::count(), exec_state)?; + let center = args.get_kw_arg_typed("center", &RuntimeType::point2d(), exec_state)?; + let inscribed = args.get_kw_arg_opt_typed("inscribed", &RuntimeType::bool(), exec_state)?; - let sketch = inner_polygon(data, sketch_surface_or_group, tag, exec_state, args).await?; + let sketch = inner_polygon( + sketch_surface_or_group, + radius, + num_sides.n as u64, + untype_point(center).0, + inscribed, + exec_state, + args, + ) + .await?; Ok(KclValue::Sketch { value: Box::new(sketch), }) @@ -298,12 +286,12 @@ pub async fn polygon(exec_state: &mut ExecState, args: Args) -> Result polygon({ +/// |> polygon( /// radius = 10, /// numSides = 6, /// center = [0, 0], /// inscribed = true, -/// }, %) +/// ) /// /// example = extrude(hex, length = 5) /// ``` @@ -311,32 +299,44 @@ pub async fn polygon(exec_state: &mut ExecState, args: Args) -> Result polygon({ +/// |> polygon( /// radius = 5.0, /// numSides = 4, /// center = [10, 10], /// inscribed = false, -/// }, %) +/// ) /// example = extrude(square, length = 5) /// ``` #[stdlib { name = "polygon", + keywords = true, + unlabeled_first = true, + args = { + sketch_surface_or_group = { docs = "Plane or surface to sketch on" }, + radius = { docs = "The radius of the polygon", include_in_snippet = true }, + num_sides = { docs = "The number of sides in the polygon", include_in_snippet = true }, + center = { docs = "The center point of the polygon", include_in_snippet = true }, + inscribed = { docs = "Whether the polygon is inscribed (true, the default) or circumscribed (false) about a circle with the specified radius" }, + } }] +#[allow(clippy::too_many_arguments)] async fn inner_polygon( - data: PolygonData, sketch_surface_or_group: SketchOrSurface, - tag: Option, + radius: TyF64, + num_sides: u64, + center: [f64; 2], + inscribed: Option, exec_state: &mut ExecState, args: Args, ) -> Result { - if data.num_sides < 3 { + if num_sides < 3 { return Err(KclError::Type(KclErrorDetails { message: "Polygon must have at least 3 sides".to_string(), source_ranges: vec![args.source_range], })); } - if data.radius.n <= 0.0 { + if radius.n <= 0.0 { return Err(KclError::Type(KclErrorDetails { message: "Radius must be greater than 0".to_string(), source_ranges: vec![args.source_range], @@ -348,21 +348,24 @@ async fn inner_polygon( SketchOrSurface::Sketch(group) => group.on, }; - let half_angle = std::f64::consts::PI / data.num_sides as f64; + let half_angle = std::f64::consts::PI / num_sides as f64; - let radius_to_vertices = match data.polygon_type { - PolygonType::Inscribed => data.radius.n, - PolygonType::Circumscribed => data.radius.n / half_angle.cos(), + let radius_to_vertices = if inscribed.unwrap_or(true) { + // inscribed + radius.n + } else { + // circumscribed + radius.n / half_angle.cos() }; - let angle_step = 2.0 * std::f64::consts::PI / data.num_sides as f64; + let angle_step = std::f64::consts::TAU / num_sides as f64; - let vertices: Vec<[f64; 2]> = (0..data.num_sides) + let vertices: Vec<[f64; 2]> = (0..num_sides) .map(|i| { let angle = angle_step * i as f64; [ - data.center[0].n + radius_to_vertices * angle.cos(), - data.center[1].n + radius_to_vertices * angle.sin(), + center[0] + radius_to_vertices * angle.cos(), + center[1] + radius_to_vertices * angle.sin(), ] }) .collect(); @@ -391,7 +394,7 @@ async fn inner_polygon( base: BasePath { from: from.into(), to: *vertex, - tag: tag.clone(), + tag: None, units: sketch.units, geo_meta: GeoMeta { id, @@ -400,10 +403,6 @@ async fn inner_polygon( }, }; - if let Some(tag) = &tag { - sketch.add_tag(tag, ¤t_path, exec_state); - } - sketch.paths.push(current_path); } @@ -427,7 +426,7 @@ async fn inner_polygon( base: BasePath { from: from.into(), to: vertices[0], - tag: tag.clone(), + tag: None, units: sketch.units, geo_meta: GeoMeta { id: close_id, @@ -436,10 +435,6 @@ async fn inner_polygon( }, }; - if let Some(tag) = &tag { - sketch.add_tag(tag, ¤t_path, exec_state); - } - sketch.paths.push(current_path); args.batch_modeling_cmd( diff --git a/rust/kcl-lib/tests/kcl_samples/bench/artifact_graph_flowchart.snap.md b/rust/kcl-lib/tests/kcl_samples/bench/artifact_graph_flowchart.snap.md index f7e2f3434..7d84273be 100644 --- a/rust/kcl-lib/tests/kcl_samples/bench/artifact_graph_flowchart.snap.md +++ b/rust/kcl-lib/tests/kcl_samples/bench/artifact_graph_flowchart.snap.md @@ -154,82 +154,82 @@ flowchart LR 522["Path
[1762, 1786, 5]"] end subgraph path523 [Path] - 523["Path
[1794, 1924, 5]"] - 524["Segment
[1794, 1924, 5]"] - 525["Segment
[1794, 1924, 5]"] - 526["Segment
[1794, 1924, 5]"] - 527["Segment
[1794, 1924, 5]"] - 528["Segment
[1794, 1924, 5]"] - 529["Segment
[1794, 1924, 5]"] - 530["Segment
[1794, 1924, 5]"] + 523["Path
[1794, 1920, 5]"] + 524["Segment
[1794, 1920, 5]"] + 525["Segment
[1794, 1920, 5]"] + 526["Segment
[1794, 1920, 5]"] + 527["Segment
[1794, 1920, 5]"] + 528["Segment
[1794, 1920, 5]"] + 529["Segment
[1794, 1920, 5]"] + 530["Segment
[1794, 1920, 5]"] 531[Solid2d] end subgraph path553 [Path] 553["Path
[1762, 1786, 5]"] end subgraph path554 [Path] - 554["Path
[1794, 1924, 5]"] - 555["Segment
[1794, 1924, 5]"] - 556["Segment
[1794, 1924, 5]"] - 557["Segment
[1794, 1924, 5]"] - 558["Segment
[1794, 1924, 5]"] - 559["Segment
[1794, 1924, 5]"] - 560["Segment
[1794, 1924, 5]"] - 561["Segment
[1794, 1924, 5]"] + 554["Path
[1794, 1920, 5]"] + 555["Segment
[1794, 1920, 5]"] + 556["Segment
[1794, 1920, 5]"] + 557["Segment
[1794, 1920, 5]"] + 558["Segment
[1794, 1920, 5]"] + 559["Segment
[1794, 1920, 5]"] + 560["Segment
[1794, 1920, 5]"] + 561["Segment
[1794, 1920, 5]"] 562[Solid2d] end subgraph path585 [Path] - 585["Path
[2200, 2227, 5]"] - 586["Segment
[2235, 2257, 5]"] - 587["Segment
[2265, 2287, 5]"] - 588["Segment
[2295, 2317, 5]"] - 589["Segment
[2325, 2348, 5]"] - 590["Segment
[2356, 2379, 5]"] - 591["Segment
[2387, 2422, 5]"] - 592["Segment
[2430, 2437, 5]"] + 585["Path
[2196, 2223, 5]"] + 586["Segment
[2231, 2253, 5]"] + 587["Segment
[2261, 2283, 5]"] + 588["Segment
[2291, 2313, 5]"] + 589["Segment
[2321, 2344, 5]"] + 590["Segment
[2352, 2375, 5]"] + 591["Segment
[2383, 2418, 5]"] + 592["Segment
[2426, 2433, 5]"] 593[Solid2d] end subgraph path618 [Path] - 618["Path
[2709, 2738, 5]"] - 619["Segment
[2746, 2781, 5]"] - 620["Segment
[2789, 2814, 5]"] - 621["Segment
[2822, 2858, 5]"] - 622["Segment
[2866, 2890, 5]"] - 623["Segment
[2898, 2932, 5]"] - 624["Segment
[2940, 2975, 5]"] - 625["Segment
[2983, 2990, 5]"] + 618["Path
[2705, 2734, 5]"] + 619["Segment
[2742, 2777, 5]"] + 620["Segment
[2785, 2810, 5]"] + 621["Segment
[2818, 2854, 5]"] + 622["Segment
[2862, 2886, 5]"] + 623["Segment
[2894, 2928, 5]"] + 624["Segment
[2936, 2971, 5]"] + 625["Segment
[2979, 2986, 5]"] 626[Solid2d] end subgraph path650 [Path] - 650["Path
[3265, 3292, 5]"] - 651["Segment
[3300, 3319, 5]"] - 652["Segment
[3327, 3376, 5]"] + 650["Path
[3261, 3288, 5]"] + 651["Segment
[3296, 3315, 5]"] + 652["Segment
[3323, 3372, 5]"] end subgraph path654 [Path] - 654["Path
[3476, 3509, 5]"] - 655["Segment
[3517, 3536, 5]"] - 656["Segment
[3544, 3566, 5]"] - 657["Segment
[3574, 3597, 5]"] - 658["Segment
[3605, 3625, 5]"] - 659["Segment
[3633, 3657, 5]"] - 660["Segment
[3665, 3688, 5]"] - 661["Segment
[3696, 3703, 5]"] + 654["Path
[3472, 3505, 5]"] + 655["Segment
[3513, 3532, 5]"] + 656["Segment
[3540, 3562, 5]"] + 657["Segment
[3570, 3593, 5]"] + 658["Segment
[3601, 3621, 5]"] + 659["Segment
[3629, 3653, 5]"] + 660["Segment
[3661, 3684, 5]"] + 661["Segment
[3692, 3699, 5]"] 662[Solid2d] end subgraph path688 [Path] - 688["Path
[3265, 3292, 5]"] - 689["Segment
[3300, 3319, 5]"] - 690["Segment
[3327, 3376, 5]"] + 688["Path
[3261, 3288, 5]"] + 689["Segment
[3296, 3315, 5]"] + 690["Segment
[3323, 3372, 5]"] end subgraph path692 [Path] - 692["Path
[3476, 3509, 5]"] - 693["Segment
[3517, 3536, 5]"] - 694["Segment
[3544, 3566, 5]"] - 695["Segment
[3574, 3597, 5]"] - 696["Segment
[3605, 3625, 5]"] - 697["Segment
[3633, 3657, 5]"] - 698["Segment
[3665, 3688, 5]"] - 699["Segment
[3696, 3703, 5]"] + 692["Path
[3472, 3505, 5]"] + 693["Segment
[3513, 3532, 5]"] + 694["Segment
[3540, 3562, 5]"] + 695["Segment
[3570, 3593, 5]"] + 696["Segment
[3601, 3621, 5]"] + 697["Segment
[3629, 3653, 5]"] + 698["Segment
[3661, 3684, 5]"] + 699["Segment
[3692, 3699, 5]"] 700[Solid2d] end 1["Plane
[333, 353, 5]"] @@ -615,7 +615,7 @@ flowchart LR 519["SweepEdge Opposite"] 520["SweepEdge Adjacent"] 521["Plane
[975, 1017, 0]"] - 532["Sweep Extrusion
[2026, 2050, 5]"] + 532["Sweep Extrusion
[2022, 2046, 5]"] 533[Wall] 534[Wall] 535[Wall] @@ -636,7 +636,7 @@ flowchart LR 550["SweepEdge Adjacent"] 551["SweepEdge Opposite"] 552["SweepEdge Adjacent"] - 563["Sweep Extrusion
[2092, 2116, 5]"] + 563["Sweep Extrusion
[2088, 2112, 5]"] 564[Wall] 565[Wall] 566[Wall] @@ -658,7 +658,7 @@ flowchart LR 582["SweepEdge Opposite"] 583["SweepEdge Adjacent"] 584["Plane
[1068, 1135, 0]"] - 594["Sweep Extrusion
[2600, 2624, 5]"] + 594["Sweep Extrusion
[2596, 2620, 5]"] 595[Wall] 596[Wall] 597[Wall] @@ -679,10 +679,10 @@ flowchart LR 612["SweepEdge Adjacent"] 613["SweepEdge Opposite"] 614["SweepEdge Adjacent"] - 615["Sweep Extrusion
[2600, 2624, 5]"] - 616["Sweep Extrusion
[2600, 2624, 5]"] + 615["Sweep Extrusion
[2596, 2620, 5]"] + 616["Sweep Extrusion
[2596, 2620, 5]"] 617["Plane
[1205, 1272, 0]"] - 627["Sweep Extrusion
[3160, 3184, 5]"] + 627["Sweep Extrusion
[3156, 3180, 5]"] 628[Wall] 629[Wall] 630[Wall] @@ -703,10 +703,10 @@ flowchart LR 645["SweepEdge Adjacent"] 646["SweepEdge Opposite"] 647["SweepEdge Adjacent"] - 648["Sweep Extrusion
[3160, 3184, 5]"] - 649["Plane
[3784, 3819, 5]"] - 653["Plane
[3850, 3879, 5]"] - 663["Sweep Sweep
[3891, 3918, 5]"] + 648["Sweep Extrusion
[3156, 3180, 5]"] + 649["Plane
[3780, 3815, 5]"] + 653["Plane
[3846, 3875, 5]"] + 663["Sweep Sweep
[3887, 3914, 5]"] 664[Wall] 665[Wall] 666[Wall] @@ -730,9 +730,9 @@ flowchart LR 684["SweepEdge Adjacent"] 685["SweepEdge Opposite"] 686["SweepEdge Adjacent"] - 687["Plane
[3784, 3819, 5]"] - 691["Plane
[3850, 3879, 5]"] - 701["Sweep Sweep
[3891, 3918, 5]"] + 687["Plane
[3780, 3815, 5]"] + 691["Plane
[3846, 3875, 5]"] + 701["Sweep Sweep
[3887, 3914, 5]"] 702[Wall] 703[Wall] 704[Wall] @@ -762,12 +762,12 @@ flowchart LR 728["StartSketchOnPlane
[333, 353, 5]"] 729["StartSketchOnPlane
[1734, 1754, 5]"] 730["StartSketchOnPlane
[1734, 1754, 5]"] - 731["StartSketchOnPlane
[2172, 2192, 5]"] - 732["StartSketchOnPlane
[2681, 2701, 5]"] - 733["StartSketchOnPlane
[3237, 3257, 5]"] - 734["StartSketchOnPlane
[3448, 3468, 5]"] - 735["StartSketchOnPlane
[3237, 3257, 5]"] - 736["StartSketchOnPlane
[3448, 3468, 5]"] + 731["StartSketchOnPlane
[2168, 2188, 5]"] + 732["StartSketchOnPlane
[2677, 2697, 5]"] + 733["StartSketchOnPlane
[3233, 3253, 5]"] + 734["StartSketchOnPlane
[3444, 3464, 5]"] + 735["StartSketchOnPlane
[3233, 3253, 5]"] + 736["StartSketchOnPlane
[3444, 3464, 5]"] 1 --- 2 2 --- 3 2 --- 4 diff --git a/rust/kcl-lib/tests/kcl_samples/bench/ops.snap b/rust/kcl-lib/tests/kcl_samples/bench/ops.snap index 40d686974..d59e17f09 100644 --- a/rust/kcl-lib/tests/kcl_samples/bench/ops.snap +++ b/rust/kcl-lib/tests/kcl_samples/bench/ops.snap @@ -807,8 +807,8 @@ description: Operations executed bench.kcl "type": "FunctionCall", "name": "connector", "functionSourceRange": [ - 1966, - 2129, + 1962, + 2125, 5 ], "unlabeledArg": null, @@ -823,7 +823,7 @@ description: Operations executed bench.kcl "name": "connectorSketch", "functionSourceRange": [ 1703, - 1945, + 1941, 5 ], "unlabeledArg": null, @@ -888,7 +888,7 @@ description: Operations executed bench.kcl "name": "connectorSketch", "functionSourceRange": [ 1703, - 1945, + 1941, 5 ], "unlabeledArg": null, @@ -985,8 +985,8 @@ description: Operations executed bench.kcl "type": "FunctionCall", "name": "seatSlats", "functionSourceRange": [ - 2551, - 2637, + 2547, + 2633, 5 ], "unlabeledArg": null, @@ -1000,8 +1000,8 @@ description: Operations executed bench.kcl "type": "FunctionCall", "name": "seatSlatSketch", "functionSourceRange": [ - 2148, - 2530, + 2144, + 2526, 5 ], "unlabeledArg": null, @@ -1115,8 +1115,8 @@ description: Operations executed bench.kcl "type": "FunctionCall", "name": "backSlats", "functionSourceRange": [ - 3106, - 3197, + 3102, + 3193, 5 ], "unlabeledArg": null, @@ -1130,8 +1130,8 @@ description: Operations executed bench.kcl "type": "FunctionCall", "name": "backSlatsSketch", "functionSourceRange": [ - 2657, - 3085, + 2653, + 3081, 5 ], "unlabeledArg": null, @@ -1209,8 +1209,8 @@ description: Operations executed bench.kcl "type": "FunctionCall", "name": "armRest", "functionSourceRange": [ - 3743, - 3931, + 3739, + 3927, 5 ], "unlabeledArg": null, @@ -1254,8 +1254,8 @@ description: Operations executed bench.kcl "type": "FunctionCall", "name": "armRestPath", "functionSourceRange": [ - 3213, - 3397, + 3209, + 3393, 5 ], "unlabeledArg": null, @@ -1317,8 +1317,8 @@ description: Operations executed bench.kcl "type": "FunctionCall", "name": "armRestProfile", "functionSourceRange": [ - 3416, - 3724, + 3412, + 3720, 5 ], "unlabeledArg": null, @@ -1378,8 +1378,8 @@ description: Operations executed bench.kcl "type": "FunctionCall", "name": "armRest", "functionSourceRange": [ - 3743, - 3931, + 3739, + 3927, 5 ], "unlabeledArg": null, @@ -1423,8 +1423,8 @@ description: Operations executed bench.kcl "type": "FunctionCall", "name": "armRestPath", "functionSourceRange": [ - 3213, - 3397, + 3209, + 3393, 5 ], "unlabeledArg": null, @@ -1486,8 +1486,8 @@ description: Operations executed bench.kcl "type": "FunctionCall", "name": "armRestProfile", "functionSourceRange": [ - 3416, - 3724, + 3412, + 3720, 5 ], "unlabeledArg": null, diff --git a/rust/kcl-lib/tests/kcl_samples/dodecahedron/artifact_graph_flowchart.snap.md b/rust/kcl-lib/tests/kcl_samples/dodecahedron/artifact_graph_flowchart.snap.md index 1316f2d5a..2c03e7abc 100644 --- a/rust/kcl-lib/tests/kcl_samples/dodecahedron/artifact_graph_flowchart.snap.md +++ b/rust/kcl-lib/tests/kcl_samples/dodecahedron/artifact_graph_flowchart.snap.md @@ -1,28 +1,28 @@ ```mermaid flowchart LR subgraph path2 [Path] - 2["Path
[1130, 1242, 0]"] - 3["Segment
[1130, 1242, 0]"] - 4["Segment
[1130, 1242, 0]"] - 5["Segment
[1130, 1242, 0]"] - 6["Segment
[1130, 1242, 0]"] - 7["Segment
[1130, 1242, 0]"] - 8["Segment
[1130, 1242, 0]"] + 2["Path
[1130, 1238, 0]"] + 3["Segment
[1130, 1238, 0]"] + 4["Segment
[1130, 1238, 0]"] + 5["Segment
[1130, 1238, 0]"] + 6["Segment
[1130, 1238, 0]"] + 7["Segment
[1130, 1238, 0]"] + 8["Segment
[1130, 1238, 0]"] 9[Solid2d] end subgraph path11 [Path] - 11["Path
[1287, 1399, 0]"] - 12["Segment
[1287, 1399, 0]"] - 13["Segment
[1287, 1399, 0]"] - 14["Segment
[1287, 1399, 0]"] - 15["Segment
[1287, 1399, 0]"] - 16["Segment
[1287, 1399, 0]"] - 17["Segment
[1287, 1399, 0]"] + 11["Path
[1283, 1391, 0]"] + 12["Segment
[1283, 1391, 0]"] + 13["Segment
[1283, 1391, 0]"] + 14["Segment
[1283, 1391, 0]"] + 15["Segment
[1283, 1391, 0]"] + 16["Segment
[1283, 1391, 0]"] + 17["Segment
[1283, 1391, 0]"] 18[Solid2d] end 1["Plane
[1107, 1124, 0]"] - 10["Plane
[1261, 1281, 0]"] - 19["Sweep Extrusion
[1445, 1488, 0]"] + 10["Plane
[1257, 1277, 0]"] + 19["Sweep Extrusion
[1437, 1480, 0]"] 20[Wall] 21[Wall] 22[Wall] @@ -40,7 +40,7 @@ flowchart LR 34["SweepEdge Adjacent"] 35["SweepEdge Opposite"] 36["SweepEdge Adjacent"] - 37["Sweep Extrusion
[1502, 1549, 0]"] + 37["Sweep Extrusion
[1494, 1541, 0]"] 38[Wall] 39[Wall] 40[Wall] diff --git a/rust/kcl-lib/tests/kcl_samples/dodecahedron/ast.snap b/rust/kcl-lib/tests/kcl_samples/dodecahedron/ast.snap index 6cac78142..5d18cce1f 100644 --- a/rust/kcl-lib/tests/kcl_samples/dodecahedron/ast.snap +++ b/rust/kcl-lib/tests/kcl_samples/dodecahedron/ast.snap @@ -1405,142 +1405,114 @@ description: Result of parsing dodecahedron.kcl { "arguments": [ { - "commentStart": 0, - "end": 0, - "properties": [ - { + "type": "LabeledArg", + "label": { + "commentStart": 0, + "end": 0, + "name": "radius", + "start": 0, + "type": "Identifier" + }, + "arg": { + "abs_path": false, + "commentStart": 0, + "end": 0, + "name": { "commentStart": 0, "end": 0, - "key": { - "commentStart": 0, - "end": 0, - "name": "radius", - "start": 0, - "type": "Identifier" - }, + "name": "pentR", "start": 0, - "type": "ObjectProperty", - "value": { - "abs_path": false, - "commentStart": 0, - "end": 0, - "name": { - "commentStart": 0, - "end": 0, - "name": "pentR", - "start": 0, - "type": "Identifier" - }, - "path": [], - "start": 0, - "type": "Name", - "type": "Name" - } + "type": "Identifier" }, - { - "commentStart": 0, - "end": 0, - "key": { + "path": [], + "start": 0, + "type": "Name", + "type": "Name" + } + }, + { + "type": "LabeledArg", + "label": { + "commentStart": 0, + "end": 0, + "name": "numSides", + "start": 0, + "type": "Identifier" + }, + "arg": { + "commentStart": 0, + "end": 0, + "raw": "5", + "start": 0, + "type": "Literal", + "type": "Literal", + "value": { + "value": 5.0, + "suffix": "None" + } + } + }, + { + "type": "LabeledArg", + "label": { + "commentStart": 0, + "end": 0, + "name": "center", + "start": 0, + "type": "Identifier" + }, + "arg": { + "commentStart": 0, + "elements": [ + { "commentStart": 0, "end": 0, - "name": "numSides", - "start": 0, - "type": "Identifier" - }, - "start": 0, - "type": "ObjectProperty", - "value": { - "commentStart": 0, - "end": 0, - "raw": "5", + "raw": "0", "start": 0, "type": "Literal", "type": "Literal", "value": { - "value": 5.0, + "value": 0.0, + "suffix": "None" + } + }, + { + "commentStart": 0, + "end": 0, + "raw": "0", + "start": 0, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, "suffix": "None" } } - }, - { - "commentStart": 0, - "end": 0, - "key": { - "commentStart": 0, - "end": 0, - "name": "center", - "start": 0, - "type": "Identifier" - }, - "start": 0, - "type": "ObjectProperty", - "value": { - "commentStart": 0, - "elements": [ - { - "commentStart": 0, - "end": 0, - "raw": "0", - "start": 0, - "type": "Literal", - "type": "Literal", - "value": { - "value": 0.0, - "suffix": "None" - } - }, - { - "commentStart": 0, - "end": 0, - "raw": "0", - "start": 0, - "type": "Literal", - "type": "Literal", - "value": { - "value": 0.0, - "suffix": "None" - } - } - ], - "end": 0, - "start": 0, - "type": "ArrayExpression", - "type": "ArrayExpression" - } - }, - { - "commentStart": 0, - "end": 0, - "key": { - "commentStart": 0, - "end": 0, - "name": "inscribed", - "start": 0, - "type": "Identifier" - }, - "start": 0, - "type": "ObjectProperty", - "value": { - "commentStart": 0, - "end": 0, - "raw": "true", - "start": 0, - "type": "Literal", - "type": "Literal", - "value": true - } - } - ], - "start": 0, - "type": "ObjectExpression", - "type": "ObjectExpression" + ], + "end": 0, + "start": 0, + "type": "ArrayExpression", + "type": "ArrayExpression" + } }, { - "commentStart": 0, - "end": 0, - "start": 0, - "type": "PipeSubstitution", - "type": "PipeSubstitution" + "type": "LabeledArg", + "label": { + "commentStart": 0, + "end": 0, + "name": "inscribed", + "start": 0, + "type": "Identifier" + }, + "arg": { + "commentStart": 0, + "end": 0, + "raw": "true", + "start": 0, + "type": "Literal", + "type": "Literal", + "value": true + } } ], "callee": { @@ -1561,8 +1533,9 @@ description: Result of parsing dodecahedron.kcl "commentStart": 0, "end": 0, "start": 0, - "type": "CallExpression", - "type": "CallExpression" + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null } ], "commentStart": 0, @@ -1642,142 +1615,114 @@ description: Result of parsing dodecahedron.kcl { "arguments": [ { - "commentStart": 0, - "end": 0, - "properties": [ - { + "type": "LabeledArg", + "label": { + "commentStart": 0, + "end": 0, + "name": "radius", + "start": 0, + "type": "Identifier" + }, + "arg": { + "abs_path": false, + "commentStart": 0, + "end": 0, + "name": { "commentStart": 0, "end": 0, - "key": { - "commentStart": 0, - "end": 0, - "name": "radius", - "start": 0, - "type": "Identifier" - }, + "name": "pentR", "start": 0, - "type": "ObjectProperty", - "value": { - "abs_path": false, - "commentStart": 0, - "end": 0, - "name": { - "commentStart": 0, - "end": 0, - "name": "pentR", - "start": 0, - "type": "Identifier" - }, - "path": [], - "start": 0, - "type": "Name", - "type": "Name" - } + "type": "Identifier" }, - { - "commentStart": 0, - "end": 0, - "key": { + "path": [], + "start": 0, + "type": "Name", + "type": "Name" + } + }, + { + "type": "LabeledArg", + "label": { + "commentStart": 0, + "end": 0, + "name": "numSides", + "start": 0, + "type": "Identifier" + }, + "arg": { + "commentStart": 0, + "end": 0, + "raw": "5", + "start": 0, + "type": "Literal", + "type": "Literal", + "value": { + "value": 5.0, + "suffix": "None" + } + } + }, + { + "type": "LabeledArg", + "label": { + "commentStart": 0, + "end": 0, + "name": "center", + "start": 0, + "type": "Identifier" + }, + "arg": { + "commentStart": 0, + "elements": [ + { "commentStart": 0, "end": 0, - "name": "numSides", - "start": 0, - "type": "Identifier" - }, - "start": 0, - "type": "ObjectProperty", - "value": { - "commentStart": 0, - "end": 0, - "raw": "5", + "raw": "0", "start": 0, "type": "Literal", "type": "Literal", "value": { - "value": 5.0, + "value": 0.0, + "suffix": "None" + } + }, + { + "commentStart": 0, + "end": 0, + "raw": "0", + "start": 0, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, "suffix": "None" } } - }, - { - "commentStart": 0, - "end": 0, - "key": { - "commentStart": 0, - "end": 0, - "name": "center", - "start": 0, - "type": "Identifier" - }, - "start": 0, - "type": "ObjectProperty", - "value": { - "commentStart": 0, - "elements": [ - { - "commentStart": 0, - "end": 0, - "raw": "0", - "start": 0, - "type": "Literal", - "type": "Literal", - "value": { - "value": 0.0, - "suffix": "None" - } - }, - { - "commentStart": 0, - "end": 0, - "raw": "0", - "start": 0, - "type": "Literal", - "type": "Literal", - "value": { - "value": 0.0, - "suffix": "None" - } - } - ], - "end": 0, - "start": 0, - "type": "ArrayExpression", - "type": "ArrayExpression" - } - }, - { - "commentStart": 0, - "end": 0, - "key": { - "commentStart": 0, - "end": 0, - "name": "inscribed", - "start": 0, - "type": "Identifier" - }, - "start": 0, - "type": "ObjectProperty", - "value": { - "commentStart": 0, - "end": 0, - "raw": "true", - "start": 0, - "type": "Literal", - "type": "Literal", - "value": true - } - } - ], - "start": 0, - "type": "ObjectExpression", - "type": "ObjectExpression" + ], + "end": 0, + "start": 0, + "type": "ArrayExpression", + "type": "ArrayExpression" + } }, { - "commentStart": 0, - "end": 0, - "start": 0, - "type": "PipeSubstitution", - "type": "PipeSubstitution" + "type": "LabeledArg", + "label": { + "commentStart": 0, + "end": 0, + "name": "inscribed", + "start": 0, + "type": "Identifier" + }, + "arg": { + "commentStart": 0, + "end": 0, + "raw": "true", + "start": 0, + "type": "Literal", + "type": "Literal", + "value": true + } } ], "callee": { @@ -1798,8 +1743,9 @@ description: Result of parsing dodecahedron.kcl "commentStart": 0, "end": 0, "start": 0, - "type": "CallExpression", - "type": "CallExpression" + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null } ], "commentStart": 0, diff --git a/rust/kcl-lib/tests/multi_transform/artifact_graph_flowchart.snap.md b/rust/kcl-lib/tests/multi_transform/artifact_graph_flowchart.snap.md index 0cdaf84eb..683e73e34 100644 --- a/rust/kcl-lib/tests/multi_transform/artifact_graph_flowchart.snap.md +++ b/rust/kcl-lib/tests/multi_transform/artifact_graph_flowchart.snap.md @@ -4,16 +4,16 @@ flowchart LR 2["Path
[132, 157, 0]"] end subgraph path3 [Path] - 3["Path
[163, 273, 0]"] - 4["Segment
[163, 273, 0]"] - 5["Segment
[163, 273, 0]"] - 6["Segment
[163, 273, 0]"] - 7["Segment
[163, 273, 0]"] - 8["Segment
[163, 273, 0]"] + 3["Path
[163, 269, 0]"] + 4["Segment
[163, 269, 0]"] + 5["Segment
[163, 269, 0]"] + 6["Segment
[163, 269, 0]"] + 7["Segment
[163, 269, 0]"] + 8["Segment
[163, 269, 0]"] 9[Solid2d] end 1["Plane
[109, 126, 0]"] - 10["Sweep Extrusion
[279, 298, 0]"] + 10["Sweep Extrusion
[275, 294, 0]"] 11[Wall] 12[Wall] 13[Wall] diff --git a/rust/kcl-lib/tests/multi_transform/ast.snap b/rust/kcl-lib/tests/multi_transform/ast.snap index 838f9c37b..44e217e00 100644 --- a/rust/kcl-lib/tests/multi_transform/ast.snap +++ b/rust/kcl-lib/tests/multi_transform/ast.snap @@ -351,138 +351,110 @@ description: Result of parsing multi_transform.kcl { "arguments": [ { - "commentStart": 0, - "end": 0, - "properties": [ - { - "commentStart": 0, - "end": 0, - "key": { - "commentStart": 0, - "end": 0, - "name": "radius", - "start": 0, - "type": "Identifier" - }, - "start": 0, - "type": "ObjectProperty", - "value": { - "commentStart": 0, - "end": 0, - "raw": "10", - "start": 0, - "type": "Literal", - "type": "Literal", - "value": { - "value": 10.0, - "suffix": "None" - } - } - }, - { - "commentStart": 0, - "end": 0, - "key": { - "commentStart": 0, - "end": 0, - "name": "numSides", - "start": 0, - "type": "Identifier" - }, - "start": 0, - "type": "ObjectProperty", - "value": { - "commentStart": 0, - "end": 0, - "raw": "4", - "start": 0, - "type": "Literal", - "type": "Literal", - "value": { - "value": 4.0, - "suffix": "None" - } - } - }, - { - "commentStart": 0, - "end": 0, - "key": { - "commentStart": 0, - "end": 0, - "name": "center", - "start": 0, - "type": "Identifier" - }, - "start": 0, - "type": "ObjectProperty", - "value": { - "commentStart": 0, - "elements": [ - { - "commentStart": 0, - "end": 0, - "raw": "0", - "start": 0, - "type": "Literal", - "type": "Literal", - "value": { - "value": 0.0, - "suffix": "None" - } - }, - { - "commentStart": 0, - "end": 0, - "raw": "0", - "start": 0, - "type": "Literal", - "type": "Literal", - "value": { - "value": 0.0, - "suffix": "None" - } - } - ], - "end": 0, - "start": 0, - "type": "ArrayExpression", - "type": "ArrayExpression" - } - }, - { - "commentStart": 0, - "end": 0, - "key": { - "commentStart": 0, - "end": 0, - "name": "inscribed", - "start": 0, - "type": "Identifier" - }, - "start": 0, - "type": "ObjectProperty", - "value": { - "commentStart": 0, - "end": 0, - "raw": "false", - "start": 0, - "type": "Literal", - "type": "Literal", - "value": false - } + "type": "LabeledArg", + "label": { + "commentStart": 0, + "end": 0, + "name": "radius", + "start": 0, + "type": "Identifier" + }, + "arg": { + "commentStart": 0, + "end": 0, + "raw": "10", + "start": 0, + "type": "Literal", + "type": "Literal", + "value": { + "value": 10.0, + "suffix": "None" } - ], - "start": 0, - "type": "ObjectExpression", - "type": "ObjectExpression" + } }, { - "commentStart": 0, - "end": 0, - "start": 0, - "type": "PipeSubstitution", - "type": "PipeSubstitution" + "type": "LabeledArg", + "label": { + "commentStart": 0, + "end": 0, + "name": "numSides", + "start": 0, + "type": "Identifier" + }, + "arg": { + "commentStart": 0, + "end": 0, + "raw": "4", + "start": 0, + "type": "Literal", + "type": "Literal", + "value": { + "value": 4.0, + "suffix": "None" + } + } + }, + { + "type": "LabeledArg", + "label": { + "commentStart": 0, + "end": 0, + "name": "center", + "start": 0, + "type": "Identifier" + }, + "arg": { + "commentStart": 0, + "elements": [ + { + "commentStart": 0, + "end": 0, + "raw": "0", + "start": 0, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + }, + { + "commentStart": 0, + "end": 0, + "raw": "0", + "start": 0, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + } + ], + "end": 0, + "start": 0, + "type": "ArrayExpression", + "type": "ArrayExpression" + } + }, + { + "type": "LabeledArg", + "label": { + "commentStart": 0, + "end": 0, + "name": "inscribed", + "start": 0, + "type": "Identifier" + }, + "arg": { + "commentStart": 0, + "end": 0, + "raw": "false", + "start": 0, + "type": "Literal", + "type": "Literal", + "value": false + } } ], "callee": { @@ -503,8 +475,9 @@ description: Result of parsing multi_transform.kcl "commentStart": 0, "end": 0, "start": 0, - "type": "CallExpression", - "type": "CallExpression" + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null }, { "arguments": [ diff --git a/rust/kcl-lib/tests/multi_transform/input.kcl b/rust/kcl-lib/tests/multi_transform/input.kcl index d6a14b875..f106b629a 100644 --- a/rust/kcl-lib/tests/multi_transform/input.kcl +++ b/rust/kcl-lib/tests/multi_transform/input.kcl @@ -6,11 +6,11 @@ fn transform(i) { } startSketchOn(XY) |> startProfileAt([0, 0], %) - |> polygon({ + |> polygon( radius = 10, numSides = 4, center = [0, 0], - inscribed = false - }, %) + inscribed = false, + ) |> extrude(length = 4) |> patternTransform(instances = 3, transform = transform) diff --git a/rust/kcl-lib/tests/multi_transform/unparsed.snap b/rust/kcl-lib/tests/multi_transform/unparsed.snap index 4cfb9e401..33fae0b51 100644 --- a/rust/kcl-lib/tests/multi_transform/unparsed.snap +++ b/rust/kcl-lib/tests/multi_transform/unparsed.snap @@ -10,11 +10,11 @@ fn transform(i) { } startSketchOn(XY) |> startProfileAt([0, 0], %) - |> polygon({ + |> polygon( radius = 10, numSides = 4, center = [0, 0], - inscribed = false - }, %) + inscribed = false, + ) |> extrude(length = 4) |> patternTransform(instances = 3, transform = transform) diff --git a/src/components/ModelingSidebar/ModelingSidebar.tsx b/src/components/ModelingSidebar/ModelingSidebar.tsx index 6f09112cd..ab9761e16 100644 --- a/src/components/ModelingSidebar/ModelingSidebar.tsx +++ b/src/components/ModelingSidebar/ModelingSidebar.tsx @@ -79,7 +79,7 @@ export function ModelingSidebar({ paneOpacity }: ModelingSidebarProps) { title: 'Load external model', sidebarName: 'Load external model', icon: 'importFile', - keybinding: 'Ctrl + Shift + I', + keybinding: 'Mod + Alt + L', action: () => commandBarActor.send({ type: 'Find and select command', @@ -88,8 +88,8 @@ export function ModelingSidebar({ paneOpacity }: ModelingSidebarProps) { }, { id: 'share-link', - title: 'Create share link', - sidebarName: 'Create share link', + title: 'Share part via Zoo link', + sidebarName: 'Share part via Zoo link', icon: 'link', keybinding: 'Mod + Alt + S', action: () => diff --git a/src/components/ProjectSidebarMenu.tsx b/src/components/ProjectSidebarMenu.tsx index ea6fff60d..37af452bd 100644 --- a/src/components/ProjectSidebarMenu.tsx +++ b/src/components/ProjectSidebarMenu.tsx @@ -220,7 +220,7 @@ function ProjectMenuPopover({ { id: 'share-link', Element: 'button', - children: 'Share current part (via Zoo link)', + children: 'Share part via Zoo link', disabled: !findCommand(shareCommandInfo), onClick: async () => { await copyFileShareLink({ diff --git a/src/lib/kclCommands.ts b/src/lib/kclCommands.ts index 151310b46..f24ddc5de 100644 --- a/src/lib/kclCommands.ts +++ b/src/lib/kclCommands.ts @@ -333,7 +333,7 @@ export function kclCommands(commandProps: KclCommandConfig): Command[] { }, { name: 'share-file-link', - displayName: 'Share current part (via Zoo link)', + displayName: 'Share part via Zoo link', description: 'Create a link that contains a copy of the current file.', groupId: 'code', needsReview: false, diff --git a/src/menu/channels.ts b/src/menu/channels.ts index 4e744d8e8..d308f0c07 100644 --- a/src/menu/channels.ts +++ b/src/menu/channels.ts @@ -13,7 +13,7 @@ export type MenuLabels = | 'Edit.Modify with Zoo Text-To-CAD' | 'Edit.Edit parameter' | 'Edit.Format code' - | 'File.New project' + | 'File.Create project' | 'File.Open project' | 'File.Import file from URL' | 'File.Preferences.User settings' @@ -26,7 +26,7 @@ export type MenuLabels = | 'File.Create new folder' | 'File.Load external model' | 'File.Export current part' - | 'File.Share current part (via Zoo link)' + | 'File.Share part via Zoo link' | 'File.Preferences.Project settings' | 'Design.Start sketch' | 'Design.Create an offset plane' diff --git a/src/menu/fileRole.ts b/src/menu/fileRole.ts index 579ee7ce2..cd1e39769 100644 --- a/src/menu/fileRole.ts +++ b/src/menu/fileRole.ts @@ -13,12 +13,12 @@ export const projectFileRole = ( label: 'File', submenu: [ { - label: 'New project', - id: 'File.New project', + label: 'Create project', + id: 'File.Create project', accelerator: 'CommandOrControl+N', click: () => { typeSafeWebContentsSend(mainWindow, 'menu-action-clicked', { - menuLabel: 'File.New project', + menuLabel: 'File.Create project', }) }, }, @@ -125,12 +125,12 @@ export const modelingFileRole = ( // }, // }, { - label: 'New project', - id: 'File.New project', + label: 'Create project', + id: 'File.Create project', accelerator: 'CommandOrControl+N', click: () => { typeSafeWebContentsSend(mainWindow, 'menu-action-clicked', { - menuLabel: 'File.New project', + menuLabel: 'File.Create project', }) }, }, @@ -166,11 +166,11 @@ export const modelingFileRole = ( }, }, { - label: 'Share current part (via Zoo link)', - id: 'File.Share current part (via Zoo link)', + label: 'Share part via Zoo link', + id: 'File.Share part via Zoo link', click: () => { typeSafeWebContentsSend(mainWindow, 'menu-action-clicked', { - menuLabel: 'File.Share current part (via Zoo link)', + menuLabel: 'File.Share part via Zoo link', }) }, }, diff --git a/src/menu/register.ts b/src/menu/register.ts index 12bbbee3b..854fefe07 100644 --- a/src/menu/register.ts +++ b/src/menu/register.ts @@ -24,7 +24,7 @@ export function modelingMenuCallbackMostActions( ) { // Menu listeners const cb = (data: WebContentSendPayload) => { - if (data.menuLabel === 'File.New project') { + if (data.menuLabel === 'File.Create project') { commandBarActor.send({ type: 'Find and select command', data: { @@ -84,7 +84,7 @@ export function modelingMenuCallbackMostActions( }) } else if (data.menuLabel === 'File.Preferences.Theme color') { navigate(filePath + PATHS.SETTINGS_USER + '#themeColor') - } else if (data.menuLabel === 'File.Share current part (via Zoo link)') { + } else if (data.menuLabel === 'File.Share part via Zoo link') { copyFileShareLink({ token: token ?? '', code: codeManager.code, diff --git a/src/menu/roles.ts b/src/menu/roles.ts index 6925427ab..bc1c4dc32 100644 --- a/src/menu/roles.ts +++ b/src/menu/roles.ts @@ -13,7 +13,7 @@ type HeaderLabel = type FileRoleLabel = | 'Open project' - | 'New project' + | 'Create project' | 'Import file from URL' | 'Preferences' | 'User settings' @@ -24,7 +24,7 @@ type FileRoleLabel = | 'Export current part' | 'Create new file' | 'Create new folder' - | 'Share current part (via Zoo link)' + | 'Share part via Zoo link' | 'Project settings' | 'Load external model' | 'User default units' diff --git a/src/routes/Home.tsx b/src/routes/Home.tsx index a8f11d878..cfe130882 100644 --- a/src/routes/Home.tsx +++ b/src/routes/Home.tsx @@ -69,7 +69,7 @@ const Home = () => { // Menu listeners const cb = (data: WebContentSendPayload) => { - if (data.menuLabel === 'File.New project') { + if (data.menuLabel === 'File.Create project') { commandBarActor.send({ type: 'Find and select command', data: {