Revolve/Sweep multiple sketches at once (#5779)
* revolve multiple sketches at once Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * do the same for swweep Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * do the same for swweep Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
@ -6,7 +6,7 @@ layout: manual
|
|||||||
|
|
||||||
Extend a 2-dimensional sketch through a third dimension in order to create new 3-dimensional volume, or if extruded into an existing volume, cut into an existing solid.
|
Extend a 2-dimensional sketch through a third dimension in order to create new 3-dimensional volume, or if extruded into an existing volume, cut into an existing solid.
|
||||||
|
|
||||||
|
You can provide more than one sketch to extrude, and they will all be extruded in the same direction.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
extrude(
|
extrude(
|
||||||
@ -20,7 +20,7 @@ extrude(
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `sketchSet` | [`SketchSet`](/docs/kcl/types/SketchSet) | Which sketches should be extruded | Yes |
|
| `sketchSet` | [`SketchSet`](/docs/kcl/types/SketchSet) | Which sketch or set of sketches should be extruded | Yes |
|
||||||
| `length` | [`number`](/docs/kcl/types/number) | How far to extrude the given sketches | Yes |
|
| `length` | [`number`](/docs/kcl/types/number) | How far to extrude the given sketches | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
File diff suppressed because one or more lines are too long
@ -89138,7 +89138,7 @@
|
|||||||
{
|
{
|
||||||
"name": "extrude",
|
"name": "extrude",
|
||||||
"summary": "Extend a 2-dimensional sketch through a third dimension in order to create new 3-dimensional volume, or if extruded into an existing volume, cut into an existing solid.",
|
"summary": "Extend a 2-dimensional sketch through a third dimension in order to create new 3-dimensional volume, or if extruded into an existing volume, cut into an existing solid.",
|
||||||
"description": "",
|
"description": "You can provide more than one sketch to extrude, and they will all be extruded in the same direction.",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"keywordArguments": true,
|
"keywordArguments": true,
|
||||||
"args": [
|
"args": [
|
||||||
@ -90844,7 +90844,7 @@
|
|||||||
},
|
},
|
||||||
"required": true,
|
"required": true,
|
||||||
"includeInSnippet": true,
|
"includeInSnippet": true,
|
||||||
"description": "Which sketches should be extruded",
|
"description": "Which sketch or set of sketches should be extruded",
|
||||||
"labelRequired": false
|
"labelRequired": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -254139,7 +254139,7 @@
|
|||||||
{
|
{
|
||||||
"name": "revolve",
|
"name": "revolve",
|
||||||
"summary": "Rotate a sketch around some provided axis, creating a solid from its extent.",
|
"summary": "Rotate a sketch around some provided axis, creating a solid from its extent.",
|
||||||
"description": "This, like extrude, is able to create a 3-dimensional solid from a 2-dimensional sketch. However, unlike extrude, this creates a solid by using the extent of the sketch as its revolved around an axis rather than using the extent of the sketch linearly translated through a third dimension.\n\nRevolve occurs around a local sketch axis rather than a global axis.",
|
"description": "This, like extrude, is able to create a 3-dimensional solid from a 2-dimensional sketch. However, unlike extrude, this creates a solid by using the extent of the sketch as its revolved around an axis rather than using the extent of the sketch linearly translated through a third dimension.\n\nRevolve occurs around a local sketch axis rather than a global axis.\n\nYou can provide more than one sketch to revolve, and they will all be revolved around the same axis.",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"keywordArguments": false,
|
"keywordArguments": false,
|
||||||
"args": [
|
"args": [
|
||||||
@ -255382,81 +255382,113 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sketch",
|
"name": "sketchSet",
|
||||||
"type": "Sketch",
|
"type": "SketchSet",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
"title": "Sketch",
|
"title": "SketchSet",
|
||||||
"type": "object",
|
"description": "A sketch or a group of sketches.",
|
||||||
"required": [
|
"oneOf": [
|
||||||
"__meta",
|
{
|
||||||
"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",
|
"type": "object",
|
||||||
"additionalProperties": {
|
"required": [
|
||||||
"$ref": "#/components/schemas/TagIdentifier"
|
"__meta",
|
||||||
|
"artifactId",
|
||||||
|
"id",
|
||||||
|
"on",
|
||||||
|
"originalId",
|
||||||
|
"paths",
|
||||||
|
"start",
|
||||||
|
"type",
|
||||||
|
"units"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"sketch"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"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"
|
||||||
|
},
|
||||||
|
"__meta": {
|
||||||
|
"description": "Metadata.",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/Metadata"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"artifactId": {
|
{
|
||||||
"description": "The original id of the sketch. This stays the same even if the sketch is is sketched on face etc.",
|
"type": [
|
||||||
"allOf": [
|
"object",
|
||||||
{
|
"array"
|
||||||
"$ref": "#/components/schemas/ArtifactId"
|
],
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"originalId": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "uuid"
|
|
||||||
},
|
|
||||||
"units": {
|
|
||||||
"$ref": "#/components/schemas/UnitLen"
|
|
||||||
},
|
|
||||||
"__meta": {
|
|
||||||
"description": "Metadata.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/components/schemas/Metadata"
|
"$ref": "#/components/schemas/Sketch"
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"type"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"sketches"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
],
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"Axis2dOrEdgeReference": {
|
"Axis2dOrEdgeReference": {
|
||||||
"description": "A 2D axis or tagged edge.",
|
"description": "A 2D axis or tagged edge.",
|
||||||
@ -257166,84 +257198,116 @@
|
|||||||
],
|
],
|
||||||
"returnValue": {
|
"returnValue": {
|
||||||
"name": "",
|
"name": "",
|
||||||
"type": "Solid",
|
"type": "SolidSet",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
"title": "Solid",
|
"title": "SolidSet",
|
||||||
"type": "object",
|
"description": "A solid or a group of solids.",
|
||||||
"required": [
|
"oneOf": [
|
||||||
"__meta",
|
{
|
||||||
"artifactId",
|
"type": "object",
|
||||||
"height",
|
"required": [
|
||||||
"id",
|
"__meta",
|
||||||
"sketch",
|
"artifactId",
|
||||||
"units",
|
"height",
|
||||||
"value"
|
"id",
|
||||||
],
|
"sketch",
|
||||||
"properties": {
|
"type",
|
||||||
"id": {
|
"units",
|
||||||
"description": "The id of the solid.",
|
"value"
|
||||||
"type": "string",
|
],
|
||||||
"format": "uuid"
|
"properties": {
|
||||||
},
|
"type": {
|
||||||
"artifactId": {
|
"type": "string",
|
||||||
"description": "The artifact ID of the solid. Unlike `id`, this doesn't change.",
|
"enum": [
|
||||||
"allOf": [
|
"solid"
|
||||||
{
|
]
|
||||||
"$ref": "#/components/schemas/ArtifactId"
|
},
|
||||||
|
"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"
|
||||||
|
},
|
||||||
|
"__meta": {
|
||||||
|
"description": "Metadata.",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/Metadata"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"description": "The extrude surfaces.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/components/schemas/ExtrudeSurface"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sketch": {
|
{
|
||||||
"description": "The sketch.",
|
"type": [
|
||||||
"allOf": [
|
"object",
|
||||||
{
|
"array"
|
||||||
"$ref": "#/components/schemas/Sketch"
|
],
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/Solid"
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"type"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"solids"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
|
||||||
},
|
|
||||||
"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"
|
|
||||||
},
|
|
||||||
"__meta": {
|
|
||||||
"description": "Metadata.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/components/schemas/Metadata"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
],
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"ArtifactId": {
|
"ArtifactId": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -258850,7 +258914,8 @@
|
|||||||
"box = startSketchOn('XY')\n |> startProfileAt([0, 0], %)\n |> line(end = [0, 20])\n |> line(end = [20, 0])\n |> line(end = [0, -20])\n |> close()\n |> extrude(length = 20)\n\nsketch001 = startSketchOn(box, \"END\")\n |> circle(center = [10, 10], radius = 4)\n |> revolve({ angle = -90, axis = 'y' }, %)",
|
"box = startSketchOn('XY')\n |> startProfileAt([0, 0], %)\n |> line(end = [0, 20])\n |> line(end = [20, 0])\n |> line(end = [0, -20])\n |> close()\n |> extrude(length = 20)\n\nsketch001 = startSketchOn(box, \"END\")\n |> circle(center = [10, 10], radius = 4)\n |> revolve({ angle = -90, axis = 'y' }, %)",
|
||||||
"box = startSketchOn('XY')\n |> startProfileAt([0, 0], %)\n |> line(end = [0, 20])\n |> line(end = [20, 0])\n |> line(end = [0, -20], tag = $revolveAxis)\n |> close()\n |> extrude(length = 20)\n\nsketch001 = startSketchOn(box, \"END\")\n |> circle(center = [10, 10], radius = 4)\n |> revolve({\n angle = 90,\n axis = getOppositeEdge(revolveAxis)\n }, %)",
|
"box = startSketchOn('XY')\n |> startProfileAt([0, 0], %)\n |> line(end = [0, 20])\n |> line(end = [20, 0])\n |> line(end = [0, -20], tag = $revolveAxis)\n |> close()\n |> extrude(length = 20)\n\nsketch001 = startSketchOn(box, \"END\")\n |> circle(center = [10, 10], radius = 4)\n |> revolve({\n angle = 90,\n axis = getOppositeEdge(revolveAxis)\n }, %)",
|
||||||
"box = startSketchOn('XY')\n |> startProfileAt([0, 0], %)\n |> line(end = [0, 20])\n |> line(end = [20, 0])\n |> line(end = [0, -20], tag = $revolveAxis)\n |> close()\n |> extrude(length = 20)\n\nsketch001 = startSketchOn(box, \"END\")\n |> circle(center = [10, 10], radius = 4)\n |> revolve({\n angle = 90,\n axis = getOppositeEdge(revolveAxis),\n tolerance = 0.0001\n }, %)",
|
"box = startSketchOn('XY')\n |> startProfileAt([0, 0], %)\n |> line(end = [0, 20])\n |> line(end = [20, 0])\n |> line(end = [0, -20], tag = $revolveAxis)\n |> close()\n |> extrude(length = 20)\n\nsketch001 = startSketchOn(box, \"END\")\n |> circle(center = [10, 10], radius = 4)\n |> revolve({\n angle = 90,\n axis = getOppositeEdge(revolveAxis),\n tolerance = 0.0001\n }, %)",
|
||||||
"sketch001 = startSketchOn('XY')\n |> startProfileAt([10, 0], %)\n |> line(end = [5, -5])\n |> line(end = [5, 5])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\npart001 = revolve({\n axis = {\n custom = {\n axis = [0.0, 1.0],\n origin = [0.0, 0.0]\n }\n }\n}, sketch001)"
|
"sketch001 = startSketchOn('XY')\n |> startProfileAt([10, 0], %)\n |> line(end = [5, -5])\n |> line(end = [5, 5])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\npart001 = revolve({\n axis = {\n custom = {\n axis = [0.0, 1.0],\n origin = [0.0, 0.0]\n }\n }\n}, sketch001)",
|
||||||
|
"// Revolve two sketches around the same axis.\n\n\nsketch001 = startSketchOn('XY')\nprofile001 = startProfileAt([4, 8], sketch001)\n |> xLine(length = 3)\n |> yLine(length = -3)\n |> xLine(length = -3)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\nprofile002 = startProfileAt([-5, 8], sketch001)\n |> xLine(length = 3)\n |> yLine(length = -3)\n |> xLine(length = -3)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\nrevolve({ axis = \"X\" }, [profile001, profile002])"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -304862,86 +304927,118 @@
|
|||||||
{
|
{
|
||||||
"name": "sweep",
|
"name": "sweep",
|
||||||
"summary": "Extrude a sketch along a path.",
|
"summary": "Extrude a sketch along a path.",
|
||||||
"description": "This, like extrude, is able to create a 3-dimensional solid from a 2-dimensional sketch. However, unlike extrude, this creates a solid by using the extent of the sketch as its path. This is useful for creating more complex shapes that can't be created with a simple extrusion.",
|
"description": "This, like extrude, is able to create a 3-dimensional solid from a 2-dimensional sketch. However, unlike extrude, this creates a solid by using the extent of the sketch as its path. This is useful for creating more complex shapes that can't be created with a simple extrusion.\n\nYou can provide more than one sketch to sweep, and they will all be swept along the same path.",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"keywordArguments": true,
|
"keywordArguments": true,
|
||||||
"args": [
|
"args": [
|
||||||
{
|
{
|
||||||
"name": "sketch",
|
"name": "sketchSet",
|
||||||
"type": "Sketch",
|
"type": "SketchSet",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
"title": "Sketch",
|
"title": "SketchSet",
|
||||||
"type": "object",
|
"description": "A sketch or a group of sketches.",
|
||||||
"required": [
|
"oneOf": [
|
||||||
"__meta",
|
{
|
||||||
"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",
|
"type": "object",
|
||||||
"additionalProperties": {
|
"required": [
|
||||||
"$ref": "#/components/schemas/TagIdentifier"
|
"__meta",
|
||||||
|
"artifactId",
|
||||||
|
"id",
|
||||||
|
"on",
|
||||||
|
"originalId",
|
||||||
|
"paths",
|
||||||
|
"start",
|
||||||
|
"type",
|
||||||
|
"units"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"sketch"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"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"
|
||||||
|
},
|
||||||
|
"__meta": {
|
||||||
|
"description": "Metadata.",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/Metadata"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"artifactId": {
|
{
|
||||||
"description": "The original id of the sketch. This stays the same even if the sketch is is sketched on face etc.",
|
"type": [
|
||||||
"allOf": [
|
"object",
|
||||||
{
|
"array"
|
||||||
"$ref": "#/components/schemas/ArtifactId"
|
],
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"originalId": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "uuid"
|
|
||||||
},
|
|
||||||
"units": {
|
|
||||||
"$ref": "#/components/schemas/UnitLen"
|
|
||||||
},
|
|
||||||
"__meta": {
|
|
||||||
"description": "Metadata.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/components/schemas/Metadata"
|
"$ref": "#/components/schemas/Sketch"
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"type"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"sketches"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
],
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"Path": {
|
"Path": {
|
||||||
"description": "A path.",
|
"description": "A path.",
|
||||||
@ -306536,7 +306633,7 @@
|
|||||||
},
|
},
|
||||||
"required": true,
|
"required": true,
|
||||||
"includeInSnippet": true,
|
"includeInSnippet": true,
|
||||||
"description": "The sketch that should be swept in space",
|
"description": "The sketch or set of sketches that should be swept in space",
|
||||||
"labelRequired": false
|
"labelRequired": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -311516,84 +311613,116 @@
|
|||||||
],
|
],
|
||||||
"returnValue": {
|
"returnValue": {
|
||||||
"name": "",
|
"name": "",
|
||||||
"type": "Solid",
|
"type": "SolidSet",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
"title": "Solid",
|
"title": "SolidSet",
|
||||||
"type": "object",
|
"description": "A solid or a group of solids.",
|
||||||
"required": [
|
"oneOf": [
|
||||||
"__meta",
|
{
|
||||||
"artifactId",
|
"type": "object",
|
||||||
"height",
|
"required": [
|
||||||
"id",
|
"__meta",
|
||||||
"sketch",
|
"artifactId",
|
||||||
"units",
|
"height",
|
||||||
"value"
|
"id",
|
||||||
],
|
"sketch",
|
||||||
"properties": {
|
"type",
|
||||||
"id": {
|
"units",
|
||||||
"description": "The id of the solid.",
|
"value"
|
||||||
"type": "string",
|
],
|
||||||
"format": "uuid"
|
"properties": {
|
||||||
},
|
"type": {
|
||||||
"artifactId": {
|
"type": "string",
|
||||||
"description": "The artifact ID of the solid. Unlike `id`, this doesn't change.",
|
"enum": [
|
||||||
"allOf": [
|
"solid"
|
||||||
{
|
]
|
||||||
"$ref": "#/components/schemas/ArtifactId"
|
},
|
||||||
|
"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"
|
||||||
|
},
|
||||||
|
"__meta": {
|
||||||
|
"description": "Metadata.",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/Metadata"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"description": "The extrude surfaces.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/components/schemas/ExtrudeSurface"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sketch": {
|
{
|
||||||
"description": "The sketch.",
|
"type": [
|
||||||
"allOf": [
|
"object",
|
||||||
{
|
"array"
|
||||||
"$ref": "#/components/schemas/Sketch"
|
],
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/Solid"
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"type"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"solids"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
|
||||||
},
|
|
||||||
"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"
|
|
||||||
},
|
|
||||||
"__meta": {
|
|
||||||
"description": "Metadata.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/components/schemas/Metadata"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
],
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"ArtifactId": {
|
"ArtifactId": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -313194,7 +313323,8 @@
|
|||||||
"deprecated": false,
|
"deprecated": false,
|
||||||
"examples": [
|
"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 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(\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)",
|
||||||
|
"// Sweep two sketches along the same path.\n\n\nsketch001 = startSketchOn('XY')\nrectangleSketch = startProfileAt([-200, 23.86], sketch001)\n |> angledLine([0, 73.47], %, $rectangleSegmentA001)\n |> angledLine([\n segAng(rectangleSegmentA001) - 90,\n 50.61\n ], %)\n |> angledLine([\n segAng(rectangleSegmentA001),\n -segLen(rectangleSegmentA001)\n ], %)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)\n\nsketch002 = startSketchOn('YZ')\nsweepPath = startProfileAt([0, 0], sketch002)\n |> yLine(length = 231.81)\n |> tangentialArc({ radius = 80, offset = -90 }, %)\n |> xLine(length = 384.93)\n\nsweep([rectangleSketch, circleSketch], path = sweepPath)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -178,13 +178,8 @@ impl KclErrorWithOutputs {
|
|||||||
path: self
|
path: self
|
||||||
.filenames
|
.filenames
|
||||||
.get(&first_source_range.module_id())
|
.get(&first_source_range.module_id())
|
||||||
.ok_or_else(|| {
|
.cloned()
|
||||||
anyhow::anyhow!(
|
.unwrap_or(ModulePath::Main),
|
||||||
"Could not find filename for module id: {:?}",
|
|
||||||
first_source_range.module_id()
|
|
||||||
)
|
|
||||||
})?
|
|
||||||
.clone(),
|
|
||||||
});
|
});
|
||||||
let filename = source.path.to_string();
|
let filename = source.path.to_string();
|
||||||
let kcl_source = source.source.to_string();
|
let kcl_source = source.source.to_string();
|
||||||
@ -192,11 +187,10 @@ impl KclErrorWithOutputs {
|
|||||||
let mut related = Vec::new();
|
let mut related = Vec::new();
|
||||||
for source_range in source_ranges {
|
for source_range in source_ranges {
|
||||||
let module_id = source_range.module_id();
|
let module_id = source_range.module_id();
|
||||||
let source = self
|
let source = self.source_files.get(&module_id).cloned().unwrap_or(ModuleSource {
|
||||||
.source_files
|
source: code.to_string(),
|
||||||
.get(&module_id)
|
path: self.filenames.get(&module_id).cloned().unwrap_or(ModulePath::Main),
|
||||||
.cloned()
|
});
|
||||||
.ok_or_else(|| anyhow::anyhow!("Could not find source file for module id: {:?}", module_id))?;
|
|
||||||
let error = self.error.override_source_ranges(vec![source_range]);
|
let error = self.error.override_source_ranges(vec![source_range]);
|
||||||
let report = Report {
|
let report = Report {
|
||||||
error,
|
error,
|
||||||
|
@ -522,13 +522,6 @@ impl Args {
|
|||||||
FromArgs::from_args(self, 0)
|
FromArgs::from_args(self, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_data_and_sketch<'a, T>(&'a self) -> Result<(T, Sketch), KclError>
|
|
||||||
where
|
|
||||||
T: serde::de::DeserializeOwned + FromArgs<'a>,
|
|
||||||
{
|
|
||||||
FromArgs::from_args(self, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn get_data_and_sketch_set<'a, T>(&'a self) -> Result<(T, SketchSet), KclError>
|
pub(crate) fn get_data_and_sketch_set<'a, T>(&'a self) -> Result<(T, SketchSet), KclError>
|
||||||
where
|
where
|
||||||
T: serde::de::DeserializeOwned + FromArgs<'a>,
|
T: serde::de::DeserializeOwned + FromArgs<'a>,
|
||||||
|
@ -34,6 +34,9 @@ pub async fn extrude(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
|||||||
/// create new 3-dimensional volume, or if extruded into an existing volume,
|
/// create new 3-dimensional volume, or if extruded into an existing volume,
|
||||||
/// cut into an existing solid.
|
/// cut into an existing solid.
|
||||||
///
|
///
|
||||||
|
/// You can provide more than one sketch to extrude, and they will all be
|
||||||
|
/// extruded in the same direction.
|
||||||
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// example = startSketchOn('XZ')
|
/// example = startSketchOn('XZ')
|
||||||
/// |> startProfileAt([0, 0], %)
|
/// |> startProfileAt([0, 0], %)
|
||||||
@ -82,7 +85,7 @@ pub async fn extrude(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
|||||||
keywords = true,
|
keywords = true,
|
||||||
unlabeled_first = true,
|
unlabeled_first = true,
|
||||||
args = {
|
args = {
|
||||||
sketch_set = { docs = "Which sketches should be extruded"},
|
sketch_set = { docs = "Which sketch or set of sketches should be extruded"},
|
||||||
length = { docs = "How far to extrude the given sketches"},
|
length = { docs = "How far to extrude the given sketches"},
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
errors::{KclError, KclErrorDetails},
|
errors::{KclError, KclErrorDetails},
|
||||||
execution::{ExecState, KclValue, Sketch, Solid},
|
execution::{ExecState, KclValue, Sketch, SketchSet, SolidSet},
|
||||||
std::{axis_or_reference::Axis2dOrEdgeReference, extrude::do_post_extrude, fillet::default_tolerance, Args},
|
std::{axis_or_reference::Axis2dOrEdgeReference, extrude::do_post_extrude, fillet::default_tolerance, Args},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -28,12 +28,12 @@ pub struct RevolveData {
|
|||||||
pub tolerance: Option<f64>,
|
pub tolerance: Option<f64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Revolve a sketch around an axis.
|
/// Revolve a sketch or set of sketches around an axis.
|
||||||
pub async fn revolve(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
pub async fn revolve(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||||
let (data, sketch): (RevolveData, Sketch) = args.get_data_and_sketch()?;
|
let (data, sketch_set): (RevolveData, SketchSet) = args.get_data_and_sketch_set()?;
|
||||||
|
|
||||||
let value = inner_revolve(data, sketch, exec_state, args).await?;
|
let value = inner_revolve(data, sketch_set, exec_state, args).await?;
|
||||||
Ok(KclValue::Solid { value })
|
Ok(value.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Rotate a sketch around some provided axis, creating a solid from its extent.
|
/// Rotate a sketch around some provided axis, creating a solid from its extent.
|
||||||
@ -46,6 +46,9 @@ pub async fn revolve(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
|||||||
///
|
///
|
||||||
/// Revolve occurs around a local sketch axis rather than a global axis.
|
/// Revolve occurs around a local sketch axis rather than a global axis.
|
||||||
///
|
///
|
||||||
|
/// You can provide more than one sketch to revolve, and they will all be
|
||||||
|
/// revolved around the same axis.
|
||||||
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// part001 = startSketchOn('XY')
|
/// part001 = startSketchOn('XY')
|
||||||
/// |> startProfileAt([4, 12], %)
|
/// |> startProfileAt([4, 12], %)
|
||||||
@ -174,16 +177,39 @@ pub async fn revolve(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
|||||||
/// }
|
/// }
|
||||||
/// }, sketch001)
|
/// }, sketch001)
|
||||||
/// ```
|
/// ```
|
||||||
|
///
|
||||||
|
/// ```no_run
|
||||||
|
/// // Revolve two sketches around the same axis.
|
||||||
|
///
|
||||||
|
/// sketch001 = startSketchOn('XY')
|
||||||
|
/// profile001 = startProfileAt([4, 8], sketch001)
|
||||||
|
/// |> xLine(length = 3)
|
||||||
|
/// |> yLine(length = -3)
|
||||||
|
/// |> xLine(length = -3)
|
||||||
|
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||||
|
/// |> close()
|
||||||
|
///
|
||||||
|
/// profile002 = startProfileAt([-5, 8], sketch001)
|
||||||
|
/// |> xLine(length = 3)
|
||||||
|
/// |> yLine(length = -3)
|
||||||
|
/// |> xLine(length = -3)
|
||||||
|
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||||
|
/// |> close()
|
||||||
|
///
|
||||||
|
/// revolve({
|
||||||
|
/// axis = "X",
|
||||||
|
/// }, [profile001, profile002])
|
||||||
|
/// ```
|
||||||
#[stdlib {
|
#[stdlib {
|
||||||
name = "revolve",
|
name = "revolve",
|
||||||
feature_tree_operation = true,
|
feature_tree_operation = true,
|
||||||
}]
|
}]
|
||||||
async fn inner_revolve(
|
async fn inner_revolve(
|
||||||
data: RevolveData,
|
data: RevolveData,
|
||||||
sketch: Sketch,
|
sketch_set: SketchSet,
|
||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
args: Args,
|
args: Args,
|
||||||
) -> Result<Box<Solid>, KclError> {
|
) -> Result<SolidSet, KclError> {
|
||||||
if let Some(angle) = data.angle {
|
if let Some(angle) = data.angle {
|
||||||
// Return an error if the angle is zero.
|
// Return an error if the angle is zero.
|
||||||
// We don't use validate() here because we want to return a specific error message that is
|
// We don't use validate() here because we want to return a specific error message that is
|
||||||
@ -198,37 +224,44 @@ async fn inner_revolve(
|
|||||||
|
|
||||||
let angle = Angle::from_degrees(data.angle.unwrap_or(360.0));
|
let angle = Angle::from_degrees(data.angle.unwrap_or(360.0));
|
||||||
|
|
||||||
let id = exec_state.next_uuid();
|
let sketches: Vec<Sketch> = sketch_set.into();
|
||||||
match data.axis {
|
let mut solids = Vec::new();
|
||||||
Axis2dOrEdgeReference::Axis(axis) => {
|
for sketch in &sketches {
|
||||||
let (axis, origin) = axis.axis_and_origin()?;
|
let id = exec_state.next_uuid();
|
||||||
args.batch_modeling_cmd(
|
|
||||||
id,
|
match &data.axis {
|
||||||
ModelingCmd::from(mcmd::Revolve {
|
Axis2dOrEdgeReference::Axis(axis) => {
|
||||||
angle,
|
let (axis, origin) = axis.axis_and_origin()?;
|
||||||
target: sketch.id.into(),
|
args.batch_modeling_cmd(
|
||||||
axis,
|
id,
|
||||||
origin,
|
ModelingCmd::from(mcmd::Revolve {
|
||||||
tolerance: LengthUnit(data.tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))),
|
angle,
|
||||||
axis_is_2d: true,
|
target: sketch.id.into(),
|
||||||
}),
|
axis,
|
||||||
)
|
origin,
|
||||||
.await?;
|
tolerance: LengthUnit(data.tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))),
|
||||||
}
|
axis_is_2d: true,
|
||||||
Axis2dOrEdgeReference::Edge(edge) => {
|
}),
|
||||||
let edge_id = edge.get_engine_id(exec_state, &args)?;
|
)
|
||||||
args.batch_modeling_cmd(
|
.await?;
|
||||||
id,
|
}
|
||||||
ModelingCmd::from(mcmd::RevolveAboutEdge {
|
Axis2dOrEdgeReference::Edge(edge) => {
|
||||||
angle,
|
let edge_id = edge.get_engine_id(exec_state, &args)?;
|
||||||
target: sketch.id.into(),
|
args.batch_modeling_cmd(
|
||||||
edge_id,
|
id,
|
||||||
tolerance: LengthUnit(data.tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))),
|
ModelingCmd::from(mcmd::RevolveAboutEdge {
|
||||||
}),
|
angle,
|
||||||
)
|
target: sketch.id.into(),
|
||||||
.await?;
|
edge_id,
|
||||||
|
tolerance: LengthUnit(data.tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
solids.push(do_post_extrude(sketch.clone(), id.into(), 0.0, exec_state, args.clone()).await?);
|
||||||
}
|
}
|
||||||
|
|
||||||
do_post_extrude(sketch, id.into(), 0.0, exec_state, args).await
|
Ok(solids.into())
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
errors::KclError,
|
errors::KclError,
|
||||||
execution::{ExecState, Helix, KclValue, Sketch, Solid},
|
execution::{ExecState, Helix, KclValue, Sketch, SketchSet, SolidSet},
|
||||||
std::{extrude::do_post_extrude, fillet::default_tolerance, Args},
|
std::{extrude::do_post_extrude, fillet::default_tolerance, Args},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ pub async fn sweep(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
|||||||
let tolerance = args.get_kw_arg_opt("tolerance")?;
|
let tolerance = args.get_kw_arg_opt("tolerance")?;
|
||||||
|
|
||||||
let value = inner_sweep(sketch, path, sectional, tolerance, exec_state, args).await?;
|
let value = inner_sweep(sketch, path, sectional, tolerance, exec_state, args).await?;
|
||||||
Ok(KclValue::Solid { value })
|
Ok(value.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extrude a sketch along a path.
|
/// Extrude a sketch along a path.
|
||||||
@ -41,6 +41,9 @@ pub async fn sweep(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
|||||||
/// creating more complex shapes that can't be created with a simple
|
/// creating more complex shapes that can't be created with a simple
|
||||||
/// extrusion.
|
/// extrusion.
|
||||||
///
|
///
|
||||||
|
/// You can provide more than one sketch to sweep, and they will all be
|
||||||
|
/// swept along the same path.
|
||||||
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// // Create a pipe using a sweep.
|
/// // Create a pipe using a sweep.
|
||||||
///
|
///
|
||||||
@ -94,40 +97,79 @@ pub async fn sweep(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
|||||||
/// |> circle( center = [0, 0], radius = 1)
|
/// |> circle( center = [0, 0], radius = 1)
|
||||||
/// |> sweep(path = helixPath)
|
/// |> sweep(path = helixPath)
|
||||||
/// ```
|
/// ```
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// // Sweep two sketches along the same path.
|
||||||
|
///
|
||||||
|
/// sketch001 = startSketchOn('XY')
|
||||||
|
/// rectangleSketch = startProfileAt([-200, 23.86], sketch001)
|
||||||
|
/// |> angledLine([0, 73.47], %, $rectangleSegmentA001)
|
||||||
|
/// |> angledLine([
|
||||||
|
/// segAng(rectangleSegmentA001) - 90,
|
||||||
|
/// 50.61
|
||||||
|
/// ], %)
|
||||||
|
/// |> angledLine([
|
||||||
|
/// segAng(rectangleSegmentA001),
|
||||||
|
/// -segLen(rectangleSegmentA001)
|
||||||
|
/// ], %)
|
||||||
|
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||||
|
/// |> close()
|
||||||
|
///
|
||||||
|
/// circleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)
|
||||||
|
///
|
||||||
|
/// sketch002 = startSketchOn('YZ')
|
||||||
|
/// sweepPath = startProfileAt([0, 0], sketch002)
|
||||||
|
/// |> yLine(length = 231.81)
|
||||||
|
/// |> tangentialArc({
|
||||||
|
/// radius = 80,
|
||||||
|
/// offset = -90,
|
||||||
|
/// }, %)
|
||||||
|
/// |> xLine(length = 384.93)
|
||||||
|
///
|
||||||
|
/// sweep([rectangleSketch, circleSketch], path = sweepPath)
|
||||||
|
/// ```
|
||||||
#[stdlib {
|
#[stdlib {
|
||||||
name = "sweep",
|
name = "sweep",
|
||||||
feature_tree_operation = true,
|
feature_tree_operation = true,
|
||||||
keywords = true,
|
keywords = true,
|
||||||
unlabeled_first = true,
|
unlabeled_first = true,
|
||||||
args = {
|
args = {
|
||||||
sketch = { docs = "The sketch that should be swept in space" },
|
sketch_set = { docs = "The sketch or set of sketches that should be swept in space" },
|
||||||
path = { docs = "The path to sweep the sketch along" },
|
path = { docs = "The path to sweep the sketch along" },
|
||||||
sectional = { docs = "If true, the sweep will be broken up into sub-sweeps (extrusions, revolves, sweeps) based on the trajectory path components." },
|
sectional = { docs = "If true, the sweep will be broken up into sub-sweeps (extrusions, revolves, sweeps) based on the trajectory path components." },
|
||||||
tolerance = { docs = "Tolerance for this operation" },
|
tolerance = { docs = "Tolerance for this operation" },
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
async fn inner_sweep(
|
async fn inner_sweep(
|
||||||
sketch: Sketch,
|
sketch_set: SketchSet,
|
||||||
path: SweepPath,
|
path: SweepPath,
|
||||||
sectional: Option<bool>,
|
sectional: Option<bool>,
|
||||||
tolerance: Option<f64>,
|
tolerance: Option<f64>,
|
||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
args: Args,
|
args: Args,
|
||||||
) -> Result<Box<Solid>, KclError> {
|
) -> Result<SolidSet, KclError> {
|
||||||
let id = exec_state.next_uuid();
|
let trajectory = match path {
|
||||||
args.batch_modeling_cmd(
|
SweepPath::Sketch(sketch) => sketch.id.into(),
|
||||||
id,
|
SweepPath::Helix(helix) => helix.value.into(),
|
||||||
ModelingCmd::from(mcmd::Sweep {
|
};
|
||||||
target: sketch.id.into(),
|
|
||||||
trajectory: match path {
|
|
||||||
SweepPath::Sketch(sketch) => sketch.id.into(),
|
|
||||||
SweepPath::Helix(helix) => helix.value.into(),
|
|
||||||
},
|
|
||||||
sectional: sectional.unwrap_or(false),
|
|
||||||
tolerance: LengthUnit(tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))),
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
do_post_extrude(sketch, id.into(), 0.0, exec_state, args).await
|
let sketches: Vec<Sketch> = sketch_set.into();
|
||||||
|
let mut solids = Vec::new();
|
||||||
|
for sketch in &sketches {
|
||||||
|
let id = exec_state.next_uuid();
|
||||||
|
args.batch_modeling_cmd(
|
||||||
|
id,
|
||||||
|
ModelingCmd::from(mcmd::Sweep {
|
||||||
|
target: sketch.id.into(),
|
||||||
|
trajectory,
|
||||||
|
sectional: sectional.unwrap_or(false),
|
||||||
|
tolerance: LengthUnit(tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
solids.push(do_post_extrude(sketch.clone(), id.into(), 0.0, exec_state, args.clone()).await?);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(solids.into())
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/simulation_tests.rs
|
source: kcl-lib/src/simulation_tests.rs
|
||||||
description: Operations executed import_function_not_sketch.kcl
|
description: Operations executed import_function_not_sketch.kcl
|
||||||
---
|
---
|
||||||
[
|
[
|
||||||
@ -44,7 +44,7 @@ description: Operations executed import_function_not_sketch.kcl
|
|||||||
3
|
3
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
|
@ -325,7 +325,7 @@ description: Operations executed ball-bearing.kcl
|
|||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
@ -585,7 +585,7 @@ description: Operations executed ball-bearing.kcl
|
|||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
@ -833,7 +833,7 @@ description: Operations executed ball-bearing.kcl
|
|||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
|
@ -1845,7 +1845,7 @@ description: Operations executed car-wheel-assembly.kcl
|
|||||||
3
|
3
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
@ -1909,7 +1909,7 @@ description: Operations executed car-wheel-assembly.kcl
|
|||||||
3
|
3
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
@ -2851,7 +2851,7 @@ description: Operations executed car-wheel-assembly.kcl
|
|||||||
3
|
3
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
@ -3101,7 +3101,7 @@ description: Operations executed car-wheel-assembly.kcl
|
|||||||
6
|
6
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
@ -3540,7 +3540,7 @@ description: Operations executed car-wheel-assembly.kcl
|
|||||||
5
|
5
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
@ -3604,7 +3604,7 @@ description: Operations executed car-wheel-assembly.kcl
|
|||||||
7
|
7
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
|
@ -57,7 +57,7 @@ description: Operations executed french-press.kcl
|
|||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
@ -744,7 +744,7 @@ description: Operations executed french-press.kcl
|
|||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
@ -808,7 +808,7 @@ description: Operations executed french-press.kcl
|
|||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
@ -1340,7 +1340,7 @@ description: Operations executed french-press.kcl
|
|||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
|
@ -473,7 +473,7 @@ description: Operations executed gridfinity-baseplate-magnets.kcl
|
|||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
|
@ -473,7 +473,7 @@ description: Operations executed gridfinity-baseplate.kcl
|
|||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
|
@ -473,7 +473,7 @@ description: Operations executed gridfinity-bins-stacking-lip.kcl
|
|||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
@ -3012,7 +3012,7 @@ description: Operations executed gridfinity-bins-stacking-lip.kcl
|
|||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
@ -3346,7 +3346,7 @@ description: Operations executed gridfinity-bins-stacking-lip.kcl
|
|||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
|
@ -473,7 +473,7 @@ description: Operations executed gridfinity-bins.kcl
|
|||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
|
File diff suppressed because one or more lines are too long
@ -67,7 +67,7 @@ description: Operations executed pipe-flange-assembly.kcl
|
|||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/simulation_tests.rs
|
source: kcl-lib/src/simulation_tests.rs
|
||||||
description: Operations executed pipe-with-bend.kcl
|
description: Operations executed pipe-with-bend.kcl
|
||||||
---
|
---
|
||||||
[
|
[
|
||||||
@ -95,7 +95,7 @@ description: Operations executed pipe-with-bend.kcl
|
|||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
|
@ -44,7 +44,7 @@ description: Operations executed pipe.kcl
|
|||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
|
@ -125,7 +125,7 @@ description: Operations executed poopy-shoe.kcl
|
|||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
|
@ -3134,7 +3134,7 @@ description: Operations executed walkie-talkie.kcl
|
|||||||
7
|
7
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
|
BIN
rust/kcl-lib/tests/outputs/serial_test_example_revolve8.png
Normal file
BIN
rust/kcl-lib/tests/outputs/serial_test_example_revolve8.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 95 KiB |
BIN
rust/kcl-lib/tests/outputs/serial_test_example_sweep2.png
Normal file
BIN
rust/kcl-lib/tests/outputs/serial_test_example_sweep2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 91 KiB |
@ -125,7 +125,7 @@ description: Operations executed poop_chute.kcl
|
|||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
|
@ -81,7 +81,7 @@ description: Operations executed revolve_about_edge.kcl
|
|||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sketch": {
|
"sketchSet": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
|
Reference in New Issue
Block a user