diff --git a/docs/kcl/helix.md b/docs/kcl/helix.md index 7f5227703..2ddd2ab4f 100644 --- a/docs/kcl/helix.md +++ b/docs/kcl/helix.md @@ -9,7 +9,7 @@ Create a helix. ```js -helix(data: HelixData) -> HelixValue +helix(revolutions: number, angle_start: number, ccw?: bool, radius: number, axis: Axis3dOrEdgeReference, length?: number) -> HelixValue ``` @@ -17,7 +17,12 @@ helix(data: HelixData) -> HelixValue | Name | Type | Description | Required | |----------|------|-------------|----------| -| `data` | [`HelixData`](/docs/kcl/types/HelixData) | Data for a helix. | Yes | +| `revolutions` | `number` | Number of revolutions. | Yes | +| `angle_start` | `number` | Start angle (in degrees). | Yes | +| `ccw` | `bool` | Is the helix rotation counter clockwise? The default is `false`. | No | +| `radius` | `number` | Radius of the helix. | Yes | +| `axis` | [`Axis3dOrEdgeReference`](/docs/kcl/types/Axis3dOrEdgeReference) | Axis to use for the helix. | Yes | +| `length` | `number` | Length of the helix. This is not necessary if the helix is created around an edge. If not given the length of the edge is used. | No | ### Returns @@ -28,14 +33,7 @@ helix(data: HelixData) -> HelixValue ```js // Create a helix around the Z axis. -helixPath = helix({ - angleStart = 0, - ccw = true, - revolutions = 5, - length = 10, - radius = 5, - axis = 'Z' -}) +helixPath = helix(angleStart = 0, ccw = true, revolutions = 5, length = 10, radius = 5, axis = 'Z') // Create a spring by sweeping around the helix path. springSketch = startSketchOn('YZ') @@ -51,14 +49,7 @@ helper001 = startSketchOn('XZ') |> startProfileAt([0, 0], %) |> line(end = [0, 10], tag = $edge001) -helixPath = helix({ - angleStart = 0, - ccw = true, - revolutions = 5, - length = 10, - radius = 5, - axis = edge001 -}) +helixPath = helix(angleStart = 0, ccw = true, revolutions = 5, length = 10, radius = 5, axis = edge001) // Create a spring by sweeping around the helix path. springSketch = startSketchOn('XY') @@ -70,17 +61,10 @@ springSketch = startSketchOn('XY') ```js // Create a helix around a custom axis. -helixPath = helix({ - angleStart = 0, - ccw = true, - revolutions = 5, - length = 10, - radius = 5, - axis = { - custom = { - axis = [0, 0, 1.0], - origin = [0, 0.25, 0] - } +helixPath = helix(angleStart = 0, ccw = true, revolutions = 5, length = 10, radius = 5, axis = { + custom = { + axis = [0, 0, 1.0], + origin = [0, 0.25, 0] } }) diff --git a/docs/kcl/std.json b/docs/kcl/std.json index eac4507df..6d529893d 100644 --- a/docs/kcl/std.json +++ b/docs/kcl/std.json @@ -82532,80 +82532,89 @@ "summary": "Create a helix.", "description": "", "tags": [], - "keywordArguments": false, + "keywordArguments": true, "args": [ { - "name": "data", - "type": "HelixData", + "name": "revolutions", + "type": "number", "schema": { "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", - "title": "HelixData", - "description": "Data for a helix.", - "type": "object", - "required": [ - "angleStart", - "axis", - "radius", - "revolutions" - ], - "properties": { - "revolutions": { - "description": "Number of revolutions.", - "type": "number", - "format": "double" - }, - "angleStart": { - "description": "Start angle (in degrees).", - "type": "number", - "format": "double" - }, - "ccw": { - "description": "Is the helix rotation counter clockwise? The default is `false`.", - "default": false, - "type": "boolean" - }, - "length": { - "description": "Length of the helix. This is not necessary if the helix is created around an edge. If not given the length of the edge is used.", - "type": "number", - "format": "double", - "nullable": true - }, - "radius": { - "description": "Radius of the helix.", - "type": "number", - "format": "double" - }, - "axis": { - "description": "Axis to use as mirror.", + "title": "double", + "type": "number", + "format": "double" + }, + "required": true, + "includeInSnippet": true, + "description": "Number of revolutions.", + "labelRequired": true + }, + { + "name": "angle_start", + "type": "number", + "schema": { + "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", + "title": "double", + "type": "number", + "format": "double" + }, + "required": true, + "includeInSnippet": true, + "description": "Start angle (in degrees).", + "labelRequired": true + }, + { + "name": "ccw", + "type": "bool", + "schema": { + "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", + "title": "Nullable_Boolean", + "type": "boolean", + "nullable": true + }, + "required": false, + "description": "Is the helix rotation counter clockwise? The default is `false`.", + "labelRequired": true + }, + { + "name": "radius", + "type": "number", + "schema": { + "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", + "title": "double", + "type": "number", + "format": "double" + }, + "required": true, + "includeInSnippet": true, + "description": "Radius of the helix.", + "labelRequired": true + }, + { + "name": "axis", + "type": "Axis3dOrEdgeReference", + "schema": { + "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", + "title": "Axis3dOrEdgeReference", + "description": "A 3D axis or tagged edge.", + "anyOf": [ + { + "description": "3D axis and origin.", "allOf": [ { - "$ref": "#/components/schemas/Axis3dOrEdgeReference" + "$ref": "#/components/schemas/AxisAndOrigin3d" + } + ] + }, + { + "description": "Tagged edge.", + "allOf": [ + { + "$ref": "#/components/schemas/EdgeReference" } ] } - }, + ], "definitions": { - "Axis3dOrEdgeReference": { - "description": "A 3D axis or tagged edge.", - "anyOf": [ - { - "description": "3D axis and origin.", - "allOf": [ - { - "$ref": "#/components/schemas/AxisAndOrigin3d" - } - ] - }, - { - "description": "Tagged edge.", - "allOf": [ - { - "$ref": "#/components/schemas/EdgeReference" - } - ] - } - ] - }, "AxisAndOrigin3d": { "description": "A 3D axis and origin.", "oneOf": [ @@ -83584,6 +83593,998 @@ }, "required": true, "includeInSnippet": true, + "description": "Axis to use for the helix.", + "labelRequired": true + }, + { + "name": "length", + "type": "number", + "schema": { + "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", + "title": "Nullable_double", + "type": "number", + "format": "double", + "nullable": true, + "definitions": { + "AxisAndOrigin3d": { + "description": "A 3D axis and origin.", + "oneOf": [ + { + "description": "X-axis.", + "type": "string", + "enum": [ + "X" + ] + }, + { + "description": "Y-axis.", + "type": "string", + "enum": [ + "Y" + ] + }, + { + "description": "Z-axis.", + "type": "string", + "enum": [ + "Z" + ] + }, + { + "description": "Flip the X-axis.", + "type": "string", + "enum": [ + "-X" + ] + }, + { + "description": "Flip the Y-axis.", + "type": "string", + "enum": [ + "-Y" + ] + }, + { + "description": "Flip the Z-axis.", + "type": "string", + "enum": [ + "-Z" + ] + }, + { + "type": "object", + "required": [ + "custom" + ], + "properties": { + "custom": { + "type": "object", + "required": [ + "axis", + "origin" + ], + "properties": { + "axis": { + "description": "The axis.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 3, + "minItems": 3 + }, + "origin": { + "description": "The origin.", + "type": "array", + "items": { + "type": "number", + "format": "double" + }, + "maxItems": 3, + "minItems": 3 + } + } + } + }, + "additionalProperties": false + } + ] + }, + "EdgeReference": { + "description": "A tag or a uuid of an edge.", + "anyOf": [ + { + "description": "A uuid of an edge.", + "type": "string", + "format": "uuid" + }, + { + "description": "A tag of an edge.", + "allOf": [ + { + "$ref": "#/components/schemas/TagIdentifier" + } + ] + } + ] + }, + "TagIdentifier": { + "type": "object", + "required": [ + "__meta", + "value" + ], + "properties": { + "value": { + "type": "string" + }, + "info": { + "allOf": [ + { + "$ref": "#/components/schemas/TagEngineInfo" + } + ], + "nullable": true + }, + "__meta": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Metadata" + } + } + } + }, + "TagEngineInfo": { + "description": "Engine information for a tag.", + "type": "object", + "required": [ + "id", + "sketch" + ], + "properties": { + "id": { + "description": "The id of the tagged object.", + "type": "string", + "format": "uuid" + }, + "sketch": { + "description": "The sketch the tag is on.", + "type": "string", + "format": "uuid" + }, + "path": { + "description": "The path the tag is on.", + "allOf": [ + { + "$ref": "#/components/schemas/Path" + } + ], + "nullable": true + }, + "surface": { + "description": "The surface information for the tag.", + "allOf": [ + { + "$ref": "#/components/schemas/ExtrudeSurface" + } + ], + "nullable": true + } + } + }, + "Path": { + "description": "A path.", + "oneOf": [ + { + "description": "A path that goes to a point.", + "type": "object", + "required": [ + "__geoMeta", + "from", + "to", + "type" + ], + "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 + }, + "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" + ], + "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 + }, + "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" + ], + "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 + }, + "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" + ], + "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 + }, + "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", + "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 + }, + "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" + ], + "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 + }, + "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" + ], + "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 + }, + "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" + ], + "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 + }, + "tag": { + "description": "The tag of the path.", + "allOf": [ + { + "$ref": "#/components/schemas/TagDeclarator" + } + ], + "nullable": true + }, + "__geoMeta": { + "description": "Metadata.", + "allOf": [ + { + "$ref": "#/components/schemas/GeoMeta" + } + ] + } + } + } + ] + }, + "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 + } + } + }, + "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" + } + ] + } + } + }, + "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 + }, + "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" + } + ] + } + } + } + ] + }, + "Metadata": { + "description": "Metadata.", + "type": "object", + "required": [ + "sourceRange" + ], + "properties": { + "sourceRange": { + "description": "The source range.", + "allOf": [ + { + "$ref": "#/components/schemas/SourceRange" + } + ] + } + } + } + } + }, + "required": false, + "includeInSnippet": true, + "description": "Length of the helix. This is not necessary if the helix is created around an edge. If not given the length of the edge is used.", "labelRequired": true } ], @@ -83759,9 +84760,9 @@ "unpublished": false, "deprecated": false, "examples": [ - "// Create a helix around the Z axis.\nhelixPath = helix({\n angleStart = 0,\n ccw = true,\n revolutions = 5,\n length = 10,\n radius = 5,\n axis = 'Z'\n})\n\n// Create a spring by sweeping around the helix path.\nspringSketch = startSketchOn('YZ')\n |> circle({ center = [0, 0], radius = 0.5 }, %)\n |> sweep({ path = helixPath }, %)", - "// Create a helix around an edge.\nhelper001 = startSketchOn('XZ')\n |> startProfileAt([0, 0], %)\n |> line(end = [0, 10], tag = $edge001)\n\nhelixPath = helix({\n angleStart = 0,\n ccw = true,\n revolutions = 5,\n length = 10,\n radius = 5,\n axis = edge001\n})\n\n// Create a spring by sweeping around the helix path.\nspringSketch = startSketchOn('XY')\n |> circle({ center = [0, 0], radius = 0.5 }, %)\n |> sweep({ path = helixPath }, %)", - "// Create a helix around a custom axis.\nhelixPath = helix({\n angleStart = 0,\n ccw = true,\n revolutions = 5,\n length = 10,\n radius = 5,\n axis = {\n custom = {\n axis = [0, 0, 1.0],\n origin = [0, 0.25, 0]\n }\n }\n})\n\n// Create a spring by sweeping around the helix path.\nspringSketch = startSketchOn('XY')\n |> circle({ center = [0, 0], radius = 1 }, %)\n |> sweep({ path = helixPath }, %)" + "// Create a helix around the Z axis.\nhelixPath = helix(angleStart = 0, ccw = true, revolutions = 5, length = 10, radius = 5, axis = 'Z')\n\n// Create a spring by sweeping around the helix path.\nspringSketch = startSketchOn('YZ')\n |> circle({ center = [0, 0], radius = 0.5 }, %)\n |> sweep({ path = helixPath }, %)", + "// Create a helix around an edge.\nhelper001 = startSketchOn('XZ')\n |> startProfileAt([0, 0], %)\n |> line(end = [0, 10], tag = $edge001)\n\nhelixPath = helix(angleStart = 0, ccw = true, revolutions = 5, length = 10, radius = 5, axis = edge001)\n\n// Create a spring by sweeping around the helix path.\nspringSketch = startSketchOn('XY')\n |> circle({ center = [0, 0], radius = 0.5 }, %)\n |> sweep({ path = helixPath }, %)", + "// Create a helix around a custom axis.\nhelixPath = helix(angleStart = 0, ccw = true, revolutions = 5, length = 10, radius = 5, axis = {\n custom = {\n axis = [0, 0, 1.0],\n origin = [0, 0.25, 0]\n }\n})\n\n// Create a spring by sweeping around the helix path.\nspringSketch = startSketchOn('XY')\n |> circle({ center = [0, 0], radius = 1 }, %)\n |> sweep({ path = helixPath }, %)" ] }, { @@ -205356,7 +206357,7 @@ "deprecated": false, "examples": [ "// Create a pipe using a sweep.\n\n\n// Create a path for the sweep.\nsweepPath = startSketchOn('XZ')\n |> startProfileAt([0.05, 0.05], %)\n |> line(end = [0, 7])\n |> tangentialArc({ offset = 90, radius = 5 }, %)\n |> line(end = [-3, 0])\n |> tangentialArc({ offset = -90, radius = 5 }, %)\n |> line(end = [0, 7])\n\n// Create a hole for the pipe.\npipeHole = startSketchOn('XY')\n |> circle({ center = [0, 0], radius = 1.5 }, %)\n\nsweepSketch = startSketchOn('XY')\n |> circle({ center = [0, 0], radius = 2 }, %)\n |> hole(pipeHole, %)\n |> sweep({ path = sweepPath }, %)", - "// Create a spring by sweeping around a helix path.\n\n\n// Create a helix around the Z axis.\nhelixPath = helix({\n angleStart = 0,\n ccw = true,\n revolutions = 4,\n length = 10,\n radius = 5,\n axis = 'Z'\n})\n\n// Create a spring by sweeping around the helix path.\nspringSketch = startSketchOn('YZ')\n |> circle({ center = [0, 0], radius = 1 }, %)\n |> sweep({ path = helixPath }, %)" + "// Create a spring by sweeping around a helix path.\n\n\n// Create a helix around the Z axis.\nhelixPath = helix(angleStart = 0, ccw = true, revolutions = 4, length = 10, radius = 5, axis = 'Z')\n\n// Create a spring by sweeping around the helix path.\nspringSketch = startSketchOn('YZ')\n |> circle({ center = [0, 0], radius = 1 }, %)\n |> sweep({ path = helixPath }, %)" ] }, { diff --git a/docs/kcl/sweep.md b/docs/kcl/sweep.md index be3d462ec..92237991e 100644 --- a/docs/kcl/sweep.md +++ b/docs/kcl/sweep.md @@ -57,14 +57,7 @@ sweepSketch = startSketchOn('XY') // Create a helix around the Z axis. -helixPath = helix({ - angleStart = 0, - ccw = true, - revolutions = 4, - length = 10, - radius = 5, - axis = 'Z' -}) +helixPath = helix(angleStart = 0, ccw = true, revolutions = 4, length = 10, radius = 5, axis = 'Z') // Create a spring by sweeping around the helix path. springSketch = startSketchOn('YZ') diff --git a/docs/kcl/types/HelixData.md b/docs/kcl/types/HelixData.md deleted file mode 100644 index 5ea06a3a2..000000000 --- a/docs/kcl/types/HelixData.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -title: "HelixData" -excerpt: "Data for a helix." -layout: manual ---- - -Data for a helix. - -**Type:** `object` - - - - - -## Properties - -| Property | Type | Description | Required | -|----------|------|-------------|----------| -| `revolutions` |`number`| Number of revolutions. | No | -| `angleStart` |`number`| Start angle (in degrees). | No | -| `ccw` |`boolean`| Is the helix rotation counter clockwise? The default is `false`. | No | -| `length` |`number`| Length of the helix. This is not necessary if the helix is created around an edge. If not given the length of the edge is used. | No | -| `radius` |`number`| Radius of the helix. | No | -| `axis` |[`Axis3dOrEdgeReference`](/docs/kcl/types/Axis3dOrEdgeReference)| Axis to use as mirror. | No | - - diff --git a/src/wasm-lib/kcl/src/docs/mod.rs b/src/wasm-lib/kcl/src/docs/mod.rs index 1d0ded412..96b5bca8c 100644 --- a/src/wasm-lib/kcl/src/docs/mod.rs +++ b/src/wasm-lib/kcl/src/docs/mod.rs @@ -1059,13 +1059,7 @@ mod tests { let snippet = helix_fn.to_autocomplete_snippet().unwrap(); assert_eq!( snippet, - r#"helix({ - revolutions = ${0:3.14}, - angleStart = ${1:3.14}, - ccw = ${2:false}, - radius = ${3:3.14}, - axis = ${4:"X"}, -})${}"# + r#"helix(revolutions = ${0:3.14}, angle_start = ${1:3.14}, radius = ${2:3.14}, axis = ${3:"X"}, length = ${4:3.14})${}"# ); } diff --git a/src/wasm-lib/kcl/src/execution/exec_ast.rs b/src/wasm-lib/kcl/src/execution/exec_ast.rs index 98867f034..0d82ce7f3 100644 --- a/src/wasm-lib/kcl/src/execution/exec_ast.rs +++ b/src/wasm-lib/kcl/src/execution/exec_ast.rs @@ -1640,9 +1640,8 @@ impl JsonSchema for FunctionParam<'_> { #[cfg(test)] mod test { - use crate::parsing::ast::types::{DefaultParamVal, Identifier, Parameter}; - use super::*; + use crate::parsing::ast::types::{DefaultParamVal, Identifier, Parameter}; #[test] fn test_assign_args_to_params() { diff --git a/src/wasm-lib/kcl/src/execution/mod.rs b/src/wasm-lib/kcl/src/execution/mod.rs index 443b6f839..129789c77 100644 --- a/src/wasm-lib/kcl/src/execution/mod.rs +++ b/src/wasm-lib/kcl/src/execution/mod.rs @@ -3,8 +3,15 @@ use std::{path::PathBuf, sync::Arc}; use anyhow::Result; +pub use artifact::{Artifact, ArtifactCommand, ArtifactGraph, ArtifactId}; +pub use cache::bust_cache; use cache::OldAstState; +pub use cad_op::Operation; +pub use exec_ast::FunctionParam; +pub use geometry::*; +pub(crate) use import::{import_foreign, send_to_engine as send_import_to_engine, ZOO_COORD_SYSTEM}; use indexmap::IndexMap; +pub use kcl_value::{KclObjectFields, KclValue, UnitAngle, UnitLen}; use kcmc::{ each_cmd as mcmd, ok_response::{output::TakeSnapshot, OkModelingCmdResponse}, @@ -12,8 +19,10 @@ use kcmc::{ ImageFormat, ModelingCmd, }; use kittycad_modeling_cmds as kcmc; +pub use memory::ProgramMemory; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +pub use state::{ExecState, IdGenerator, MetaSettings}; use crate::{ engine::EngineManager, @@ -30,16 +39,6 @@ use crate::{ ExecError, KclErrorWithOutputs, }; -pub use artifact::{Artifact, ArtifactCommand, ArtifactGraph, ArtifactId}; -pub use cache::bust_cache; -pub use cad_op::Operation; -pub use exec_ast::FunctionParam; -pub use geometry::*; -pub(crate) use import::{import_foreign, send_to_engine as send_import_to_engine, ZOO_COORD_SYSTEM}; -pub use kcl_value::{KclObjectFields, KclValue, UnitAngle, UnitLen}; -pub use memory::ProgramMemory; -pub use state::{ExecState, IdGenerator, MetaSettings}; - pub(crate) mod annotations; mod artifact; pub(crate) mod cache; diff --git a/src/wasm-lib/kcl/src/parsing/ast/modify.rs b/src/wasm-lib/kcl/src/parsing/ast/modify.rs index 7d3c54826..0f7090237 100644 --- a/src/wasm-lib/kcl/src/parsing/ast/modify.rs +++ b/src/wasm-lib/kcl/src/parsing/ast/modify.rs @@ -6,6 +6,7 @@ use kcmc::{ }; use kittycad_modeling_cmds as kcmc; +use super::types::{CallExpressionKw, Identifier, LabeledArg, LiteralValue}; use crate::{ engine::EngineManager, errors::{KclError, KclErrorDetails}, @@ -18,8 +19,6 @@ use crate::{ Program, }; -use super::types::{CallExpressionKw, Identifier, LabeledArg, LiteralValue}; - type Point3d = kcmc::shared::Point3d; #[derive(Debug)] diff --git a/src/wasm-lib/kcl/src/parsing/ast/types/mod.rs b/src/wasm-lib/kcl/src/parsing/ast/types/mod.rs index 676ef5388..35e8d9b9d 100644 --- a/src/wasm-lib/kcl/src/parsing/ast/types/mod.rs +++ b/src/wasm-lib/kcl/src/parsing/ast/types/mod.rs @@ -26,8 +26,7 @@ use crate::{ docs::StdLibFn, errors::KclError, execution::{annotations, KclValue, Metadata, TagIdentifier}, - parsing::ast::digest::Digest, - parsing::PIPE_OPERATOR, + parsing::{ast::digest::Digest, PIPE_OPERATOR}, source_range::{ModuleId, SourceRange}, }; diff --git a/src/wasm-lib/kcl/src/settings/types/mod.rs b/src/wasm-lib/kcl/src/settings/types/mod.rs index 789333dfd..aa7059bcf 100644 --- a/src/wasm-lib/kcl/src/settings/types/mod.rs +++ b/src/wasm-lib/kcl/src/settings/types/mod.rs @@ -561,12 +561,11 @@ mod tests { use pretty_assertions::assert_eq; use validator::Validate; - use crate::settings::types::CameraOrbitType; - use super::{ AppColor, AppSettings, AppTheme, AppearanceSettings, CameraProjectionType, CommandBarSettings, Configuration, ModelingSettings, OnboardingStatus, ProjectSettings, Settings, TextEditorSettings, UnitLength, }; + use crate::settings::types::CameraOrbitType; #[test] // Test that we can deserialize a project file from the old format. diff --git a/src/wasm-lib/kcl/src/std/args.rs b/src/wasm-lib/kcl/src/std/args.rs index cfa093152..3873f667e 100644 --- a/src/wasm-lib/kcl/src/std/args.rs +++ b/src/wasm-lib/kcl/src/std/args.rs @@ -1071,27 +1071,6 @@ impl<'a> FromKclValue<'a> for super::appearance::AppearanceData { } } -impl<'a> FromKclValue<'a> for super::helix::HelixData { - fn from_kcl_val(arg: &'a KclValue) -> Option { - let obj = arg.as_object()?; - let_field_of!(obj, revolutions); - let_field_of!(obj, length?); - let_field_of!(obj, ccw?); - let_field_of!(obj, radius); - let_field_of!(obj, axis); - let ccw = ccw.unwrap_or_default(); - let angle_start = obj.get("angleStart")?.as_f64()?; - Some(Self { - revolutions, - angle_start, - ccw, - length, - radius, - axis, - }) - } -} - impl<'a> FromKclValue<'a> for super::helix::HelixRevolutionsData { fn from_kcl_val(arg: &'a KclValue) -> Option { let obj = arg.as_object()?; diff --git a/src/wasm-lib/kcl/src/std/helix.rs b/src/wasm-lib/kcl/src/std/helix.rs index 584cf1465..c5a8c714b 100644 --- a/src/wasm-lib/kcl/src/std/helix.rs +++ b/src/wasm-lib/kcl/src/std/helix.rs @@ -13,33 +13,16 @@ use crate::{ std::{axis_or_reference::Axis3dOrEdgeReference, Args}, }; -/// Data for a helix. -#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)] -#[ts(export)] -pub struct HelixData { - /// Number of revolutions. - pub revolutions: f64, - /// Start angle (in degrees). - #[serde(rename = "angleStart")] - pub angle_start: f64, - /// Is the helix rotation counter clockwise? - /// The default is `false`. - #[serde(default)] - pub ccw: bool, - /// Length of the helix. This is not necessary if the helix is created around an edge. If not - /// given the length of the edge is used. - pub length: Option, - /// Radius of the helix. - pub radius: f64, - /// Axis to use as mirror. - pub axis: Axis3dOrEdgeReference, -} - /// Create a helix. pub async fn helix(exec_state: &mut ExecState, args: Args) -> Result { - let data: HelixData = args.get_data()?; + let angle_start = args.get_kw_arg("angleStart")?; + let revolutions = args.get_kw_arg("revolutions")?; + let ccw = args.get_kw_arg_opt("ccw")?; + let radius = args.get_kw_arg("radius")?; + let axis = args.get_kw_arg("axis")?; + let length = args.get_kw_arg_opt("length")?; - let value = inner_helix(data, exec_state, args).await?; + let value = inner_helix(revolutions, angle_start, ccw, radius, axis, length, exec_state, args).await?; Ok(KclValue::Helix { value }) } @@ -47,14 +30,14 @@ pub async fn helix(exec_state: &mut ExecState, args: Args) -> Result Result startProfileAt([0, 0], %) /// |> line(end = [0, 10], tag = $edge001) /// -/// helixPath = helix({ +/// helixPath = helix( /// angleStart = 0, /// ccw = true, /// revolutions = 5, /// length = 10, /// radius = 5, /// axis = edge001, -/// }) +/// ) /// /// // Create a spring by sweeping around the helix path. /// springSketch = startSketchOn('XY') @@ -86,7 +69,7 @@ pub async fn helix(exec_state: &mut ExecState, args: Args) -> Result Result Result Result, KclError> { +#[allow(clippy::too_many_arguments)] +async fn inner_helix( + revolutions: f64, + angle_start: f64, + ccw: Option, + radius: f64, + axis: Axis3dOrEdgeReference, + length: Option, + exec_state: &mut ExecState, + args: Args, +) -> Result, KclError> { let id = exec_state.next_uuid(); let helix_result = Box::new(HelixValue { value: id, - revolutions: data.revolutions, - angle_start: data.angle_start, - ccw: data.ccw, + revolutions, + angle_start, + ccw: ccw.unwrap_or(false), units: exec_state.length_unit(), meta: vec![args.source_range.into()], }); @@ -125,12 +128,12 @@ async fn inner_helix(data: HelixData, exec_state: &mut ExecState, args: Args) -> return Ok(helix_result); } - match data.axis { + match axis { Axis3dOrEdgeReference::Axis(axis) => { let (axis, origin) = axis.axis_and_origin()?; // Make sure they gave us a length. - let Some(length) = data.length else { + let Some(length) = length else { return Err(KclError::Semantic(crate::errors::KclErrorDetails { message: "Length is required when creating a helix around an axis.".to_string(), source_ranges: vec![args.source_range], @@ -140,11 +143,11 @@ async fn inner_helix(data: HelixData, exec_state: &mut ExecState, args: Args) -> args.batch_modeling_cmd( id, ModelingCmd::from(mcmd::EntityMakeHelixFromParams { - radius: LengthUnit(data.radius), - is_clockwise: !data.ccw, + radius: LengthUnit(radius), + is_clockwise: !helix_result.ccw, length: LengthUnit(length), - revolutions: data.revolutions, - start_angle: Angle::from_degrees(data.angle_start), + revolutions, + start_angle: Angle::from_degrees(angle_start), axis, center: origin, }), @@ -157,11 +160,11 @@ async fn inner_helix(data: HelixData, exec_state: &mut ExecState, args: Args) -> args.batch_modeling_cmd( id, ModelingCmd::from(mcmd::EntityMakeHelixFromEdge { - radius: LengthUnit(data.radius), - is_clockwise: !data.ccw, - length: data.length.map(LengthUnit), - revolutions: data.revolutions, - start_angle: Angle::from_degrees(data.angle_start), + radius: LengthUnit(radius), + is_clockwise: !helix_result.ccw, + length: length.map(LengthUnit), + revolutions, + start_angle: Angle::from_degrees(angle_start), edge_id, }), ) diff --git a/src/wasm-lib/kcl/src/std/sketch.rs b/src/wasm-lib/kcl/src/std/sketch.rs index 4ede41de6..9cc0545e0 100644 --- a/src/wasm-lib/kcl/src/std/sketch.rs +++ b/src/wasm-lib/kcl/src/std/sketch.rs @@ -130,7 +130,6 @@ pub async fn line(exec_state: &mut ExecState, args: Args) -> Result line(end = [-10, 0], tag = $thirdLineOfBox) /// |> close() /// |> extrude(length = 5) -/// /// ``` #[stdlib { name = "line", diff --git a/src/wasm-lib/kcl/src/std/sweep.rs b/src/wasm-lib/kcl/src/std/sweep.rs index 3290bc3ab..edd3ed051 100644 --- a/src/wasm-lib/kcl/src/std/sweep.rs +++ b/src/wasm-lib/kcl/src/std/sweep.rs @@ -91,14 +91,14 @@ pub async fn sweep(exec_state: &mut ExecState, args: Args) -> Result