fully remove show (#1592)
* fully remove show 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> * fmt Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * rm Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix tests --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch>
This commit is contained in:
@ -43186,978 +43186,6 @@
|
|||||||
"unpublished": false,
|
"unpublished": false,
|
||||||
"deprecated": false
|
"deprecated": false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "show",
|
|
||||||
"summary": "Render a model.",
|
|
||||||
"description": "",
|
|
||||||
"tags": [],
|
|
||||||
"args": [
|
|
||||||
{
|
|
||||||
"name": "sketch",
|
|
||||||
"type": "SketchGroup",
|
|
||||||
"schema": {
|
|
||||||
"description": "A sketch group is a collection of paths.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"__meta",
|
|
||||||
"id",
|
|
||||||
"on",
|
|
||||||
"position",
|
|
||||||
"rotation",
|
|
||||||
"start",
|
|
||||||
"value",
|
|
||||||
"xAxis",
|
|
||||||
"yAxis",
|
|
||||||
"zAxis"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"__meta": {
|
|
||||||
"description": "Metadata.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"description": "Metadata.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"sourceRange"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"sourceRange": {
|
|
||||||
"description": "The source range.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "uint",
|
|
||||||
"minimum": 0.0
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"entityId": {
|
|
||||||
"description": "The plane id or face id of the sketch group.",
|
|
||||||
"type": "string",
|
|
||||||
"format": "uuid",
|
|
||||||
"nullable": true
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
"description": "The id of the sketch group.",
|
|
||||||
"type": "string",
|
|
||||||
"format": "uuid"
|
|
||||||
},
|
|
||||||
"on": {
|
|
||||||
"description": "What the sketch is on (can be a plane or a face).",
|
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"description": "A plane.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"__meta",
|
|
||||||
"id",
|
|
||||||
"origin",
|
|
||||||
"type",
|
|
||||||
"value",
|
|
||||||
"xAxis",
|
|
||||||
"yAxis",
|
|
||||||
"zAxis"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"__meta": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"description": "Metadata.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"sourceRange"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"sourceRange": {
|
|
||||||
"description": "The source range.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "uint",
|
|
||||||
"minimum": 0.0
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
"description": "The id of the plane.",
|
|
||||||
"type": "string",
|
|
||||||
"format": "uuid"
|
|
||||||
},
|
|
||||||
"origin": {
|
|
||||||
"description": "Origin of the plane.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"x",
|
|
||||||
"y",
|
|
||||||
"z"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"x": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"y": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"z": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"plane"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"description": "Type for a plane.",
|
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"XY",
|
|
||||||
"XZ",
|
|
||||||
"YZ"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "A custom plane.",
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Custom"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"xAxis": {
|
|
||||||
"description": "What should the plane’s X axis be?",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"x",
|
|
||||||
"y",
|
|
||||||
"z"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"x": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"y": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"z": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"yAxis": {
|
|
||||||
"description": "What should the plane’s Y axis be?",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"x",
|
|
||||||
"y",
|
|
||||||
"z"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"x": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"y": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"z": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"zAxis": {
|
|
||||||
"description": "The z-axis (normal).",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"x",
|
|
||||||
"y",
|
|
||||||
"z"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"x": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"y": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"z": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "A face.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"__meta",
|
|
||||||
"id",
|
|
||||||
"sketchGroupId",
|
|
||||||
"type",
|
|
||||||
"value",
|
|
||||||
"xAxis",
|
|
||||||
"yAxis",
|
|
||||||
"zAxis"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"__meta": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"description": "Metadata.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"sourceRange"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"sourceRange": {
|
|
||||||
"description": "The source range.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "uint",
|
|
||||||
"minimum": 0.0
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
"description": "The id of the face.",
|
|
||||||
"type": "string",
|
|
||||||
"format": "uuid"
|
|
||||||
},
|
|
||||||
"sketchGroupId": {
|
|
||||||
"description": "The original sketch group id of the object we are sketching on.",
|
|
||||||
"type": "string",
|
|
||||||
"format": "uuid"
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"face"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"description": "The tag of the face.",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"xAxis": {
|
|
||||||
"description": "What should the face’s X axis be?",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"x",
|
|
||||||
"y",
|
|
||||||
"z"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"x": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"y": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"z": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"yAxis": {
|
|
||||||
"description": "What should the face’s Y axis be?",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"x",
|
|
||||||
"y",
|
|
||||||
"z"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"x": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"y": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"z": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"zAxis": {
|
|
||||||
"description": "The z-axis (normal).",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"x",
|
|
||||||
"y",
|
|
||||||
"z"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"x": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"y": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"z": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"position": {
|
|
||||||
"description": "The position of the sketch group.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"maxItems": 3,
|
|
||||||
"minItems": 3
|
|
||||||
},
|
|
||||||
"rotation": {
|
|
||||||
"description": "The rotation of the sketch group base plane.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"maxItems": 4,
|
|
||||||
"minItems": 4
|
|
||||||
},
|
|
||||||
"start": {
|
|
||||||
"description": "The starting path.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"__geoMeta",
|
|
||||||
"from",
|
|
||||||
"name",
|
|
||||||
"to"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"__geoMeta": {
|
|
||||||
"description": "Metadata.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"id",
|
|
||||||
"sourceRange"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"description": "The id of the geometry.",
|
|
||||||
"type": "string",
|
|
||||||
"format": "uuid"
|
|
||||||
},
|
|
||||||
"sourceRange": {
|
|
||||||
"description": "The source range.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "uint",
|
|
||||||
"minimum": 0.0
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"from": {
|
|
||||||
"description": "The from point.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"description": "The name of the path.",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"to": {
|
|
||||||
"description": "The to point.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"description": "The paths in the sketch group.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"description": "A path.",
|
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"description": "A path that goes to a point.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"__geoMeta",
|
|
||||||
"from",
|
|
||||||
"name",
|
|
||||||
"to",
|
|
||||||
"type"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"__geoMeta": {
|
|
||||||
"description": "Metadata.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"id",
|
|
||||||
"sourceRange"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"description": "The id of the geometry.",
|
|
||||||
"type": "string",
|
|
||||||
"format": "uuid"
|
|
||||||
},
|
|
||||||
"sourceRange": {
|
|
||||||
"description": "The source range.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "uint",
|
|
||||||
"minimum": 0.0
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"from": {
|
|
||||||
"description": "The from point.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"description": "The name of the path.",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"to": {
|
|
||||||
"description": "The to point.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"ToPoint"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "A arc that is tangential to the last path segment that goes to a point",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"__geoMeta",
|
|
||||||
"ccw",
|
|
||||||
"center",
|
|
||||||
"from",
|
|
||||||
"name",
|
|
||||||
"to",
|
|
||||||
"type"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"__geoMeta": {
|
|
||||||
"description": "Metadata.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"id",
|
|
||||||
"sourceRange"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"description": "The id of the geometry.",
|
|
||||||
"type": "string",
|
|
||||||
"format": "uuid"
|
|
||||||
},
|
|
||||||
"sourceRange": {
|
|
||||||
"description": "The source range.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "uint",
|
|
||||||
"minimum": 0.0
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ccw": {
|
|
||||||
"description": "arc's direction",
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"center": {
|
|
||||||
"description": "the arc's center",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
},
|
|
||||||
"from": {
|
|
||||||
"description": "The from point.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"description": "The name of the path.",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"to": {
|
|
||||||
"description": "The to point.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"TangentialArcTo"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "A arc that is tangential to the last path segment",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"__geoMeta",
|
|
||||||
"from",
|
|
||||||
"name",
|
|
||||||
"to",
|
|
||||||
"type"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"__geoMeta": {
|
|
||||||
"description": "Metadata.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"id",
|
|
||||||
"sourceRange"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"description": "The id of the geometry.",
|
|
||||||
"type": "string",
|
|
||||||
"format": "uuid"
|
|
||||||
},
|
|
||||||
"sourceRange": {
|
|
||||||
"description": "The source range.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "uint",
|
|
||||||
"minimum": 0.0
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"from": {
|
|
||||||
"description": "The from point.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"description": "The name of the path.",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"to": {
|
|
||||||
"description": "The to point.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"TangentialArc"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "A path that is horizontal.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"__geoMeta",
|
|
||||||
"from",
|
|
||||||
"name",
|
|
||||||
"to",
|
|
||||||
"type",
|
|
||||||
"x"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"__geoMeta": {
|
|
||||||
"description": "Metadata.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"id",
|
|
||||||
"sourceRange"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"description": "The id of the geometry.",
|
|
||||||
"type": "string",
|
|
||||||
"format": "uuid"
|
|
||||||
},
|
|
||||||
"sourceRange": {
|
|
||||||
"description": "The source range.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "uint",
|
|
||||||
"minimum": 0.0
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"from": {
|
|
||||||
"description": "The from point.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"description": "The name of the path.",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"to": {
|
|
||||||
"description": "The to point.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Horizontal"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"x": {
|
|
||||||
"description": "The x coordinate.",
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "An angled line to.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"__geoMeta",
|
|
||||||
"from",
|
|
||||||
"name",
|
|
||||||
"to",
|
|
||||||
"type"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"__geoMeta": {
|
|
||||||
"description": "Metadata.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"id",
|
|
||||||
"sourceRange"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"description": "The id of the geometry.",
|
|
||||||
"type": "string",
|
|
||||||
"format": "uuid"
|
|
||||||
},
|
|
||||||
"sourceRange": {
|
|
||||||
"description": "The source range.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "uint",
|
|
||||||
"minimum": 0.0
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"from": {
|
|
||||||
"description": "The from point.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"description": "The name of the path.",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"to": {
|
|
||||||
"description": "The to point.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
},
|
|
||||||
"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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "A base path.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"__geoMeta",
|
|
||||||
"from",
|
|
||||||
"name",
|
|
||||||
"to",
|
|
||||||
"type"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"__geoMeta": {
|
|
||||||
"description": "Metadata.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"id",
|
|
||||||
"sourceRange"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"description": "The id of the geometry.",
|
|
||||||
"type": "string",
|
|
||||||
"format": "uuid"
|
|
||||||
},
|
|
||||||
"sourceRange": {
|
|
||||||
"description": "The source range.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "uint",
|
|
||||||
"minimum": 0.0
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"from": {
|
|
||||||
"description": "The from point.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"description": "The name of the path.",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"to": {
|
|
||||||
"description": "The to point.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"maxItems": 2,
|
|
||||||
"minItems": 2
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Base"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"xAxis": {
|
|
||||||
"description": "The x-axis of the sketch group base plane in the 3D space",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"x",
|
|
||||||
"y",
|
|
||||||
"z"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"x": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"y": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"z": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"yAxis": {
|
|
||||||
"description": "The y-axis of the sketch group base plane in the 3D space",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"x",
|
|
||||||
"y",
|
|
||||||
"z"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"x": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"y": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"z": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"zAxis": {
|
|
||||||
"description": "The z-axis of the sketch group base plane in the 3D space",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"x",
|
|
||||||
"y",
|
|
||||||
"z"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"x": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"y": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"z": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"returnValue": null,
|
|
||||||
"unpublished": false,
|
|
||||||
"deprecated": false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "sin",
|
"name": "sin",
|
||||||
"summary": "Computes the sine of a number (in radians).",
|
"summary": "Computes the sine of a number (in radians).",
|
||||||
|
180
docs/kcl/std.md
180
docs/kcl/std.md
@ -50,7 +50,6 @@
|
|||||||
* [`segEndX`](#segEndX)
|
* [`segEndX`](#segEndX)
|
||||||
* [`segEndY`](#segEndY)
|
* [`segEndY`](#segEndY)
|
||||||
* [`segLen`](#segLen)
|
* [`segLen`](#segLen)
|
||||||
* [`show`](#show)
|
|
||||||
* [`sin`](#sin)
|
* [`sin`](#sin)
|
||||||
* [`sqrt`](#sqrt)
|
* [`sqrt`](#sqrt)
|
||||||
* [`startProfileAt`](#startProfileAt)
|
* [`startProfileAt`](#startProfileAt)
|
||||||
@ -7669,185 +7668,6 @@ segLen(segment_name: string, sketch_group: SketchGroup) -> number
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
### show
|
|
||||||
|
|
||||||
Render a model.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```
|
|
||||||
show(sketch: SketchGroup)
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Arguments
|
|
||||||
|
|
||||||
* `sketch`: `SketchGroup` - A sketch group is a collection of paths.
|
|
||||||
```
|
|
||||||
{
|
|
||||||
// The plane id or face id of the sketch group.
|
|
||||||
entityId: uuid,
|
|
||||||
// The id of the sketch group.
|
|
||||||
id: uuid,
|
|
||||||
// What the sketch is on (can be a plane or a face).
|
|
||||||
on: {
|
|
||||||
// The id of the plane.
|
|
||||||
id: uuid,
|
|
||||||
// Origin of the plane.
|
|
||||||
origin: {
|
|
||||||
x: number,
|
|
||||||
y: number,
|
|
||||||
z: number,
|
|
||||||
},
|
|
||||||
type: "plane",
|
|
||||||
// Type for a plane.
|
|
||||||
value: "XY" | "XZ" | "YZ" | "Custom",
|
|
||||||
// What should the plane’s X axis be?
|
|
||||||
xAxis: {
|
|
||||||
x: number,
|
|
||||||
y: number,
|
|
||||||
z: number,
|
|
||||||
},
|
|
||||||
// What should the plane’s Y axis be?
|
|
||||||
yAxis: {
|
|
||||||
x: number,
|
|
||||||
y: number,
|
|
||||||
z: number,
|
|
||||||
},
|
|
||||||
// The z-axis (normal).
|
|
||||||
zAxis: {
|
|
||||||
x: number,
|
|
||||||
y: number,
|
|
||||||
z: number,
|
|
||||||
},
|
|
||||||
} |
|
|
||||||
{
|
|
||||||
// The id of the face.
|
|
||||||
id: uuid,
|
|
||||||
// The original sketch group id of the object we are sketching on.
|
|
||||||
sketchGroupId: uuid,
|
|
||||||
type: "face",
|
|
||||||
// The tag of the face.
|
|
||||||
value: string,
|
|
||||||
// What should the face’s X axis be?
|
|
||||||
xAxis: {
|
|
||||||
x: number,
|
|
||||||
y: number,
|
|
||||||
z: number,
|
|
||||||
},
|
|
||||||
// What should the face’s Y axis be?
|
|
||||||
yAxis: {
|
|
||||||
x: number,
|
|
||||||
y: number,
|
|
||||||
z: number,
|
|
||||||
},
|
|
||||||
// The z-axis (normal).
|
|
||||||
zAxis: {
|
|
||||||
x: number,
|
|
||||||
y: number,
|
|
||||||
z: number,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// The position of the sketch group.
|
|
||||||
position: [number, number, number],
|
|
||||||
// The rotation of the sketch group base plane.
|
|
||||||
rotation: [number, number, number, number],
|
|
||||||
// The starting path.
|
|
||||||
start: {
|
|
||||||
// The from point.
|
|
||||||
from: [number, number],
|
|
||||||
// The name of the path.
|
|
||||||
name: string,
|
|
||||||
// The to point.
|
|
||||||
to: [number, number],
|
|
||||||
},
|
|
||||||
// The paths in the sketch group.
|
|
||||||
value: [{
|
|
||||||
// The from point.
|
|
||||||
from: [number, number],
|
|
||||||
// The name of the path.
|
|
||||||
name: string,
|
|
||||||
// The to point.
|
|
||||||
to: [number, number],
|
|
||||||
type: "ToPoint",
|
|
||||||
} |
|
|
||||||
{
|
|
||||||
// arc's direction
|
|
||||||
ccw: string,
|
|
||||||
// the arc's center
|
|
||||||
center: [number, number],
|
|
||||||
// The from point.
|
|
||||||
from: [number, number],
|
|
||||||
// The name of the path.
|
|
||||||
name: string,
|
|
||||||
// The to point.
|
|
||||||
to: [number, number],
|
|
||||||
type: "TangentialArcTo",
|
|
||||||
} |
|
|
||||||
{
|
|
||||||
// The from point.
|
|
||||||
from: [number, number],
|
|
||||||
// The name of the path.
|
|
||||||
name: string,
|
|
||||||
// The to point.
|
|
||||||
to: [number, number],
|
|
||||||
type: "TangentialArc",
|
|
||||||
} |
|
|
||||||
{
|
|
||||||
// The from point.
|
|
||||||
from: [number, number],
|
|
||||||
// The name of the path.
|
|
||||||
name: string,
|
|
||||||
// The to point.
|
|
||||||
to: [number, number],
|
|
||||||
type: "Horizontal",
|
|
||||||
// The x coordinate.
|
|
||||||
x: number,
|
|
||||||
} |
|
|
||||||
{
|
|
||||||
// The from point.
|
|
||||||
from: [number, number],
|
|
||||||
// The name of the path.
|
|
||||||
name: string,
|
|
||||||
// The to point.
|
|
||||||
to: [number, number],
|
|
||||||
type: "AngledLineTo",
|
|
||||||
// The x coordinate.
|
|
||||||
x: number,
|
|
||||||
// The y coordinate.
|
|
||||||
y: number,
|
|
||||||
} |
|
|
||||||
{
|
|
||||||
// The from point.
|
|
||||||
from: [number, number],
|
|
||||||
// The name of the path.
|
|
||||||
name: string,
|
|
||||||
// The to point.
|
|
||||||
to: [number, number],
|
|
||||||
type: "Base",
|
|
||||||
}],
|
|
||||||
// The x-axis of the sketch group base plane in the 3D space
|
|
||||||
xAxis: {
|
|
||||||
x: number,
|
|
||||||
y: number,
|
|
||||||
z: number,
|
|
||||||
},
|
|
||||||
// The y-axis of the sketch group base plane in the 3D space
|
|
||||||
yAxis: {
|
|
||||||
x: number,
|
|
||||||
y: number,
|
|
||||||
z: number,
|
|
||||||
},
|
|
||||||
// The z-axis of the sketch group base plane in the 3D space
|
|
||||||
zAxis: {
|
|
||||||
x: number,
|
|
||||||
y: number,
|
|
||||||
z: number,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### sin
|
### sin
|
||||||
|
|
||||||
Computes the sine of a number (in radians).
|
Computes the sine of a number (in radians).
|
||||||
|
@ -25,8 +25,7 @@ describe('processMemory', () => {
|
|||||||
|> lineTo([-3.35, 0.17], %)
|
|> lineTo([-3.35, 0.17], %)
|
||||||
|> lineTo([0.98, 5.16], %)
|
|> lineTo([0.98, 5.16], %)
|
||||||
|> lineTo([2.15, 4.32], %)
|
|> lineTo([2.15, 4.32], %)
|
||||||
// |> rx(90, %)
|
// |> rx(90, %)`
|
||||||
show(theExtrude, theSketch)`
|
|
||||||
const ast = parse(code)
|
const ast = parse(code)
|
||||||
const programMemory = await enginelessExecutor(ast, {
|
const programMemory = await enginelessExecutor(ast, {
|
||||||
root: {},
|
root: {},
|
||||||
|
@ -11,16 +11,11 @@ const mySketch001 = startSketchOn('XY')
|
|||||||
|> startProfileAt([0, 0], %)
|
|> startProfileAt([0, 0], %)
|
||||||
|> lineTo([-1.59, -1.54], %)
|
|> lineTo([-1.59, -1.54], %)
|
||||||
|> lineTo([0.46, -5.82], %)
|
|> lineTo([0.46, -5.82], %)
|
||||||
// |> rx(45, %)
|
// |> rx(45, %)`
|
||||||
show(mySketch001)`
|
|
||||||
const programMemory = await enginelessExecutor(parse(code))
|
const programMemory = await enginelessExecutor(parse(code))
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const shown = programMemory?.return?.map(
|
const sketch001 = programMemory?.root?.mySketch001
|
||||||
// @ts-ignore
|
expect(sketch001).toEqual({
|
||||||
(a) => programMemory?.root?.[a.name]
|
|
||||||
)
|
|
||||||
expect(shown).toEqual([
|
|
||||||
{
|
|
||||||
type: 'SketchGroup',
|
type: 'SketchGroup',
|
||||||
on: expect.any(Object),
|
on: expect.any(Object),
|
||||||
start: {
|
start: {
|
||||||
@ -62,8 +57,7 @@ show(mySketch001)`
|
|||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
entityId: expect.any(String),
|
entityId: expect.any(String),
|
||||||
__meta: [{ sourceRange: [46, 71] }],
|
__meta: [{ sourceRange: [46, 71] }],
|
||||||
},
|
})
|
||||||
])
|
|
||||||
})
|
})
|
||||||
test('extrude artifacts', async () => {
|
test('extrude artifacts', async () => {
|
||||||
// Enable rotations #152
|
// Enable rotations #152
|
||||||
@ -73,16 +67,11 @@ const mySketch001 = startSketchOn('XY')
|
|||||||
|> lineTo([-1.59, -1.54], %)
|
|> lineTo([-1.59, -1.54], %)
|
||||||
|> lineTo([0.46, -5.82], %)
|
|> lineTo([0.46, -5.82], %)
|
||||||
// |> rx(45, %)
|
// |> rx(45, %)
|
||||||
|> extrude(2, %)
|
|> extrude(2, %)`
|
||||||
show(mySketch001)`
|
|
||||||
const programMemory = await enginelessExecutor(parse(code))
|
const programMemory = await enginelessExecutor(parse(code))
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const shown = programMemory?.return?.map(
|
const sketch001 = programMemory?.root?.mySketch001
|
||||||
// @ts-ignore
|
expect(sketch001).toEqual({
|
||||||
(a) => programMemory?.root?.[a.name]
|
|
||||||
)
|
|
||||||
expect(shown).toEqual([
|
|
||||||
{
|
|
||||||
type: 'ExtrudeGroup',
|
type: 'ExtrudeGroup',
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
value: [],
|
value: [],
|
||||||
@ -95,8 +84,7 @@ show(mySketch001)`
|
|||||||
yAxis: { x: 0, y: 1, z: 0 },
|
yAxis: { x: 0, y: 1, z: 0 },
|
||||||
zAxis: { x: 0, y: 0, z: 1 },
|
zAxis: { x: 0, y: 0, z: 1 },
|
||||||
__meta: [{ sourceRange: [46, 71] }],
|
__meta: [{ sourceRange: [46, 71] }],
|
||||||
},
|
})
|
||||||
])
|
|
||||||
})
|
})
|
||||||
test('sketch extrude and sketch on one of the faces', async () => {
|
test('sketch extrude and sketch on one of the faces', async () => {
|
||||||
// Enable rotations #152
|
// Enable rotations #152
|
||||||
@ -120,14 +108,10 @@ const sk2 = startSketchOn('XY')
|
|||||||
// |> transform(theTransf, %)
|
// |> transform(theTransf, %)
|
||||||
|> extrude(2, %)
|
|> extrude(2, %)
|
||||||
|
|
||||||
|
`
|
||||||
show(theExtrude, sk2)`
|
|
||||||
const programMemory = await enginelessExecutor(parse(code))
|
const programMemory = await enginelessExecutor(parse(code))
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const geos = programMemory?.return?.map(
|
const geos = [programMemory?.root?.theExtrude, programMemory?.root?.sk2]
|
||||||
// @ts-ignore
|
|
||||||
({ name }) => programMemory?.root?.[name]
|
|
||||||
)
|
|
||||||
expect(geos).toEqual([
|
expect(geos).toEqual([
|
||||||
{
|
{
|
||||||
type: 'ExtrudeGroup',
|
type: 'ExtrudeGroup',
|
||||||
|
@ -47,9 +47,8 @@ const newVar = myVar + 1`
|
|||||||
|> lineTo([2,3], %)
|
|> lineTo([2,3], %)
|
||||||
|> lineTo({ to: [5,-1], tag: "rightPath" }, %)
|
|> lineTo({ to: [5,-1], tag: "rightPath" }, %)
|
||||||
// |> close(%)
|
// |> close(%)
|
||||||
show(mySketch)
|
|
||||||
`
|
`
|
||||||
const { root, return: _return } = await exe(code)
|
const { root } = await exe(code)
|
||||||
// geo is three js buffer geometry and is very bloated to have in tests
|
// geo is three js buffer geometry and is very bloated to have in tests
|
||||||
const minusGeo = root.mySketch.value
|
const minusGeo = root.mySketch.value
|
||||||
expect(minusGeo).toEqual([
|
expect(minusGeo).toEqual([
|
||||||
@ -84,15 +83,6 @@ show(mySketch)
|
|||||||
name: 'rightPath',
|
name: 'rightPath',
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
// expect(root.mySketch.sketch[0]).toEqual(root.mySketch.sketch[4].firstPath)
|
|
||||||
expect(_return).toEqual([
|
|
||||||
{
|
|
||||||
type: 'Identifier',
|
|
||||||
start: 203,
|
|
||||||
end: 211,
|
|
||||||
name: 'mySketch',
|
|
||||||
},
|
|
||||||
])
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('pipe binary expression into call expression', async () => {
|
it('pipe binary expression into call expression', async () => {
|
||||||
@ -357,7 +347,6 @@ describe('testing math operators', () => {
|
|||||||
` -legLen(segLen('seg01', %), myVar)`,
|
` -legLen(segLen('seg01', %), myVar)`,
|
||||||
`], %)`,
|
`], %)`,
|
||||||
``,
|
``,
|
||||||
`show(part001)`,
|
|
||||||
].join('\n')
|
].join('\n')
|
||||||
const { root } = await exe(code)
|
const { root } = await exe(code)
|
||||||
const sketch = root.part001
|
const sketch = root.part001
|
||||||
@ -392,8 +381,7 @@ const theExtrude = startSketchOn('XY')
|
|||||||
|> line([-0.76], myVarZ, %)
|
|> line([-0.76], myVarZ, %)
|
||||||
|> line([5,5], %)
|
|> line([5,5], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(4, %)
|
|> extrude(4, %)`
|
||||||
show(theExtrude)`
|
|
||||||
await expect(exe(code)).rejects.toEqual(
|
await expect(exe(code)).rejects.toEqual(
|
||||||
new KCLError(
|
new KCLError(
|
||||||
'undefined_value',
|
'undefined_value',
|
||||||
|
@ -122,7 +122,6 @@ describe('Testing addSketchTo', () => {
|
|||||||
expect(str).toBe(`const part001 = startSketchOn('YZ')
|
expect(str).toBe(`const part001 = startSketchOn('YZ')
|
||||||
|> startProfileAt('default', %)
|
|> startProfileAt('default', %)
|
||||||
|> line('default', %)
|
|> line('default', %)
|
||||||
show(part001)
|
|
||||||
`)
|
`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -147,8 +146,7 @@ describe('Testing giveSketchFnCallTag', () => {
|
|||||||
|> startProfileAt([0, 0], %)
|
|> startProfileAt([0, 0], %)
|
||||||
|> line([-2.57, -0.13], %)
|
|> line([-2.57, -0.13], %)
|
||||||
|> line([0, 0.83], %)
|
|> line([0, 0.83], %)
|
||||||
|> line([0.82, 0.34], %)
|
|> line([0.82, 0.34], %)`
|
||||||
show(part001)`
|
|
||||||
it('Should add tag to a sketch function call', () => {
|
it('Should add tag to a sketch function call', () => {
|
||||||
const { newCode, tag, isTagExisting } = giveSketchFnCallTagTestHelper(
|
const { newCode, tag, isTagExisting } = giveSketchFnCallTagTestHelper(
|
||||||
code,
|
code,
|
||||||
@ -204,8 +202,7 @@ const part001 = startSketchOn('XY')
|
|||||||
|> angledLine([def(yo), 3.09], %)
|
|> angledLine([def(yo), 3.09], %)
|
||||||
|> angledLine([ghi(%), 3.09], %)
|
|> angledLine([ghi(%), 3.09], %)
|
||||||
|> angledLine([jkl(yo) + 2, 3.09], %)
|
|> angledLine([jkl(yo) + 2, 3.09], %)
|
||||||
const yo2 = hmm([identifierGuy + 5])
|
const yo2 = hmm([identifierGuy + 5])`
|
||||||
show(part001)`
|
|
||||||
it('should move a binary expression into a new variable', async () => {
|
it('should move a binary expression into a new variable', async () => {
|
||||||
const ast = parse(code)
|
const ast = parse(code)
|
||||||
const programMemory = await enginelessExecutor(ast)
|
const programMemory = await enginelessExecutor(ast)
|
||||||
|
@ -128,16 +128,8 @@ export function addSketchTo(
|
|||||||
createPipeExpression(pipeBody)
|
createPipeExpression(pipeBody)
|
||||||
)
|
)
|
||||||
|
|
||||||
const showCallIndex = getShowIndex(_node)
|
|
||||||
let sketchIndex = showCallIndex
|
|
||||||
if (showCallIndex === -1) {
|
|
||||||
_node.body = [...node.body, variableDeclaration]
|
_node.body = [...node.body, variableDeclaration]
|
||||||
sketchIndex = _node.body.length - 1
|
let sketchIndex = _node.body.length - 1
|
||||||
} else {
|
|
||||||
const newBody = [...node.body]
|
|
||||||
newBody.splice(showCallIndex, 0, variableDeclaration)
|
|
||||||
_node.body = newBody
|
|
||||||
}
|
|
||||||
let pathToNode: PathToNode = [
|
let pathToNode: PathToNode = [
|
||||||
['body', ''],
|
['body', ''],
|
||||||
[sketchIndex, 'index'],
|
[sketchIndex, 'index'],
|
||||||
@ -150,7 +142,7 @@ export function addSketchTo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
modifiedAst: addToShow(_node, _name),
|
modifiedAst: _node,
|
||||||
id: _name,
|
id: _name,
|
||||||
pathToNode,
|
pathToNode,
|
||||||
}
|
}
|
||||||
@ -191,44 +183,6 @@ export function findUniqueName(
|
|||||||
return findUniqueName(searchStr, name, pad, index + 1)
|
return findUniqueName(searchStr, name, pad, index + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
function addToShow(node: Program, name: string): Program {
|
|
||||||
const _node = { ...node }
|
|
||||||
const dumbyStartend = { start: 0, end: 0 }
|
|
||||||
const showCallIndex = getShowIndex(_node)
|
|
||||||
if (showCallIndex === -1) {
|
|
||||||
const showCall = createCallExpressionStdLib('show', [
|
|
||||||
createIdentifier(name),
|
|
||||||
])
|
|
||||||
const showExpressionStatement: ExpressionStatement = {
|
|
||||||
type: 'ExpressionStatement',
|
|
||||||
...dumbyStartend,
|
|
||||||
expression: showCall,
|
|
||||||
}
|
|
||||||
_node.body = [..._node.body, showExpressionStatement]
|
|
||||||
return _node
|
|
||||||
}
|
|
||||||
const showCall = { ..._node.body[showCallIndex] } as ExpressionStatement
|
|
||||||
const showCallArgs = (showCall.expression as CallExpression).arguments
|
|
||||||
const newShowCallArgs: Value[] = [...showCallArgs, createIdentifier(name)]
|
|
||||||
const newShowExpression = createCallExpressionStdLib('show', newShowCallArgs)
|
|
||||||
|
|
||||||
_node.body[showCallIndex] = {
|
|
||||||
...showCall,
|
|
||||||
expression: newShowExpression,
|
|
||||||
}
|
|
||||||
return _node
|
|
||||||
}
|
|
||||||
|
|
||||||
function getShowIndex(node: Program): number {
|
|
||||||
return node.body.findIndex(
|
|
||||||
(statement) =>
|
|
||||||
statement.type === 'ExpressionStatement' &&
|
|
||||||
statement.expression.type === 'CallExpression' &&
|
|
||||||
statement.expression.callee.type === 'Identifier' &&
|
|
||||||
statement.expression.callee.name === 'show'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function mutateArrExp(
|
export function mutateArrExp(
|
||||||
node: Value,
|
node: Value,
|
||||||
updateWith: ArrayExpression
|
updateWith: ArrayExpression
|
||||||
@ -348,15 +302,10 @@ export function extrudeSketch(
|
|||||||
}
|
}
|
||||||
const name = findUniqueName(node, 'part')
|
const name = findUniqueName(node, 'part')
|
||||||
const VariableDeclaration = createVariableDeclaration(name, extrudeCall)
|
const VariableDeclaration = createVariableDeclaration(name, extrudeCall)
|
||||||
let showCallIndex = getShowIndex(_node)
|
_node.body.splice(_node.body.length, 0, VariableDeclaration)
|
||||||
if (showCallIndex === -1) {
|
|
||||||
// We didn't find a show, so let's just append everything
|
|
||||||
showCallIndex = _node.body.length
|
|
||||||
}
|
|
||||||
_node.body.splice(showCallIndex, 0, VariableDeclaration)
|
|
||||||
const pathToExtrudeArg: PathToNode = [
|
const pathToExtrudeArg: PathToNode = [
|
||||||
['body', ''],
|
['body', ''],
|
||||||
[showCallIndex, 'index'],
|
[_node.body.length, 'index'],
|
||||||
['declarations', 'VariableDeclaration'],
|
['declarations', 'VariableDeclaration'],
|
||||||
[0, 'index'],
|
[0, 'index'],
|
||||||
['init', 'VariableDeclarator'],
|
['init', 'VariableDeclarator'],
|
||||||
@ -365,7 +314,7 @@ export function extrudeSketch(
|
|||||||
]
|
]
|
||||||
return {
|
return {
|
||||||
modifiedAst: node,
|
modifiedAst: node,
|
||||||
pathToNode: [...pathToNode.slice(0, -1), [showCallIndex, 'index']],
|
pathToNode: [...pathToNode.slice(0, -1), [-1, 'index']],
|
||||||
pathToExtrudeArg,
|
pathToExtrudeArg,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -425,7 +374,7 @@ export function sketchOnExtrudedFace(
|
|||||||
_node.body.splice(expressionIndex + 1, 0, newSketch)
|
_node.body.splice(expressionIndex + 1, 0, newSketch)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
modifiedAst: addToShow(_node, newSketchName),
|
modifiedAst: _node,
|
||||||
pathToNode: [...pathToNode.slice(0, -1), [expressionIndex, 'index']],
|
pathToNode: [...pathToNode.slice(0, -1), [expressionIndex, 'index']],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,7 @@ const part001 = startSketchOn('XY')
|
|||||||
|> xLine(3.84, %) // selection-range-7ish-before-this
|
|> xLine(3.84, %) // selection-range-7ish-before-this
|
||||||
|
|
||||||
const variableBelowShouldNotBeIncluded = 3
|
const variableBelowShouldNotBeIncluded = 3
|
||||||
|
`
|
||||||
show(part001)`
|
|
||||||
const rangeStart = code.indexOf('// selection-range-7ish-before-this') - 7
|
const rangeStart = code.indexOf('// selection-range-7ish-before-this') - 7
|
||||||
const ast = parse(code)
|
const ast = parse(code)
|
||||||
const programMemory = await enginelessExecutor(ast)
|
const programMemory = await enginelessExecutor(ast)
|
||||||
@ -69,8 +68,7 @@ describe('testing argIsNotIdentifier', () => {
|
|||||||
|> angledLine([ghi(%), 3.09], %)
|
|> angledLine([ghi(%), 3.09], %)
|
||||||
|> angledLine([jkl('yo') + 2, 3.09], %)
|
|> angledLine([jkl('yo') + 2, 3.09], %)
|
||||||
const yo = 5 + 6
|
const yo = 5 + 6
|
||||||
const yo2 = hmm([identifierGuy + 5])
|
const yo2 = hmm([identifierGuy + 5])`
|
||||||
show(part001)`
|
|
||||||
it('find a safe binaryExpression', () => {
|
it('find a safe binaryExpression', () => {
|
||||||
const ast = parse(code)
|
const ast = parse(code)
|
||||||
const rangeStart = code.indexOf('100 + 100') + 2
|
const rangeStart = code.indexOf('100 + 100') + 2
|
||||||
@ -201,8 +199,7 @@ describe('testing getNodePathFromSourceRange', () => {
|
|||||||
const code = `const part001 = startSketchOn('XY')
|
const code = `const part001 = startSketchOn('XY')
|
||||||
|> startProfileAt([0.39, -0.05], %)
|
|> startProfileAt([0.39, -0.05], %)
|
||||||
|> line([0.94, 2.61], %)
|
|> line([0.94, 2.61], %)
|
||||||
|> line([-0.21, -1.4], %)
|
|> line([-0.21, -1.4], %)`
|
||||||
show(part001)`
|
|
||||||
it('finds the second line when cursor is put at the end', () => {
|
it('finds the second line when cursor is put at the end', () => {
|
||||||
const searchLn = `line([0.94, 2.61], %)`
|
const searchLn = `line([0.94, 2.61], %)`
|
||||||
const sourceIndex = code.indexOf(searchLn) + searchLn.length
|
const sourceIndex = code.indexOf(searchLn) + searchLn.length
|
||||||
|
@ -68,8 +68,6 @@ log(5, myVar)
|
|||||||
|> lineTo([1, 1], %)
|
|> lineTo([1, 1], %)
|
||||||
|> lineTo({ to: [1, 0], tag: "rightPath" }, %)
|
|> lineTo({ to: [1, 0], tag: "rightPath" }, %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|
|
||||||
show(mySketch)
|
|
||||||
`
|
`
|
||||||
const { ast } = code2ast(code)
|
const { ast } = code2ast(code)
|
||||||
const recasted = recast(ast)
|
const recasted = recast(ast)
|
||||||
@ -331,7 +329,6 @@ describe('it recasts wrapped object expressions in pipe bodies with correct inde
|
|||||||
intersectTag: 'seg01'
|
intersectTag: 'seg01'
|
||||||
}, %)
|
}, %)
|
||||||
|> line([-0.42, -1.72], %)
|
|> line([-0.42, -1.72], %)
|
||||||
show(part001)
|
|
||||||
`
|
`
|
||||||
const { ast } = code2ast(code)
|
const { ast } = code2ast(code)
|
||||||
const recasted = recast(ast)
|
const recasted = recast(ast)
|
||||||
|
@ -101,7 +101,6 @@ describe('testing changeSketchArguments', () => {
|
|||||||
|> ${line}
|
|> ${line}
|
||||||
|> lineTo([0.46, -5.82], %)
|
|> lineTo([0.46, -5.82], %)
|
||||||
// |> rx(45, %)
|
// |> rx(45, %)
|
||||||
show(mySketch001)
|
|
||||||
`
|
`
|
||||||
const code = genCode(lineToChange)
|
const code = genCode(lineToChange)
|
||||||
const expectedCode = genCode(lineAfterChange)
|
const expectedCode = genCode(lineAfterChange)
|
||||||
@ -128,8 +127,7 @@ const mySketch001 = startSketchOn('XY')
|
|||||||
|> startProfileAt([0, 0], %)
|
|> startProfileAt([0, 0], %)
|
||||||
// |> rx(45, %)
|
// |> rx(45, %)
|
||||||
|> lineTo([-1.59, -1.54], %)
|
|> lineTo([-1.59, -1.54], %)
|
||||||
|> lineTo([0.46, -5.82], %)
|
|> lineTo([0.46, -5.82], %)`
|
||||||
show(mySketch001)`
|
|
||||||
const ast = parse(code)
|
const ast = parse(code)
|
||||||
const programMemory = await enginelessExecutor(ast)
|
const programMemory = await enginelessExecutor(ast)
|
||||||
const sourceStart = code.indexOf(lineToChange)
|
const sourceStart = code.indexOf(lineToChange)
|
||||||
@ -155,7 +153,6 @@ show(mySketch001)`
|
|||||||
|> lineTo([-1.59, -1.54], %)
|
|> lineTo([-1.59, -1.54], %)
|
||||||
|> lineTo([0.46, -5.82], %)
|
|> lineTo([0.46, -5.82], %)
|
||||||
|> lineTo([2, 3], %)
|
|> lineTo([2, 3], %)
|
||||||
show(mySketch001)
|
|
||||||
`
|
`
|
||||||
expect(recast(modifiedAst)).toBe(expectedCode)
|
expect(recast(modifiedAst)).toBe(expectedCode)
|
||||||
|
|
||||||
@ -177,7 +174,6 @@ show(mySketch001)
|
|||||||
|> lineTo([-1.59, -1.54], %)
|
|> lineTo([-1.59, -1.54], %)
|
||||||
|> lineTo([0.46, -5.82], %)
|
|> lineTo([0.46, -5.82], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
show(mySketch001)
|
|
||||||
`
|
`
|
||||||
expect(recast(modifiedAst)).toBe(expectedCode)
|
expect(recast(modifiedAst)).toBe(expectedCode)
|
||||||
})
|
})
|
||||||
@ -192,7 +188,6 @@ describe('testing addTagForSketchOnFace', () => {
|
|||||||
// |> rx(45, %)
|
// |> rx(45, %)
|
||||||
|> ${line}
|
|> ${line}
|
||||||
|> lineTo([0.46, -5.82], %)
|
|> lineTo([0.46, -5.82], %)
|
||||||
show(mySketch001)
|
|
||||||
`
|
`
|
||||||
const code = genCode(originalLine)
|
const code = genCode(originalLine)
|
||||||
const ast = parse(code)
|
const ast = parse(code)
|
||||||
|
@ -88,7 +88,6 @@ describe('testing swapping out sketch calls with xLine/xLineTo', () => {
|
|||||||
` |> yLine(-1.07, %)`,
|
` |> yLine(-1.07, %)`,
|
||||||
` |> xLineTo(3.27, %)`,
|
` |> xLineTo(3.27, %)`,
|
||||||
` |> yLineTo(2.14, %)`,
|
` |> yLineTo(2.14, %)`,
|
||||||
`show(part001)`,
|
|
||||||
]
|
]
|
||||||
const bigExample = bigExampleArr.join('\n')
|
const bigExample = bigExampleArr.join('\n')
|
||||||
it('line with tag converts to xLine', async () => {
|
it('line with tag converts to xLine', async () => {
|
||||||
@ -290,7 +289,6 @@ describe('testing swapping out sketch calls with xLine/xLineTo while keeping var
|
|||||||
` |> angledLineToX([330, angledLineToXx], %)`,
|
` |> angledLineToX([330, angledLineToXx], %)`,
|
||||||
` |> angledLineToY([217, angledLineToYy], %)`,
|
` |> angledLineToY([217, angledLineToYy], %)`,
|
||||||
` |> line([0.89, -0.1], %)`,
|
` |> line([0.89, -0.1], %)`,
|
||||||
`show(part001)`,
|
|
||||||
]
|
]
|
||||||
const varExample = variablesExampleArr.join('\n')
|
const varExample = variablesExampleArr.join('\n')
|
||||||
it('line keeps variable when converted to xLine', async () => {
|
it('line keeps variable when converted to xLine', async () => {
|
||||||
@ -378,8 +376,7 @@ const part001 = startSketchOn('XY')
|
|||||||
|> line([0, 0.4], %)
|
|> line([0, 0.4], %)
|
||||||
|> xLine(3.48, %)
|
|> xLine(3.48, %)
|
||||||
|> line([2.14, 1.35], %) // normal-segment
|
|> line([2.14, 1.35], %) // normal-segment
|
||||||
|> xLine(3.54, %)
|
|> xLine(3.54, %)`
|
||||||
show(part001)`
|
|
||||||
it('normal case works', async () => {
|
it('normal case works', async () => {
|
||||||
const programMemory = await enginelessExecutor(parse(code))
|
const programMemory = await enginelessExecutor(parse(code))
|
||||||
const index = code.indexOf('// normal-segment') - 7
|
const index = code.indexOf('// normal-segment') - 7
|
||||||
|
@ -123,7 +123,6 @@ const part001 = startSketchOn('XY')
|
|||||||
|> yLine(1.04, %) // ln-yLine-free should sub in segLen
|
|> yLine(1.04, %) // ln-yLine-free should sub in segLen
|
||||||
|> xLineTo(30, %) // ln-xLineTo-free should convert to xLine
|
|> xLineTo(30, %) // ln-xLineTo-free should convert to xLine
|
||||||
|> yLineTo(20, %) // ln-yLineTo-free should convert to yLine
|
|> yLineTo(20, %) // ln-yLineTo-free should convert to yLine
|
||||||
show(part001)
|
|
||||||
`
|
`
|
||||||
const expectModifiedScript = `const myVar = 3
|
const expectModifiedScript = `const myVar = 3
|
||||||
const myVar2 = 5
|
const myVar2 = 5
|
||||||
@ -196,7 +195,6 @@ const part001 = startSketchOn('XY')
|
|||||||
|> yLine(segLen('seg01', %), %) // ln-yLine-free should sub in segLen
|
|> yLine(segLen('seg01', %), %) // ln-yLine-free should sub in segLen
|
||||||
|> xLine(segLen('seg01', %), %) // ln-xLineTo-free should convert to xLine
|
|> xLine(segLen('seg01', %), %) // ln-xLineTo-free should convert to xLine
|
||||||
|> yLine(segLen('seg01', %), %) // ln-yLineTo-free should convert to yLine
|
|> yLine(segLen('seg01', %), %) // ln-yLineTo-free should convert to yLine
|
||||||
show(part001)
|
|
||||||
`
|
`
|
||||||
it('should transform the ast', async () => {
|
it('should transform the ast', async () => {
|
||||||
const ast = parse(inputScript)
|
const ast = parse(inputScript)
|
||||||
@ -257,7 +255,6 @@ const part001 = startSketchOn('XY')
|
|||||||
|> angledLineToY([223, 7.68], %) // select for vertical constraint 9
|
|> angledLineToY([223, 7.68], %) // select for vertical constraint 9
|
||||||
|> angledLineToX([333, myVar3], %) // select for horizontal constraint 10
|
|> angledLineToX([333, myVar3], %) // select for horizontal constraint 10
|
||||||
|> angledLineToY([301, myVar], %) // select for vertical constraint 10
|
|> angledLineToY([301, myVar], %) // select for vertical constraint 10
|
||||||
show(part001)
|
|
||||||
`
|
`
|
||||||
it('should transform horizontal lines the ast', async () => {
|
it('should transform horizontal lines the ast', async () => {
|
||||||
const expectModifiedScript = `const myVar = 2
|
const expectModifiedScript = `const myVar = 2
|
||||||
@ -286,7 +283,6 @@ const part001 = startSketchOn('XY')
|
|||||||
|> angledLineToY([223, 7.68], %) // select for vertical constraint 9
|
|> angledLineToY([223, 7.68], %) // select for vertical constraint 9
|
||||||
|> xLineTo(myVar3, %) // select for horizontal constraint 10
|
|> xLineTo(myVar3, %) // select for horizontal constraint 10
|
||||||
|> angledLineToY([301, myVar], %) // select for vertical constraint 10
|
|> angledLineToY([301, myVar], %) // select for vertical constraint 10
|
||||||
show(part001)
|
|
||||||
`
|
`
|
||||||
const ast = parse(inputScript)
|
const ast = parse(inputScript)
|
||||||
const selectionRanges: Selections['codeBasedSelections'] = inputScript
|
const selectionRanges: Selections['codeBasedSelections'] = inputScript
|
||||||
@ -345,7 +341,6 @@ const part001 = startSketchOn('XY')
|
|||||||
|> yLineTo(7.68, %) // select for vertical constraint 9
|
|> yLineTo(7.68, %) // select for vertical constraint 9
|
||||||
|> angledLineToX([333, myVar3], %) // select for horizontal constraint 10
|
|> angledLineToX([333, myVar3], %) // select for horizontal constraint 10
|
||||||
|> yLineTo(myVar, %) // select for vertical constraint 10
|
|> yLineTo(myVar, %) // select for vertical constraint 10
|
||||||
show(part001)
|
|
||||||
`
|
`
|
||||||
const ast = parse(inputScript)
|
const ast = parse(inputScript)
|
||||||
const selectionRanges: Selections['codeBasedSelections'] = inputScript
|
const selectionRanges: Selections['codeBasedSelections'] = inputScript
|
||||||
@ -389,7 +384,6 @@ const part001 = startSketchOn('XY')
|
|||||||
|> line([0.45, 1.46], %) // free
|
|> line([0.45, 1.46], %) // free
|
||||||
|> line([myVar, 0.01], %) // xRelative
|
|> line([myVar, 0.01], %) // xRelative
|
||||||
|> line([0.7, myVar], %) // yRelative
|
|> line([0.7, myVar], %) // yRelative
|
||||||
show(part001)
|
|
||||||
`
|
`
|
||||||
it('testing for free to horizontal and vertical distance', async () => {
|
it('testing for free to horizontal and vertical distance', async () => {
|
||||||
const expectedHorizontalCode = await helperThing(
|
const expectedHorizontalCode = await helperThing(
|
||||||
@ -501,8 +495,7 @@ const part001 = startSketchOn('XY')
|
|||||||
|> xLine(3.36, %) // partial
|
|> xLine(3.36, %) // partial
|
||||||
|> line([-1.49, 1.06], %) // free
|
|> line([-1.49, 1.06], %) // free
|
||||||
|> xLine(-3.43 + 0, %) // full
|
|> xLine(-3.43 + 0, %) // full
|
||||||
|> angledLineOfXLength([243 + 0, 1.2 + 0], %) // full
|
|> angledLineOfXLength([243 + 0, 1.2 + 0], %) // full`
|
||||||
show(part001)`
|
|
||||||
const ast = parse(code)
|
const ast = parse(code)
|
||||||
const constraintLevels: ReturnType<
|
const constraintLevels: ReturnType<
|
||||||
typeof getConstraintLevelFromSourceRange
|
typeof getConstraintLevelFromSourceRange
|
||||||
|
@ -15,8 +15,7 @@ describe('testing angledLineThatIntersects', () => {
|
|||||||
offset: ${offset},
|
offset: ${offset},
|
||||||
tag: "yo2"
|
tag: "yo2"
|
||||||
}, %)
|
}, %)
|
||||||
const intersect = segEndX('yo2', part001)
|
const intersect = segEndX('yo2', part001)`
|
||||||
show(part001)`
|
|
||||||
const { root } = await enginelessExecutor(parse(code('-1')))
|
const { root } = await enginelessExecutor(parse(code('-1')))
|
||||||
expect(root.intersect.value).toBe(1 + Math.sqrt(2))
|
expect(root.intersect.value).toBe(1 + Math.sqrt(2))
|
||||||
const { root: noOffset } = await enginelessExecutor(parse(code('0')))
|
const { root: noOffset } = await enginelessExecutor(parse(code('0')))
|
||||||
|
@ -3091,8 +3091,7 @@ let baz = {a: 1, b: "thing"}
|
|||||||
fn ghi = (x) => {
|
fn ghi = (x) => {
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
"#;
|
||||||
show(part001)"#;
|
|
||||||
let tokens = crate::token::lexer(code);
|
let tokens = crate::token::lexer(code);
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
let program = parser.ast().unwrap();
|
let program = parser.ast().unwrap();
|
||||||
@ -3372,9 +3371,7 @@ const mySk1 = startSketchOn('XY')
|
|||||||
offset: -1.35,
|
offset: -1.35,
|
||||||
intersectTag: 'seg01'
|
intersectTag: 'seg01'
|
||||||
}, %)
|
}, %)
|
||||||
|> line([-0.42, -1.72], %)
|
|> line([-0.42, -1.72], %)"#;
|
||||||
|
|
||||||
show(part001)"#;
|
|
||||||
let tokens = crate::token::lexer(some_program_string);
|
let tokens = crate::token::lexer(some_program_string);
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
let program = parser.ast().unwrap();
|
let program = parser.ast().unwrap();
|
||||||
@ -3523,8 +3520,7 @@ let baz = {a: 1, part001: "thing"}
|
|||||||
fn ghi = (part001) => {
|
fn ghi = (part001) => {
|
||||||
return part001
|
return part001
|
||||||
}
|
}
|
||||||
|
"#;
|
||||||
show(part001)"#;
|
|
||||||
let tokens = crate::token::lexer(some_program_string);
|
let tokens = crate::token::lexer(some_program_string);
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
let mut program = parser.ast().unwrap();
|
let mut program = parser.ast().unwrap();
|
||||||
@ -3546,8 +3542,6 @@ let baz = { a: 1, part001: "thing" }
|
|||||||
fn ghi = (part001) => {
|
fn ghi = (part001) => {
|
||||||
return part001
|
return part001
|
||||||
}
|
}
|
||||||
|
|
||||||
show(mySuperCoolPart)
|
|
||||||
"#
|
"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -3676,8 +3670,7 @@ const firstExtrude = startSketchOn('XY')
|
|||||||
|> line([0, -l], %)
|
|> line([0, -l], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(h, %)
|
|> extrude(h, %)
|
||||||
|
"#;
|
||||||
show(firstExtrude)"#;
|
|
||||||
let tokens = crate::token::lexer(some_program_string);
|
let tokens = crate::token::lexer(some_program_string);
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
let program = parser.ast().unwrap();
|
let program = parser.ast().unwrap();
|
||||||
@ -3696,8 +3689,6 @@ const firstExtrude = startSketchOn('XY')
|
|||||||
|> line([0, -l], %)
|
|> line([0, -l], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(h, %)
|
|> extrude(h, %)
|
||||||
|
|
||||||
show(firstExtrude)
|
|
||||||
"#
|
"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -3718,8 +3709,7 @@ const firstExtrude = startSketchOn('XY')
|
|||||||
|> line([0, -l], %)
|
|> line([0, -l], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(h, %)
|
|> extrude(h, %)
|
||||||
|
"#;
|
||||||
show(firstExtrude)"#;
|
|
||||||
let tokens = crate::token::lexer(some_program_string);
|
let tokens = crate::token::lexer(some_program_string);
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
let program = parser.ast().unwrap();
|
let program = parser.ast().unwrap();
|
||||||
@ -3741,8 +3731,6 @@ const firstExtrude = startSketchOn('XY')
|
|||||||
|> line([0, -l], %)
|
|> line([0, -l], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(h, %)
|
|> extrude(h, %)
|
||||||
|
|
||||||
show(firstExtrude)
|
|
||||||
"#
|
"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -566,17 +566,4 @@ mod tests {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_deserialize_function_show() {
|
|
||||||
let some_function_string = r#"{"type":"StdLib","func":{"name":"show","summary":"","description":"","tags":[],"returnValue":{"type":"","required":false,"name":"","schema":{}},"args":[],"unpublished":false,"deprecated":false}}"#;
|
|
||||||
let some_function: crate::ast::types::Function = serde_json::from_str(some_function_string).unwrap();
|
|
||||||
|
|
||||||
assert_eq!(
|
|
||||||
some_function,
|
|
||||||
crate::ast::types::Function::StdLib {
|
|
||||||
func: Box::new(crate::std::Show),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1017,7 +1017,7 @@ impl ExecutorContext {
|
|||||||
pub async fn execute(
|
pub async fn execute(
|
||||||
program: crate::ast::types::Program,
|
program: crate::ast::types::Program,
|
||||||
memory: &mut ProgramMemory,
|
memory: &mut ProgramMemory,
|
||||||
options: BodyType,
|
_options: BodyType,
|
||||||
ctx: &ExecutorContext,
|
ctx: &ExecutorContext,
|
||||||
) -> Result<ProgramMemory, KclError> {
|
) -> Result<ProgramMemory, KclError> {
|
||||||
// Before we even start executing the program, set the units.
|
// Before we even start executing the program, set the units.
|
||||||
@ -1073,25 +1073,12 @@ pub async fn execute(
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let _show_fn = Box::new(crate::std::Show);
|
|
||||||
match ctx.stdlib.get_either(&call_expr.callee.name) {
|
match ctx.stdlib.get_either(&call_expr.callee.name) {
|
||||||
FunctionKind::Core(func) => {
|
FunctionKind::Core(func) => {
|
||||||
use crate::docs::StdLibFn;
|
|
||||||
if func.name() == _show_fn.name() {
|
|
||||||
if options != BodyType::Root {
|
|
||||||
return Err(KclError::Semantic(KclErrorDetails {
|
|
||||||
message: "Cannot call show outside of a root".to_string(),
|
|
||||||
source_ranges: vec![call_expr.into()],
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
memory.return_ = Some(ProgramReturn::Arguments(call_expr.arguments.clone()));
|
|
||||||
} else {
|
|
||||||
let args = crate::std::Args::new(args, call_expr.into(), ctx.clone());
|
let args = crate::std::Args::new(args, call_expr.into(), ctx.clone());
|
||||||
let result = func.std_lib_fn()(args).await?;
|
let result = func.std_lib_fn()(args).await?;
|
||||||
memory.return_ = Some(ProgramReturn::Value(result));
|
memory.return_ = Some(ProgramReturn::Value(result));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
FunctionKind::Std(func) => {
|
FunctionKind::Std(func) => {
|
||||||
let mut newmem = memory.clone();
|
let mut newmem = memory.clone();
|
||||||
let result = execute(func.program().to_owned(), &mut newmem, BodyType::Block, ctx).await?;
|
let result = execute(func.program().to_owned(), &mut newmem, BodyType::Block, ctx).await?;
|
||||||
@ -1352,8 +1339,7 @@ const newVar = myVar + 1"#;
|
|||||||
offset: {},
|
offset: {},
|
||||||
tag: "yo2"
|
tag: "yo2"
|
||||||
}}, %)
|
}}, %)
|
||||||
const intersect = segEndX('yo2', part001)
|
const intersect = segEndX('yo2', part001)"#,
|
||||||
show(part001)"#,
|
|
||||||
offset
|
offset
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
@ -1399,8 +1385,7 @@ const part001 = startSketchOn('XY')
|
|||||||
|> angledLine([ghi(2), 3.04], %)
|
|> angledLine([ghi(2), 3.04], %)
|
||||||
|> angledLine([jkl(yo) + 2, 3.05], %)
|
|> angledLine([jkl(yo) + 2, 3.05], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
const yo2 = hmm([identifierGuy + 5])
|
const yo2 = hmm([identifierGuy + 5])"#;
|
||||||
show(part001)"#;
|
|
||||||
|
|
||||||
parse_execute(ast).await.unwrap();
|
parse_execute(ast).await.unwrap();
|
||||||
}
|
}
|
||||||
@ -1415,8 +1400,7 @@ const part001 = startSketchOn('XY')
|
|||||||
min(segLen('seg01', %), myVar),
|
min(segLen('seg01', %), myVar),
|
||||||
-legLen(segLen('seg01', %), myVar)
|
-legLen(segLen('seg01', %), myVar)
|
||||||
], %)
|
], %)
|
||||||
|
"#;
|
||||||
show(part001)"#;
|
|
||||||
|
|
||||||
parse_execute(ast).await.unwrap();
|
parse_execute(ast).await.unwrap();
|
||||||
}
|
}
|
||||||
@ -1431,8 +1415,7 @@ const part001 = startSketchOn('XY')
|
|||||||
min(segLen('seg01', %), myVar),
|
min(segLen('seg01', %), myVar),
|
||||||
legLen(segLen('seg01', %), myVar)
|
legLen(segLen('seg01', %), myVar)
|
||||||
], %)
|
], %)
|
||||||
|
"#;
|
||||||
show(part001)"#;
|
|
||||||
|
|
||||||
parse_execute(ast).await.unwrap();
|
parse_execute(ast).await.unwrap();
|
||||||
}
|
}
|
||||||
@ -1454,8 +1437,7 @@ const part001 = startSketchOn('XY')
|
|||||||
|> xLine(3.84, %) // selection-range-7ish-before-this
|
|> xLine(3.84, %) // selection-range-7ish-before-this
|
||||||
|
|
||||||
const variableBelowShouldNotBeIncluded = 3
|
const variableBelowShouldNotBeIncluded = 3
|
||||||
|
"#;
|
||||||
show(part001)"#;
|
|
||||||
|
|
||||||
parse_execute(ast).await.unwrap();
|
parse_execute(ast).await.unwrap();
|
||||||
}
|
}
|
||||||
@ -1476,9 +1458,7 @@ const firstExtrude = startSketchOn('XY')
|
|||||||
|> line([w, 0], %)
|
|> line([w, 0], %)
|
||||||
|> line([0, thing()], %)
|
|> line([0, thing()], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(h, %)
|
|> extrude(h, %)"#;
|
||||||
|
|
||||||
show(firstExtrude)"#;
|
|
||||||
|
|
||||||
parse_execute(ast).await.unwrap();
|
parse_execute(ast).await.unwrap();
|
||||||
}
|
}
|
||||||
@ -1499,9 +1479,7 @@ const firstExtrude = startSketchOn('XY')
|
|||||||
|> line([w, 0], %)
|
|> line([w, 0], %)
|
||||||
|> line([0, thing(8)], %)
|
|> line([0, thing(8)], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(h, %)
|
|> extrude(h, %)"#;
|
||||||
|
|
||||||
show(firstExtrude)"#;
|
|
||||||
|
|
||||||
parse_execute(ast).await.unwrap();
|
parse_execute(ast).await.unwrap();
|
||||||
}
|
}
|
||||||
@ -1522,9 +1500,7 @@ const firstExtrude = startSketchOn('XY')
|
|||||||
|> line([w, 0], %)
|
|> line([w, 0], %)
|
||||||
|> line(thing(8), %)
|
|> line(thing(8), %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(h, %)
|
|> extrude(h, %)"#;
|
||||||
|
|
||||||
show(firstExtrude)"#;
|
|
||||||
|
|
||||||
parse_execute(ast).await.unwrap();
|
parse_execute(ast).await.unwrap();
|
||||||
}
|
}
|
||||||
@ -1549,9 +1525,7 @@ const firstExtrude = startSketchOn('XY')
|
|||||||
|> line([w, 0], %)
|
|> line([w, 0], %)
|
||||||
|> line([0, thing(8)], %)
|
|> line([0, thing(8)], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(h, %)
|
|> extrude(h, %)"#;
|
||||||
|
|
||||||
show(firstExtrude)"#;
|
|
||||||
|
|
||||||
parse_execute(ast).await.unwrap();
|
parse_execute(ast).await.unwrap();
|
||||||
}
|
}
|
||||||
@ -1570,9 +1544,7 @@ show(firstExtrude)"#;
|
|||||||
return myBox
|
return myBox
|
||||||
}
|
}
|
||||||
|
|
||||||
const fnBox = box(3, 6, 10)
|
const fnBox = box(3, 6, 10)"#;
|
||||||
|
|
||||||
show(fnBox)"#;
|
|
||||||
|
|
||||||
parse_execute(ast).await.unwrap();
|
parse_execute(ast).await.unwrap();
|
||||||
}
|
}
|
||||||
@ -1592,8 +1564,6 @@ show(fnBox)"#;
|
|||||||
}
|
}
|
||||||
|
|
||||||
const thisBox = box({start: [0,0], l: 6, w: 10, h: 3})
|
const thisBox = box({start: [0,0], l: 6, w: 10, h: 3})
|
||||||
|
|
||||||
show(thisBox)
|
|
||||||
"#;
|
"#;
|
||||||
parse_execute(ast).await.unwrap();
|
parse_execute(ast).await.unwrap();
|
||||||
}
|
}
|
||||||
@ -1613,8 +1583,6 @@ show(thisBox)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const thisBox = box({start: [0,0], l: 6, w: 10, h: 3})
|
const thisBox = box({start: [0,0], l: 6, w: 10, h: 3})
|
||||||
|
|
||||||
show(thisBox)
|
|
||||||
"#;
|
"#;
|
||||||
parse_execute(ast).await.unwrap();
|
parse_execute(ast).await.unwrap();
|
||||||
}
|
}
|
||||||
@ -1634,8 +1602,6 @@ show(thisBox)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const thisBox = box({start: [0,0], l: 6, w: 10, h: 3})
|
const thisBox = box({start: [0,0], l: 6, w: 10, h: 3})
|
||||||
|
|
||||||
show(thisBox)
|
|
||||||
"#;
|
"#;
|
||||||
parse_execute(ast).await.unwrap();
|
parse_execute(ast).await.unwrap();
|
||||||
}
|
}
|
||||||
@ -1657,7 +1623,6 @@ let myBox = startSketchOn('XY')
|
|||||||
|
|
||||||
for var in [{start: [0,0], l: 6, w: 10, h: 3}, {start: [-10,-10], l: 3, w: 5, h: 1.5}] {
|
for var in [{start: [0,0], l: 6, w: 10, h: 3}, {start: [-10,-10], l: 3, w: 5, h: 1.5}] {
|
||||||
const thisBox = box(var)
|
const thisBox = box(var)
|
||||||
show(thisBox)
|
|
||||||
}"#;
|
}"#;
|
||||||
|
|
||||||
parse_execute(ast).await.unwrap();
|
parse_execute(ast).await.unwrap();
|
||||||
@ -1681,7 +1646,6 @@ for var in [{start: [0,0], l: 6, w: 10, h: 3}, {start: [-10,-10], l: 3, w: 5, h:
|
|||||||
|
|
||||||
for var in [[3, 6, 10, [0,0]], [1.5, 3, 5, [-10,-10]]] {
|
for var in [[3, 6, 10, [0,0]], [1.5, 3, 5, [-10,-10]]] {
|
||||||
const thisBox = box(var[0], var[1], var[2], var[3])
|
const thisBox = box(var[0], var[1], var[2], var[3])
|
||||||
show(thisBox)
|
|
||||||
}"#;
|
}"#;
|
||||||
|
|
||||||
parse_execute(ast).await.unwrap();
|
parse_execute(ast).await.unwrap();
|
||||||
@ -1703,7 +1667,6 @@ for var in [[3, 6, 10, [0,0]], [1.5, 3, 5, [-10,-10]]] {
|
|||||||
|
|
||||||
const thisBox = box([[0,0], 6, 10, 3])
|
const thisBox = box([[0,0], 6, 10, 3])
|
||||||
|
|
||||||
show(thisBox)
|
|
||||||
"#;
|
"#;
|
||||||
parse_execute(ast).await.unwrap();
|
parse_execute(ast).await.unwrap();
|
||||||
}
|
}
|
||||||
@ -1820,7 +1783,6 @@ const bracket = startSketchOn('XY')
|
|||||||
|> line([0, -1 * leg1 + thickness], %)
|
|> line([0, -1 * leg1 + thickness], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(width, %)
|
|> extrude(width, %)
|
||||||
show(bracket)
|
|
||||||
"#;
|
"#;
|
||||||
parse_execute(ast).await.unwrap();
|
parse_execute(ast).await.unwrap();
|
||||||
}
|
}
|
||||||
@ -1845,7 +1807,6 @@ const bracket = startSketchOn('XY')
|
|||||||
|> line([0, -1 * leg1 + thickness], %)
|
|> line([0, -1 * leg1 + thickness], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(width, %)
|
|> extrude(width, %)
|
||||||
show(bracket)
|
|
||||||
"#;
|
"#;
|
||||||
parse_execute(ast).await.unwrap();
|
parse_execute(ast).await.unwrap();
|
||||||
}
|
}
|
||||||
|
@ -17,14 +17,13 @@ use tower_lsp::{
|
|||||||
DocumentSymbol, DocumentSymbolParams, DocumentSymbolResponse, Documentation, FullDocumentDiagnosticReport,
|
DocumentSymbol, DocumentSymbolParams, DocumentSymbolResponse, Documentation, FullDocumentDiagnosticReport,
|
||||||
Hover, HoverContents, HoverParams, HoverProviderCapability, InitializeParams, InitializeResult,
|
Hover, HoverContents, HoverParams, HoverProviderCapability, InitializeParams, InitializeResult,
|
||||||
InitializedParams, InlayHint, InlayHintParams, InsertTextFormat, MarkupContent, MarkupKind, MessageType, OneOf,
|
InitializedParams, InlayHint, InlayHintParams, InsertTextFormat, MarkupContent, MarkupKind, MessageType, OneOf,
|
||||||
ParameterInformation, ParameterLabel, Position, RelatedFullDocumentDiagnosticReport, RenameFilesParams,
|
Position, RelatedFullDocumentDiagnosticReport, RenameFilesParams, RenameParams, SemanticToken,
|
||||||
RenameParams, SemanticToken, SemanticTokenType, SemanticTokens, SemanticTokensFullOptions,
|
SemanticTokenType, SemanticTokens, SemanticTokensFullOptions, SemanticTokensLegend, SemanticTokensOptions,
|
||||||
SemanticTokensLegend, SemanticTokensOptions, SemanticTokensParams, SemanticTokensRegistrationOptions,
|
SemanticTokensParams, SemanticTokensRegistrationOptions, SemanticTokensResult,
|
||||||
SemanticTokensResult, SemanticTokensServerCapabilities, ServerCapabilities, SignatureHelp,
|
SemanticTokensServerCapabilities, ServerCapabilities, SignatureHelp, SignatureHelpOptions, SignatureHelpParams,
|
||||||
SignatureHelpOptions, SignatureHelpParams, SignatureInformation, StaticRegistrationOptions, TextDocumentItem,
|
StaticRegistrationOptions, TextDocumentItem, TextDocumentRegistrationOptions, TextDocumentSyncCapability,
|
||||||
TextDocumentRegistrationOptions, TextDocumentSyncCapability, TextDocumentSyncKind, TextDocumentSyncOptions,
|
TextDocumentSyncKind, TextDocumentSyncOptions, TextEdit, WorkDoneProgressOptions, WorkspaceEdit,
|
||||||
TextEdit, WorkDoneProgressOptions, WorkspaceEdit, WorkspaceFoldersServerCapabilities,
|
WorkspaceFoldersServerCapabilities, WorkspaceServerCapabilities,
|
||||||
WorkspaceServerCapabilities,
|
|
||||||
},
|
},
|
||||||
Client, LanguageServer,
|
Client, LanguageServer,
|
||||||
};
|
};
|
||||||
@ -659,27 +658,6 @@ pub fn get_signatures_from_stdlib(stdlib: &crate::std::StdLib) -> Result<HashMap
|
|||||||
signatures.insert(internal_fn.name(), internal_fn.to_signature_help());
|
signatures.insert(internal_fn.name(), internal_fn.to_signature_help());
|
||||||
}
|
}
|
||||||
|
|
||||||
let show = SignatureHelp {
|
|
||||||
signatures: vec![SignatureInformation {
|
|
||||||
label: "show".to_string(),
|
|
||||||
documentation: Some(Documentation::MarkupContent(MarkupContent {
|
|
||||||
kind: MarkupKind::PlainText,
|
|
||||||
value: "Show a model.".to_string(),
|
|
||||||
})),
|
|
||||||
parameters: Some(vec![ParameterInformation {
|
|
||||||
label: ParameterLabel::Simple("sg: SketchGroup".to_string()),
|
|
||||||
documentation: Some(Documentation::MarkupContent(MarkupContent {
|
|
||||||
kind: MarkupKind::PlainText,
|
|
||||||
value: "A sketch group.".to_string(),
|
|
||||||
})),
|
|
||||||
}]),
|
|
||||||
active_parameter: None,
|
|
||||||
}],
|
|
||||||
active_signature: Some(0),
|
|
||||||
active_parameter: None,
|
|
||||||
};
|
|
||||||
signatures.insert("show".to_string(), show);
|
|
||||||
|
|
||||||
Ok(signatures)
|
Ok(signatures)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1909,7 +1909,6 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
let test_program = r#"startSketchAt([0, 0])
|
let test_program = r#"startSketchAt([0, 0])
|
||||||
|> lineTo([0, -0], %) // MoveRelative
|
|> lineTo([0, -0], %) // MoveRelative
|
||||||
|
|
||||||
show(svg)
|
|
||||||
"#;
|
"#;
|
||||||
let tokens = crate::token::lexer(test_program);
|
let tokens = crate::token::lexer(test_program);
|
||||||
let mut slice = &tokens[..];
|
let mut slice = &tokens[..];
|
||||||
@ -2239,8 +2238,6 @@ const firstExtrude = startSketchOn('XY')
|
|||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(2, %)
|
|> extrude(2, %)
|
||||||
|
|
||||||
show(firstExtrude)
|
|
||||||
|
|
||||||
const secondExtrude = startSketchOn('XY')
|
const secondExtrude = startSketchOn('XY')
|
||||||
|> startProfileAt([0,0], %)
|
|> startProfileAt([0,0], %)
|
||||||
|",
|
|",
|
||||||
@ -2724,9 +2721,7 @@ const b2 = cube([3,3], 4)
|
|||||||
|
|
||||||
const pt1 = b1[0]
|
const pt1 = b1[0]
|
||||||
const pt2 = b2[0]
|
const pt2 = b2[0]
|
||||||
|
"#;
|
||||||
show(b1)
|
|
||||||
show(b2)"#;
|
|
||||||
let tokens = crate::token::lexer(some_program_string);
|
let tokens = crate::token::lexer(some_program_string);
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
parser.ast().unwrap();
|
parser.ast().unwrap();
|
||||||
@ -2755,7 +2750,7 @@ let other_thing = 2 * cos(3)"#;
|
|||||||
return myBox
|
return myBox
|
||||||
}
|
}
|
||||||
let myBox = box([0,0], -3, -16, -10)
|
let myBox = box([0,0], -3, -16, -10)
|
||||||
show(myBox)"#;
|
"#;
|
||||||
let tokens = crate::token::lexer(some_program_string);
|
let tokens = crate::token::lexer(some_program_string);
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
parser.ast().unwrap();
|
parser.ast().unwrap();
|
||||||
|
@ -4,7 +4,7 @@ expression: actual
|
|||||||
---
|
---
|
||||||
{
|
{
|
||||||
"start": 0,
|
"start": 0,
|
||||||
"end": 74,
|
"end": 59,
|
||||||
"body": [
|
"body": [
|
||||||
{
|
{
|
||||||
"type": "VariableDeclaration",
|
"type": "VariableDeclaration",
|
||||||
@ -121,34 +121,6 @@ expression: actual
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"kind": "const"
|
"kind": "const"
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "ExpressionStatement",
|
|
||||||
"type": "ExpressionStatement",
|
|
||||||
"start": 59,
|
|
||||||
"end": 73,
|
|
||||||
"expression": {
|
|
||||||
"type": "CallExpression",
|
|
||||||
"type": "CallExpression",
|
|
||||||
"start": 59,
|
|
||||||
"end": 73,
|
|
||||||
"callee": {
|
|
||||||
"type": "Identifier",
|
|
||||||
"start": 59,
|
|
||||||
"end": 63,
|
|
||||||
"name": "show"
|
|
||||||
},
|
|
||||||
"arguments": [
|
|
||||||
{
|
|
||||||
"type": "Identifier",
|
|
||||||
"type": "Identifier",
|
|
||||||
"start": 64,
|
|
||||||
"end": 72,
|
|
||||||
"name": "cylinder"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"optional": false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"nonCodeMeta": {
|
"nonCodeMeta": {
|
||||||
|
@ -37,7 +37,6 @@ pub type FnMap = HashMap<String, StdFn>;
|
|||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref CORE_FNS: Vec<Box<dyn StdLibFn>> = vec![
|
static ref CORE_FNS: Vec<Box<dyn StdLibFn>> = vec![
|
||||||
Box::new(Show),
|
|
||||||
Box::new(LegLen),
|
Box::new(LegLen),
|
||||||
Box::new(LegAngX),
|
Box::new(LegAngX),
|
||||||
Box::new(LegAngY),
|
Box::new(LegAngY),
|
||||||
@ -714,21 +713,6 @@ impl Args {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Render a model.
|
|
||||||
// This never actually gets called so this is fine.
|
|
||||||
pub async fn show<'a>(args: Args) -> Result<MemoryItem, KclError> {
|
|
||||||
let sketch_group = args.get_sketch_group()?;
|
|
||||||
inner_show(sketch_group);
|
|
||||||
|
|
||||||
args.make_user_val_from_f64(0.0)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Render a model.
|
|
||||||
#[stdlib {
|
|
||||||
name = "show",
|
|
||||||
}]
|
|
||||||
fn inner_show(_sketch: Box<SketchGroup>) {}
|
|
||||||
|
|
||||||
/// Returns the length of the given leg.
|
/// Returns the length of the given leg.
|
||||||
pub async fn leg_length(args: Args) -> Result<MemoryItem, KclError> {
|
pub async fn leg_length(args: Args) -> Result<MemoryItem, KclError> {
|
||||||
let (hypotenuse, leg) = args.get_hypotenuse_leg()?;
|
let (hypotenuse, leg) = args.get_hypotenuse_leg()?;
|
||||||
|
@ -1463,13 +1463,13 @@ const things = "things"
|
|||||||
fn test_kitt() {
|
fn test_kitt() {
|
||||||
let program = include_str!("../../../tests/executor/inputs/kittycad_svg.kcl");
|
let program = include_str!("../../../tests/executor/inputs/kittycad_svg.kcl");
|
||||||
let actual = lexer(program).unwrap();
|
let actual = lexer(program).unwrap();
|
||||||
assert_eq!(actual.len(), 5098);
|
assert_eq!(actual.len(), 5093);
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn test_pipes_on_pipes() {
|
fn test_pipes_on_pipes() {
|
||||||
let program = include_str!("../../../tests/executor/inputs/pipes_on_pipes.kcl");
|
let program = include_str!("../../../tests/executor/inputs/pipes_on_pipes.kcl");
|
||||||
let actual = lexer(program).unwrap();
|
let actual = lexer(program).unwrap();
|
||||||
assert_eq!(actual.len(), 17846);
|
assert_eq!(actual.len(), 17841);
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn test_lexer_negative_word() {
|
fn test_lexer_negative_word() {
|
||||||
|
@ -17,4 +17,3 @@ fn cube = (length, center) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const myCube = cube(40, [0,0])
|
const myCube = cube(40, [0,0])
|
||||||
show(myCube)
|
|
||||||
|
@ -1,2 +1 @@
|
|||||||
const cylinder = circle('XY', [0,0], 22) |> extrude(14, %)
|
const cylinder = circle('XY', [0,0], 22) |> extrude(14, %)
|
||||||
show(cylinder)
|
|
||||||
|
@ -308,4 +308,3 @@ const svg = startSketchOn('XY')
|
|||||||
|> lineTo([13.44, -13.44], %) // VerticalLineHorizonal
|
|> lineTo([13.44, -13.44], %) // VerticalLineHorizonal
|
||||||
|> lineTo([14.28, -13.44], %) // HorizontalLineRelative
|
|> lineTo([14.28, -13.44], %) // HorizontalLineRelative
|
||||||
|> close(%)
|
|> close(%)
|
||||||
show(svg)
|
|
||||||
|
@ -468,4 +468,3 @@ const svg = startSketchOn('XY')
|
|||||||
|> bezierCurve({ control1: [0, -2], control2: [-2.68, -2.67], to: [-1.36, -2.34] }, %) // CubicBezierAbsolute
|
|> bezierCurve({ control1: [0, -2], control2: [-2.68, -2.67], to: [-1.36, -2.34] }, %) // CubicBezierAbsolute
|
||||||
|> bezierCurve({ control1: [0, -0], control2: [0, -1.34], to: [0, -0.68] }, %) // CubicBezierAbsolute
|
|> bezierCurve({ control1: [0, -0], control2: [0, -1.34], to: [0, -0.68] }, %) // CubicBezierAbsolute
|
||||||
|> close(%)
|
|> close(%)
|
||||||
show(svg)
|
|
||||||
|
Reference in New Issue
Block a user