Compare commits

...

6 Commits

Author SHA1 Message Date
3811c88b5c properly flush batch (#5565)
* properly flush batch

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* add test

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* add test

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* only flush if not on error

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* better method

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* ensure nothing in batch assembly test

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-02-28 19:52:14 +00:00
69a1473197 Scheduled e2e tests on main (#5551)
* WIP: Scheduled e2e tests

* Update .github/workflows/e2e-tests.yml

Co-authored-by: Jonathan Tran <jonnytran@gmail.com>

---------

Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
2025-02-28 18:55:45 +00:00
1f1e996cfa Bugfix: absolute line segment dragging behavior offset was relative (#5571)
* Refactor: Use the named constant for 'endAbsolute' in more places

* Bugfix: lineTo was calculating relative distances instead of absolute

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-02-28 12:50:14 -05:00
58167deda7 Fix file I/O errors to not be engine type errors (#5554)
* Fix file I/O errors to not be engine type errors

* Update output
2025-02-28 12:08:44 -05:00
83d22a4f5f Release kcl 44 (#5570) 2025-02-28 09:56:19 -06:00
7003b19a70 Release kcl 42 (#5569) 2025-02-28 09:50:32 -06:00
26 changed files with 2634 additions and 57 deletions

View File

@ -3,6 +3,8 @@ on:
push:
branches: [ main ]
pull_request:
schedule:
- cron: 0 * * * * # hourly
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@ -15,23 +17,6 @@ permissions:
jobs:
check-rust-changes:
runs-on: ubuntu-latest
outputs:
rust-changed: ${{ steps.filter.outputs.rust }}
steps:
- uses: actions/checkout@v4
- id: filter
name: Check for Rust changes
uses: dorny/paths-filter@v3
with:
filters: |
rust:
- 'src/wasm-lib/**'
electron:
timeout-minutes: 60
name: playwright:electron:${{ matrix.os }} ${{ matrix.shardIndex }} ${{ matrix.shardTotal }}
@ -42,8 +27,8 @@ jobs:
os: [namespace-profile-ubuntu-8-cores, namespace-profile-macos-8-cores, windows-16-cores]
shardIndex: [1, 2, 3, 4]
shardTotal: [4]
# TODO: add ref here for main and latest release tag
runs-on: ${{ matrix.os }}
needs: check-rust-changes
steps:
- uses: actions/create-github-app-token@v1
id: app-token
@ -54,6 +39,13 @@ jobs:
- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- id: filter
name: Check for Rust changes
uses: dorny/paths-filter@v3
with:
filters: |
rust:
- 'src/wasm-lib/**'
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
@ -73,7 +65,7 @@ jobs:
run: yarn playwright install --with-deps
- name: Download Wasm Cache
id: download-wasm
if: needs.check-rust-changes.outputs.rust-changed == 'false'
if: github.event_name != 'schedule' && steps.filter.outputs.rust == 'false'
uses: dawidd6/action-download-artifact@v7
continue-on-error: true
with:
@ -83,7 +75,7 @@ jobs:
branch: main
path: src/wasm-lib/pkg
- name: copy wasm blob
if: needs.check-rust-changes.outputs.rust-changed == 'false'
if: github.event_name != 'schedule' && steps.filter.outputs.rust == 'false'
shell: bash
run: cp src/wasm-lib/pkg/wasm_lib_bg.wasm public
continue-on-error: true
@ -93,7 +85,7 @@ jobs:
with:
tool: wasm-pack
- name: Cache Wasm (because rust diff)
if: needs.check-rust-changes.outputs.rust-changed == 'true'
if: github.event_name == 'schedule' || steps.filter.outputs.rust == 'true'
uses: Swatinem/rust-cache@v2
with:
workspaces: './src/wasm-lib'
@ -126,7 +118,7 @@ jobs:
cat /tmp/vector.toml
${HOME}/.vector/bin/vector --config /tmp/vector.toml &
- name: Build Wasm (because rust diff)
if: needs.check-rust-changes.outputs.rust-changed == 'true'
if: github.event_name == 'schedule' || steps.filter.outputs.rust == 'true'
shell: bash
run: yarn build:wasm
- name: OR Build Wasm (because wasm cache failed)

View File

@ -29,5 +29,5 @@
}
}
],
"kcl_version": "0.2.41"
"kcl_version": "0.2.44"
}

View File

@ -72,6 +72,7 @@ import {
addCallExpressionsToPipe,
addCloseToPipe,
addNewSketchLn,
ARG_END_ABSOLUTE,
changeSketchArguments,
updateStartProfileAtArgs,
} from 'lang/std/sketch'
@ -904,7 +905,7 @@ export class SceneEntities {
createPipeSubstitution(),
])
: createCallExpressionStdLibKw('line', null, [
createLabeledArg('endAbsolute', originCoords),
createLabeledArg(ARG_END_ABSOLUTE, originCoords),
]),
],
})

View File

@ -159,7 +159,7 @@ export class KCLTypeError extends KCLError {
}
}
export class KCLUnimplementedError extends KCLError {
export class KCLIoError extends KCLError {
constructor(
msg: string,
sourceRange: SourceRange,
@ -169,7 +169,7 @@ export class KCLUnimplementedError extends KCLError {
filenames: { [x: number]: ModulePath | undefined }
) {
super(
'unimplemented',
'io',
msg,
sourceRange,
operations,
@ -177,7 +177,7 @@ export class KCLUnimplementedError extends KCLError {
artifactGraph,
filenames
)
Object.setPrototypeOf(this, KCLUnimplementedError.prototype)
Object.setPrototypeOf(this, KCLIoError.prototype)
}
}

View File

@ -629,8 +629,8 @@ export const lineTo: SketchLineHelperKw = {
const { node: callExpression } = nodeMeta
const toArrExp = createArrayExpression([
createLiteral(roundOff(to[0] - from[0], 2)),
createLiteral(roundOff(to[1] - from[1], 2)),
createLiteral(roundOff(to[0], 2)),
createLiteral(roundOff(to[1], 2)),
])
mutateKwArg(ARG_END_ABSOLUTE, callExpression, toArrExp)
@ -2348,7 +2348,7 @@ export function changeSketchArguments(
if (fnName in sketchLineHelperMapKw) {
const isAbsolute =
callExpression.type === 'CallExpressionKw' &&
findKwArg('endAbsolute', callExpression) !== undefined
findKwArg(ARG_END_ABSOLUTE, callExpression) !== undefined
const correctFnName = fnName === 'line' && isAbsolute ? 'lineTo' : fnName
const { updateArgs } = sketchLineHelperMapKw[correctFnName]
if (!updateArgs) {
@ -2391,7 +2391,7 @@ export function getConstraintInfoKw(
const fnName = callExpression?.callee?.name || ''
const isAbsolute =
fnName === 'circleThreePoint' ||
findKwArg('endAbsolute', callExpression) !== undefined
findKwArg(ARG_END_ABSOLUTE, callExpression) !== undefined
if (!(fnName in sketchLineHelperMapKw)) return []
const correctFnName = fnName === 'line' && isAbsolute ? 'lineTo' : fnName
return sketchLineHelperMapKw[correctFnName].getConstraintInfo(

View File

@ -138,7 +138,7 @@ function createCallWrapper(
}
if (tooltip === 'lineTo') {
const labeledArgs = [
createLabeledArg('endAbsolute', createArrayExpression(val)),
createLabeledArg(ARG_END_ABSOLUTE, createArrayExpression(val)),
]
if (tag) {
labeledArgs.push(createLabeledArg(ARG_TAG, tag))

View File

@ -24,6 +24,7 @@ import {
isBinaryExpression,
isLiteralValueNumber,
} from 'lang/util'
import { ARG_END_ABSOLUTE } from 'lang/std/sketch'
/**
* It does not create the startSketchOn and it does not create the startProfileAt.
@ -70,7 +71,7 @@ export const getRectangleCallExpressions = (
]),
createCallExpressionStdLibKw('line', null, [
createLabeledArg(
'endAbsolute',
ARG_END_ABSOLUTE,
createArrayExpression([
createCallExpressionStdLib('profileStartX', [createPipeSubstitution()]),
createCallExpressionStdLib('profileStartY', [createPipeSubstitution()]),

View File

@ -730,7 +730,7 @@ dependencies = [
[[package]]
name = "derive-docs"
version = "0.1.40"
version = "0.1.44"
dependencies = [
"Inflector",
"anyhow",
@ -1724,7 +1724,7 @@ dependencies = [
[[package]]
name = "kcl-lib"
version = "0.2.41"
version = "0.2.44"
dependencies = [
"anyhow",
"approx 0.5.1",
@ -1791,7 +1791,7 @@ dependencies = [
[[package]]
name = "kcl-test-server"
version = "0.1.40"
version = "0.1.44"
dependencies = [
"anyhow",
"hyper 0.14.32",

View File

@ -1,7 +1,7 @@
[package]
name = "derive-docs"
description = "A tool for generating documentation from Rust derive macros"
version = "0.1.40"
version = "0.1.44"
edition = "2021"
license = "MIT"
repository = "https://github.com/KittyCAD/modeling-app"

View File

@ -1,7 +1,7 @@
[package]
name = "kcl-test-server"
description = "A test server for KCL"
version = "0.1.40"
version = "0.1.44"
edition = "2021"
license = "MIT"

View File

@ -1,7 +1,7 @@
[package]
name = "kcl-lib"
description = "KittyCAD Language implementation and tools"
version = "0.2.41"
version = "0.2.44"
edition = "2021"
license = "MIT"
repository = "https://github.com/KittyCAD/modeling-app"
@ -22,7 +22,7 @@ clap = { version = "4.5.27", default-features = false, optional = true, features
] }
convert_case = "0.6.0"
dashmap = "6.1.0"
derive-docs = { version = "0.1.40", path = "../derive-docs" }
derive-docs = { version = "0.1.44", path = "../derive-docs" }
dhat = { version = "0.3", optional = true }
fnv = "1.0.7"
form_urlencoded = "1.2.1"

View File

@ -87,8 +87,8 @@ pub enum KclError {
ImportCycle(KclErrorDetails),
#[error("type: {0:?}")]
Type(KclErrorDetails),
#[error("unimplemented: {0:?}")]
Unimplemented(KclErrorDetails),
#[error("i/o: {0:?}")]
Io(KclErrorDetails),
#[error("unexpected: {0:?}")]
Unexpected(KclErrorDetails),
#[error("value already defined: {0:?}")]
@ -268,7 +268,7 @@ impl miette::Diagnostic for ReportWithOutputs {
KclError::Semantic(_) => "Semantic",
KclError::ImportCycle(_) => "ImportCycle",
KclError::Type(_) => "Type",
KclError::Unimplemented(_) => "Unimplemented",
KclError::Io(_) => "I/O",
KclError::Unexpected(_) => "Unexpected",
KclError::ValueAlreadyDefined(_) => "ValueAlreadyDefined",
KclError::UndefinedValue(_) => "UndefinedValue",
@ -318,7 +318,7 @@ impl miette::Diagnostic for Report {
KclError::Semantic(_) => "Semantic",
KclError::ImportCycle(_) => "ImportCycle",
KclError::Type(_) => "Type",
KclError::Unimplemented(_) => "Unimplemented",
KclError::Io(_) => "I/O",
KclError::Unexpected(_) => "Unexpected",
KclError::ValueAlreadyDefined(_) => "ValueAlreadyDefined",
KclError::UndefinedValue(_) => "UndefinedValue",
@ -377,7 +377,7 @@ impl KclError {
KclError::Semantic(_) => "semantic",
KclError::ImportCycle(_) => "import cycle",
KclError::Type(_) => "type",
KclError::Unimplemented(_) => "unimplemented",
KclError::Io(_) => "i/o",
KclError::Unexpected(_) => "unexpected",
KclError::ValueAlreadyDefined(_) => "value already defined",
KclError::UndefinedValue(_) => "undefined value",
@ -394,7 +394,7 @@ impl KclError {
KclError::Semantic(e) => e.source_ranges.clone(),
KclError::ImportCycle(e) => e.source_ranges.clone(),
KclError::Type(e) => e.source_ranges.clone(),
KclError::Unimplemented(e) => e.source_ranges.clone(),
KclError::Io(e) => e.source_ranges.clone(),
KclError::Unexpected(e) => e.source_ranges.clone(),
KclError::ValueAlreadyDefined(e) => e.source_ranges.clone(),
KclError::UndefinedValue(e) => e.source_ranges.clone(),
@ -412,7 +412,7 @@ impl KclError {
KclError::Semantic(e) => &e.message,
KclError::ImportCycle(e) => &e.message,
KclError::Type(e) => &e.message,
KclError::Unimplemented(e) => &e.message,
KclError::Io(e) => &e.message,
KclError::Unexpected(e) => &e.message,
KclError::ValueAlreadyDefined(e) => &e.message,
KclError::UndefinedValue(e) => &e.message,
@ -430,7 +430,7 @@ impl KclError {
KclError::Semantic(e) => e.source_ranges = source_ranges,
KclError::ImportCycle(e) => e.source_ranges = source_ranges,
KclError::Type(e) => e.source_ranges = source_ranges,
KclError::Unimplemented(e) => e.source_ranges = source_ranges,
KclError::Io(e) => e.source_ranges = source_ranges,
KclError::Unexpected(e) => e.source_ranges = source_ranges,
KclError::ValueAlreadyDefined(e) => e.source_ranges = source_ranges,
KclError::UndefinedValue(e) => e.source_ranges = source_ranges,
@ -450,7 +450,7 @@ impl KclError {
KclError::Semantic(e) => e.source_ranges.extend(source_ranges),
KclError::ImportCycle(e) => e.source_ranges.extend(source_ranges),
KclError::Type(e) => e.source_ranges.extend(source_ranges),
KclError::Unimplemented(e) => e.source_ranges.extend(source_ranges),
KclError::Io(e) => e.source_ranges.extend(source_ranges),
KclError::Unexpected(e) => e.source_ranges.extend(source_ranges),
KclError::ValueAlreadyDefined(e) => e.source_ranges.extend(source_ranges),
KclError::UndefinedValue(e) => e.source_ranges.extend(source_ranges),

View File

@ -123,7 +123,11 @@ impl ExecutorContext {
};
std::mem::swap(&mut exec_state.mod_local, &mut local_state);
if !exec_kind.is_isolated() && new_units != old_units {
// We only need to reset the units if we are not on the Main path.
// If we reset at the end of the main path, then we just add on an extra
// command and we'd need to flush the batch again.
// This avoids that.
if !exec_kind.is_isolated() && new_units != old_units && *path != ModulePath::Main {
self.engine.set_units(old_units.into(), Default::default()).await?;
}
self.engine.replace_execution_kind(original_execution).await;

View File

@ -31,7 +31,7 @@ impl FileSystem for FileManager {
source_range: SourceRange,
) -> Result<Vec<u8>, KclError> {
tokio::fs::read(&path).await.map_err(|e| {
KclError::Engine(KclErrorDetails {
KclError::Io(KclErrorDetails {
message: format!("Failed to read file `{}`: {}", path.as_ref().display(), e),
source_ranges: vec![source_range],
})
@ -44,7 +44,7 @@ impl FileSystem for FileManager {
source_range: SourceRange,
) -> Result<String, KclError> {
tokio::fs::read_to_string(&path).await.map_err(|e| {
KclError::Engine(KclErrorDetails {
KclError::Io(KclErrorDetails {
message: format!("Failed to read file `{}`: {}", path.as_ref().display(), e),
source_ranges: vec![source_range],
})
@ -60,7 +60,7 @@ impl FileSystem for FileManager {
if e.kind() == std::io::ErrorKind::NotFound {
Ok(false)
} else {
Err(KclError::Engine(KclErrorDetails {
Err(KclError::Io(KclErrorDetails {
message: format!("Failed to check if file `{}` exists: {}", path.as_ref().display(), e),
source_ranges: vec![source_range],
}))
@ -82,7 +82,7 @@ impl FileSystem for FileManager {
}
let mut read_dir = tokio::fs::read_dir(&path).await.map_err(|e| {
KclError::Engine(KclErrorDetails {
KclError::Io(KclErrorDetails {
message: format!("Failed to read directory `{}`: {}", path.display(), e),
source_ranges: vec![source_range],
})

View File

@ -2074,3 +2074,25 @@ mod import_file_parse_error {
super::execute(TEST_NAME, true).await
}
}
mod flush_batch_on_end {
const TEST_NAME: &str = "flush_batch_on_end";
/// Test parsing KCL.
#[test]
fn parse() {
super::parse(TEST_NAME);
}
/// Test that parsing and unparsing KCL produces the original KCL input.
#[test]
fn unparse() {
super::unparse(TEST_NAME)
}
/// Test that KCL is executed correctly.
#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_execute() {
super::execute(TEST_NAME, true).await
}
}

View File

@ -1,7 +1,6 @@
---
source: kcl/src/simulation_tests.rs
description: Artifact commands cube_with_error.kcl
snapshot_kind: text
---
[
{

View File

@ -0,0 +1,655 @@
---
source: kcl/src/simulation_tests.rs
description: Artifact commands flush_batch_on_end.kcl
---
[
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "make_plane",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"x_axis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"y_axis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"size": 100.0,
"clobber": false,
"hide": true
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "plane_set_color",
"plane_id": "[uuid]",
"color": {
"r": 0.7,
"g": 0.28,
"b": 0.28,
"a": 0.4
}
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "make_plane",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"x_axis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"y_axis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"size": 100.0,
"clobber": false,
"hide": true
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "plane_set_color",
"plane_id": "[uuid]",
"color": {
"r": 0.28,
"g": 0.7,
"b": 0.28,
"a": 0.4
}
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "make_plane",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"x_axis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"y_axis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"size": 100.0,
"clobber": false,
"hide": true
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "plane_set_color",
"plane_id": "[uuid]",
"color": {
"r": 0.28,
"g": 0.28,
"b": 0.7,
"a": 0.4
}
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "make_plane",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"x_axis": {
"x": -1.0,
"y": 0.0,
"z": 0.0
},
"y_axis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"size": 100.0,
"clobber": false,
"hide": true
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "make_plane",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"x_axis": {
"x": 0.0,
"y": -1.0,
"z": 0.0
},
"y_axis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"size": 100.0,
"clobber": false,
"hide": true
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "make_plane",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"x_axis": {
"x": -1.0,
"y": 0.0,
"z": 0.0
},
"y_axis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"size": 100.0,
"clobber": false,
"hide": true
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "edge_lines_visible",
"hidden": false
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "set_scene_units",
"unit": "mm"
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "object_visible",
"object_id": "[uuid]",
"hidden": true
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "object_visible",
"object_id": "[uuid]",
"hidden": true
}
},
{
"cmdId": "[uuid]",
"range": [
0,
33,
0
],
"command": {
"type": "set_scene_units",
"unit": "in"
}
},
{
"cmdId": "[uuid]",
"range": [
199,
218,
0
],
"command": {
"type": "make_plane",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"x_axis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"y_axis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"size": 60.0,
"clobber": false,
"hide": true
}
},
{
"cmdId": "[uuid]",
"range": [
282,
365,
0
],
"command": {
"type": "enable_sketch_mode",
"entity_id": "[uuid]",
"ortho": false,
"animated": false,
"adjust_camera": false,
"planar_normal": {
"x": 0.0,
"y": 0.0,
"z": 1.0
}
}
},
{
"cmdId": "[uuid]",
"range": [
282,
365,
0
],
"command": {
"type": "start_path"
}
},
{
"cmdId": "[uuid]",
"range": [
282,
365,
0
],
"command": {
"type": "move_path_pen",
"path": "[uuid]",
"to": {
"x": 0.2734375,
"y": 0.0,
"z": 0.0
}
}
},
{
"cmdId": "[uuid]",
"range": [
282,
365,
0
],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "arc",
"center": {
"x": 0.0,
"y": 0.0
},
"radius": 0.2734375,
"start": {
"unit": "degrees",
"value": 0.0
},
"end": {
"unit": "degrees",
"value": 360.0
},
"relative": false
}
}
},
{
"cmdId": "[uuid]",
"range": [
282,
365,
0
],
"command": {
"type": "close_path",
"path_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [
428,
511,
0
],
"command": {
"type": "enable_sketch_mode",
"entity_id": "[uuid]",
"ortho": false,
"animated": false,
"adjust_camera": false,
"planar_normal": {
"x": 0.0,
"y": 0.0,
"z": 1.0
}
}
},
{
"cmdId": "[uuid]",
"range": [
428,
511,
0
],
"command": {
"type": "start_path"
}
},
{
"cmdId": "[uuid]",
"range": [
428,
511,
0
],
"command": {
"type": "move_path_pen",
"path": "[uuid]",
"to": {
"x": 0.182,
"y": 0.0,
"z": 0.0
}
}
},
{
"cmdId": "[uuid]",
"range": [
428,
511,
0
],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "arc",
"center": {
"x": 0.0,
"y": 0.0
},
"radius": 0.182,
"start": {
"unit": "degrees",
"value": 0.0
},
"end": {
"unit": "degrees",
"value": 360.0
},
"relative": false
}
}
},
{
"cmdId": "[uuid]",
"range": [
428,
511,
0
],
"command": {
"type": "close_path",
"path_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [
601,
622,
0
],
"command": {
"type": "solid2d_add_hole",
"object_id": "[uuid]",
"hole_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [
601,
622,
0
],
"command": {
"type": "object_visible",
"object_id": "[uuid]",
"hidden": true
}
},
{
"cmdId": "[uuid]",
"range": [
678,
715,
0
],
"command": {
"type": "enable_sketch_mode",
"entity_id": "[uuid]",
"ortho": false,
"animated": false,
"adjust_camera": false,
"planar_normal": {
"x": 0.0,
"y": 0.0,
"z": 1.0
}
}
},
{
"cmdId": "[uuid]",
"range": [
678,
715,
0
],
"command": {
"type": "extrude",
"target": "[uuid]",
"distance": 1.5,
"faces": null
}
},
{
"cmdId": "[uuid]",
"range": [
678,
715,
0
],
"command": {
"type": "sketch_mode_disable"
}
},
{
"cmdId": "[uuid]",
"range": [
678,
715,
0
],
"command": {
"type": "object_bring_to_front",
"object_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [
678,
715,
0
],
"command": {
"type": "solid3d_get_extrusion_face_info",
"object_id": "[uuid]",
"edge_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [
678,
715,
0
],
"command": {
"type": "solid3d_get_opposite_edge",
"object_id": "[uuid]",
"edge_id": "[uuid]",
"face_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [
678,
715,
0
],
"command": {
"type": "solid3d_get_next_adjacent_edge",
"object_id": "[uuid]",
"edge_id": "[uuid]",
"face_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [
678,
715,
0
],
"command": {
"type": "solid3d_get_opposite_edge",
"object_id": "[uuid]",
"edge_id": "[uuid]",
"face_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [
678,
715,
0
],
"command": {
"type": "solid3d_get_next_adjacent_edge",
"object_id": "[uuid]",
"edge_id": "[uuid]",
"face_id": "[uuid]"
}
}
]

View File

@ -0,0 +1,6 @@
---
source: kcl/src/simulation_tests.rs
description: Artifact graph flowchart flush_batch_on_end.kcl
extension: md
snapshot_kind: binary
---

View File

@ -0,0 +1,35 @@
```mermaid
flowchart LR
subgraph path2 [Path]
2["Path<br>[282, 365, 0]"]
3["Segment<br>[282, 365, 0]"]
4[Solid2d]
end
subgraph path5 [Path]
5["Path<br>[428, 511, 0]"]
6["Segment<br>[428, 511, 0]"]
7[Solid2d]
end
1["Plane<br>[199, 218, 0]"]
8["Sweep Extrusion<br>[678, 715, 0]"]
9[Wall]
10["Cap Start"]
11["Cap End"]
12["SweepEdge Opposite"]
13["SweepEdge Adjacent"]
1 --- 2
1 --- 5
2 --- 3
2 ---- 8
2 --- 4
3 --- 9
3 --- 12
3 --- 13
5 --- 6
5 --- 7
8 --- 9
8 --- 10
8 --- 11
8 --- 12
8 --- 13
```

View File

@ -0,0 +1,700 @@
---
source: kcl/src/simulation_tests.rs
description: Result of parsing flush_batch_on_end.kcl
---
{
"Ok": {
"body": [
{
"declaration": {
"end": 105,
"id": {
"end": 97,
"name": "innerDiameter",
"start": 84,
"type": "Identifier"
},
"init": {
"end": 105,
"raw": "0.364",
"start": 100,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.364,
"suffix": "None"
}
},
"start": 84,
"type": "VariableDeclarator"
},
"end": 105,
"kind": "const",
"start": 84,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declaration": {
"end": 129,
"id": {
"end": 119,
"name": "outerDiameter",
"start": 106,
"type": "Identifier"
},
"init": {
"end": 129,
"left": {
"end": 124,
"raw": "35",
"start": 122,
"type": "Literal",
"type": "Literal",
"value": {
"value": 35.0,
"suffix": "None"
}
},
"operator": "/",
"right": {
"end": 129,
"raw": "64",
"start": 127,
"type": "Literal",
"type": "Literal",
"value": {
"value": 64.0,
"suffix": "None"
}
},
"start": 122,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 106,
"type": "VariableDeclarator"
},
"end": 129,
"kind": "const",
"start": 106,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declaration": {
"end": 148,
"id": {
"end": 136,
"name": "length",
"start": 130,
"type": "Identifier"
},
"init": {
"end": 148,
"left": {
"end": 140,
"raw": "1",
"start": 139,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
"operator": "+",
"right": {
"end": 148,
"left": {
"end": 144,
"raw": "1",
"start": 143,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
"operator": "/",
"right": {
"end": 148,
"raw": "2",
"start": 147,
"type": "Literal",
"type": "Literal",
"value": {
"value": 2.0,
"suffix": "None"
}
},
"start": 143,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 139,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 130,
"type": "VariableDeclarator"
},
"end": 148,
"kind": "const",
"start": 130,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declaration": {
"end": 218,
"id": {
"end": 196,
"name": "sketch000",
"start": 187,
"type": "Identifier"
},
"init": {
"arguments": [
{
"end": 217,
"raw": "'XY'",
"start": 213,
"type": "Literal",
"type": "Literal",
"value": "XY"
}
],
"callee": {
"end": 212,
"name": "startSketchOn",
"start": 199,
"type": "Identifier"
},
"end": 218,
"start": 199,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 187,
"type": "VariableDeclarator"
},
"end": 218,
"kind": "const",
"start": 187,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declaration": {
"end": 365,
"id": {
"end": 279,
"name": "outerProfile",
"start": 267,
"type": "Identifier"
},
"init": {
"arguments": [
{
"end": 344,
"properties": [
{
"end": 312,
"key": {
"end": 299,
"name": "center",
"start": 293,
"type": "Identifier"
},
"start": 293,
"type": "ObjectProperty",
"value": {
"elements": [
{
"end": 306,
"raw": "0.0",
"start": 303,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"end": 311,
"raw": "0.0",
"start": 308,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
],
"end": 312,
"start": 302,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"end": 342,
"key": {
"end": 322,
"name": "radius",
"start": 316,
"type": "Identifier"
},
"start": 316,
"type": "ObjectProperty",
"value": {
"end": 342,
"left": {
"end": 338,
"name": "outerDiameter",
"start": 325,
"type": "Identifier",
"type": "Identifier"
},
"operator": "/",
"right": {
"end": 342,
"raw": "2",
"start": 341,
"type": "Literal",
"type": "Literal",
"value": {
"value": 2.0,
"suffix": "None"
}
},
"start": 325,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
}
],
"start": 289,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"end": 355,
"name": "sketch000",
"start": 346,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 364,
"start": 357,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "arc000"
}
],
"callee": {
"end": 288,
"name": "circle",
"start": 282,
"type": "Identifier"
},
"end": 365,
"start": 282,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 267,
"type": "VariableDeclarator"
},
"end": 365,
"kind": "const",
"start": 267,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declaration": {
"end": 511,
"id": {
"end": 425,
"name": "innerProfile",
"start": 413,
"type": "Identifier"
},
"init": {
"arguments": [
{
"end": 490,
"properties": [
{
"end": 458,
"key": {
"end": 445,
"name": "center",
"start": 439,
"type": "Identifier"
},
"start": 439,
"type": "ObjectProperty",
"value": {
"elements": [
{
"end": 452,
"raw": "0.0",
"start": 449,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"end": 457,
"raw": "0.0",
"start": 454,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
],
"end": 458,
"start": 448,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"end": 488,
"key": {
"end": 468,
"name": "radius",
"start": 462,
"type": "Identifier"
},
"start": 462,
"type": "ObjectProperty",
"value": {
"end": 488,
"left": {
"end": 484,
"name": "innerDiameter",
"start": 471,
"type": "Identifier",
"type": "Identifier"
},
"operator": "/",
"right": {
"end": 488,
"raw": "2",
"start": 487,
"type": "Literal",
"type": "Literal",
"value": {
"value": 2.0,
"suffix": "None"
}
},
"start": 471,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
}
],
"start": 435,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"end": 501,
"name": "sketch000",
"start": 492,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 510,
"start": 503,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "arc001"
}
],
"callee": {
"end": 434,
"name": "circle",
"start": 428,
"type": "Identifier"
},
"end": 511,
"start": 428,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 413,
"type": "VariableDeclarator"
},
"end": 511,
"kind": "const",
"start": 413,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declaration": {
"end": 670,
"id": {
"end": 580,
"name": "pipeProfile",
"start": 569,
"type": "Identifier"
},
"init": {
"body": [
{
"end": 595,
"name": "outerProfile",
"start": 583,
"type": "Identifier",
"type": "Identifier"
},
{
"arguments": [
{
"end": 618,
"name": "innerProfile",
"start": 606,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 621,
"start": 620,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 605,
"name": "hole",
"start": 601,
"type": "Identifier"
},
"end": 622,
"start": 601,
"type": "CallExpression",
"type": "CallExpression"
}
],
"end": 670,
"nonCodeMeta": {
"nonCodeNodes": {
"1": [
{
"end": 670,
"start": 622,
"type": "NonCodeNode",
"value": {
"type": "newLineBlockComment",
"value": "extrude the pipe profile to create the pipe",
"style": "line"
}
}
]
},
"startNodes": []
},
"start": 583,
"type": "PipeExpression",
"type": "PipeExpression"
},
"start": 569,
"type": "VariableDeclarator"
},
"end": 670,
"kind": "const",
"start": 569,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declaration": {
"end": 715,
"id": {
"end": 675,
"name": "pipe",
"start": 671,
"type": "Identifier"
},
"init": {
"arguments": [
{
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "length"
},
"arg": {
"end": 714,
"name": "length",
"start": 708,
"type": "Identifier",
"type": "Identifier"
}
}
],
"callee": {
"end": 685,
"name": "extrude",
"start": 678,
"type": "Identifier"
},
"end": 715,
"start": 678,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"end": 697,
"name": "pipeProfile",
"start": 686,
"type": "Identifier",
"type": "Identifier"
}
},
"start": 671,
"type": "VariableDeclarator"
},
"end": 715,
"kind": "const",
"start": 671,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"end": 716,
"innerAttrs": [
{
"end": 33,
"name": {
"end": 9,
"name": "settings",
"start": 1,
"type": "Identifier"
},
"properties": [
{
"end": 32,
"key": {
"end": 27,
"name": "defaultLengthUnit",
"start": 10,
"type": "Identifier"
},
"start": 10,
"type": "ObjectProperty",
"value": {
"end": 32,
"name": "in",
"start": 30,
"type": "Identifier",
"type": "Identifier"
}
}
],
"start": 0,
"type": "Annotation"
}
],
"nonCodeMeta": {
"nonCodeNodes": {
"2": [
{
"end": 186,
"start": 148,
"type": "NonCodeNode",
"value": {
"type": "newLineBlockComment",
"value": "create a sketch on the 'XY' plane",
"style": "line"
}
}
],
"3": [
{
"end": 266,
"start": 218,
"type": "NonCodeNode",
"value": {
"type": "newLineBlockComment",
"value": "create a profile of the outside of the pipe",
"style": "line"
}
}
],
"4": [
{
"end": 412,
"start": 365,
"type": "NonCodeNode",
"value": {
"type": "newLineBlockComment",
"value": "create a profile of the inside of the pipe",
"style": "line"
}
}
],
"5": [
{
"end": 568,
"start": 511,
"type": "NonCodeNode",
"value": {
"type": "newLineBlockComment",
"value": "create a profile with holes sketch000Profile000Holes",
"style": "line"
}
}
]
},
"startNodes": [
{
"end": 61,
"start": 34,
"type": "NonCodeNode",
"value": {
"type": "blockComment",
"value": "Set units in inches (in)",
"style": "line"
}
},
{
"end": 64,
"start": 61,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
},
{
"end": 83,
"start": 64,
"type": "NonCodeNode",
"value": {
"type": "blockComment",
"value": "Define constants",
"style": "line"
}
}
]
},
"start": 0
}
}

View File

@ -0,0 +1,30 @@
@settings(defaultLengthUnit = in)
// Set units in inches (in)
// Define constants
innerDiameter = 0.364
outerDiameter = 35 / 64
length = 1 + 1 / 2
// create a sketch on the 'XY' plane
sketch000 = startSketchOn('XY')
// create a profile of the outside of the pipe
outerProfile = circle({
center = [0.0, 0.0],
radius = outerDiameter / 2
}, sketch000, $arc000)
// create a profile of the inside of the pipe
innerProfile = circle({
center = [0.0, 0.0],
radius = innerDiameter / 2
}, sketch000, $arc001)
// create a profile with holes sketch000Profile000Holes
pipeProfile = outerProfile
|> hole(innerProfile, %)
// extrude the pipe profile to create the pipe
pipe = extrude(pipeProfile, length = length)

View File

@ -0,0 +1,105 @@
---
source: kcl/src/simulation_tests.rs
description: Operations executed flush_batch_on_end.kcl
---
[
{
"labeledArgs": {
"data": {
"value": {
"type": "String",
"value": "XY"
},
"sourceRange": [
213,
217,
0
]
}
},
"name": "startSketchOn",
"sourceRange": [
199,
218,
0
],
"type": "StdLibCall",
"unlabeledArg": null
},
{
"labeledArgs": {
"holeSketch": {
"value": {
"type": "Sketch",
"value": {
"artifactId": "[uuid]"
}
},
"sourceRange": [
606,
618,
0
]
},
"sketch": {
"value": {
"type": "Sketch",
"value": {
"artifactId": "[uuid]"
}
},
"sourceRange": [
620,
621,
0
]
}
},
"name": "hole",
"sourceRange": [
601,
622,
0
],
"type": "StdLibCall",
"unlabeledArg": null
},
{
"labeledArgs": {
"length": {
"value": {
"type": "Number",
"value": 1.5,
"ty": {
"type": "Unknown"
}
},
"sourceRange": [
708,
714,
0
]
}
},
"name": "extrude",
"sourceRange": [
678,
715,
0
],
"type": "StdLibCall",
"unlabeledArg": {
"value": {
"type": "Sketch",
"value": {
"artifactId": "[uuid]"
}
},
"sourceRange": [
686,
697,
0
]
}
}
]

View File

@ -0,0 +1,975 @@
---
source: kcl/src/simulation_tests.rs
description: Variables in memory after executing flush_batch_on_end.kcl
---
{
"arc000": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "arc000",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
282,
365,
0
]
},
"ccw": true,
"center": [
0.0,
0.0
],
"from": [
0.2734375,
0.0
],
"radius": 0.2734375,
"tag": {
"end": 364,
"start": 357,
"type": "TagDeclarator",
"value": "arc000"
},
"to": [
0.2734375,
0.0
],
"type": "Circle",
"units": {
"type": "Inches"
}
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
282,
365,
0
],
"tag": {
"end": 364,
"start": 357,
"type": "TagDeclarator",
"value": "arc000"
},
"type": "extrudeArc"
}
},
"__meta": [
{
"sourceRange": [
357,
364,
0
]
}
]
},
"arc001": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "arc001",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
428,
511,
0
]
},
"ccw": true,
"center": [
0.0,
0.0
],
"from": [
0.182,
0.0
],
"radius": 0.182,
"tag": {
"end": 510,
"start": 503,
"type": "TagDeclarator",
"value": "arc001"
},
"to": [
0.182,
0.0
],
"type": "Circle",
"units": {
"type": "Inches"
}
},
"surface": null
},
"__meta": [
{
"sourceRange": [
503,
510,
0
]
}
]
},
"innerDiameter": {
"type": "Number",
"value": 0.364,
"ty": {
"type": "Default",
"len": {
"type": "Inches"
},
"angle": {
"type": "Degrees"
}
},
"__meta": [
{
"sourceRange": [
100,
105,
0
]
}
]
},
"innerProfile": {
"type": "Sketch",
"value": {
"type": "Sketch",
"id": "[uuid]",
"paths": [
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
428,
511,
0
]
},
"ccw": true,
"center": [
0.0,
0.0
],
"from": [
0.182,
0.0
],
"radius": 0.182,
"tag": {
"end": 510,
"start": 503,
"type": "TagDeclarator",
"value": "arc001"
},
"to": [
0.182,
0.0
],
"type": "Circle",
"units": {
"type": "Inches"
}
}
],
"on": {
"type": "plane",
"id": "[uuid]",
"artifactId": "[uuid]",
"value": "XY",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"xAxis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"yAxis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"zAxis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"units": {
"type": "Inches"
},
"__meta": []
},
"start": {
"from": [
0.182,
0.0
],
"to": [
0.182,
0.0
],
"units": {
"type": "Inches"
},
"tag": null,
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
428,
511,
0
]
}
},
"tags": {
"arc001": {
"type": "TagIdentifier",
"value": "arc001",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
428,
511,
0
]
},
"ccw": true,
"center": [
0.0,
0.0
],
"from": [
0.182,
0.0
],
"radius": 0.182,
"tag": {
"end": 510,
"start": 503,
"type": "TagDeclarator",
"value": "arc001"
},
"to": [
0.182,
0.0
],
"type": "Circle",
"units": {
"type": "Inches"
}
},
"surface": null
},
"__meta": [
{
"sourceRange": [
503,
510,
0
]
}
]
}
},
"artifactId": "[uuid]",
"originalId": "[uuid]",
"units": {
"type": "Inches"
},
"__meta": [
{
"sourceRange": [
428,
511,
0
]
}
]
}
},
"length": {
"type": "Number",
"value": 1.5,
"ty": {
"type": "Unknown"
},
"__meta": [
{
"sourceRange": [
139,
140,
0
]
},
{
"sourceRange": [
143,
144,
0
]
},
{
"sourceRange": [
147,
148,
0
]
}
]
},
"outerDiameter": {
"type": "Number",
"value": 0.546875,
"ty": {
"type": "Unknown"
},
"__meta": [
{
"sourceRange": [
122,
124,
0
]
},
{
"sourceRange": [
127,
129,
0
]
}
]
},
"outerProfile": {
"type": "Sketch",
"value": {
"type": "Sketch",
"id": "[uuid]",
"paths": [
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
282,
365,
0
]
},
"ccw": true,
"center": [
0.0,
0.0
],
"from": [
0.2734,
0.0
],
"radius": 0.2734375,
"tag": {
"end": 364,
"start": 357,
"type": "TagDeclarator",
"value": "arc000"
},
"to": [
0.2734,
0.0
],
"type": "Circle",
"units": {
"type": "Inches"
}
}
],
"on": {
"type": "plane",
"id": "[uuid]",
"artifactId": "[uuid]",
"value": "XY",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"xAxis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"yAxis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"zAxis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"units": {
"type": "Inches"
},
"__meta": []
},
"start": {
"from": [
0.2734375,
0.0
],
"to": [
0.2734375,
0.0
],
"units": {
"type": "Inches"
},
"tag": null,
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
282,
365,
0
]
}
},
"tags": {
"arc000": {
"type": "TagIdentifier",
"value": "arc000",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
282,
365,
0
]
},
"ccw": true,
"center": [
0.0,
0.0
],
"from": [
0.2734375,
0.0
],
"radius": 0.2734375,
"tag": {
"end": 364,
"start": 357,
"type": "TagDeclarator",
"value": "arc000"
},
"to": [
0.2734375,
0.0
],
"type": "Circle",
"units": {
"type": "Inches"
}
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
282,
365,
0
],
"tag": {
"end": 364,
"start": 357,
"type": "TagDeclarator",
"value": "arc000"
},
"type": "extrudeArc"
}
},
"__meta": [
{
"sourceRange": [
357,
364,
0
]
}
]
}
},
"artifactId": "[uuid]",
"originalId": "[uuid]",
"units": {
"type": "Inches"
},
"__meta": [
{
"sourceRange": [
282,
365,
0
]
}
]
}
},
"pipe": {
"type": "Solid",
"value": {
"type": "Solid",
"id": "[uuid]",
"artifactId": "[uuid]",
"value": [
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
282,
365,
0
],
"tag": {
"end": 364,
"start": 357,
"type": "TagDeclarator",
"value": "arc000"
},
"type": "extrudeArc"
}
],
"sketch": {
"type": "Sketch",
"id": "[uuid]",
"paths": [
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
282,
365,
0
]
},
"ccw": true,
"center": [
0.0,
0.0
],
"from": [
0.2734,
0.0
],
"radius": 0.2734375,
"tag": {
"end": 364,
"start": 357,
"type": "TagDeclarator",
"value": "arc000"
},
"to": [
0.2734,
0.0
],
"type": "Circle",
"units": {
"type": "Inches"
}
}
],
"on": {
"type": "plane",
"id": "[uuid]",
"artifactId": "[uuid]",
"value": "XY",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"xAxis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"yAxis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"zAxis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"units": {
"type": "Inches"
},
"__meta": []
},
"start": {
"from": [
0.2734375,
0.0
],
"to": [
0.2734375,
0.0
],
"units": {
"type": "Inches"
},
"tag": null,
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
282,
365,
0
]
}
},
"tags": {
"arc000": {
"type": "TagIdentifier",
"value": "arc000",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
282,
365,
0
]
},
"ccw": true,
"center": [
0.0,
0.0
],
"from": [
0.2734375,
0.0
],
"radius": 0.2734375,
"tag": {
"end": 364,
"start": 357,
"type": "TagDeclarator",
"value": "arc000"
},
"to": [
0.2734375,
0.0
],
"type": "Circle",
"units": {
"type": "Inches"
}
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
282,
365,
0
],
"tag": {
"end": 364,
"start": 357,
"type": "TagDeclarator",
"value": "arc000"
},
"type": "extrudeArc"
}
},
"__meta": [
{
"sourceRange": [
357,
364,
0
]
}
]
}
},
"artifactId": "[uuid]",
"originalId": "[uuid]",
"units": {
"type": "Inches"
},
"__meta": [
{
"sourceRange": [
282,
365,
0
]
}
]
},
"height": 1.5,
"startCapId": "[uuid]",
"endCapId": "[uuid]",
"units": {
"type": "Inches"
},
"__meta": [
{
"sourceRange": [
282,
365,
0
]
}
]
}
},
"pipeProfile": {
"type": "Sketch",
"value": {
"type": "Sketch",
"id": "[uuid]",
"paths": [
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
282,
365,
0
]
},
"ccw": true,
"center": [
0.0,
0.0
],
"from": [
0.2734,
0.0
],
"radius": 0.2734375,
"tag": {
"end": 364,
"start": 357,
"type": "TagDeclarator",
"value": "arc000"
},
"to": [
0.2734,
0.0
],
"type": "Circle",
"units": {
"type": "Inches"
}
}
],
"on": {
"type": "plane",
"id": "[uuid]",
"artifactId": "[uuid]",
"value": "XY",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"xAxis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"yAxis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"zAxis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"units": {
"type": "Inches"
},
"__meta": []
},
"start": {
"from": [
0.2734375,
0.0
],
"to": [
0.2734375,
0.0
],
"units": {
"type": "Inches"
},
"tag": null,
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
282,
365,
0
]
}
},
"tags": {
"arc000": {
"type": "TagIdentifier",
"value": "arc000",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
282,
365,
0
]
},
"ccw": true,
"center": [
0.0,
0.0
],
"from": [
0.2734375,
0.0
],
"radius": 0.2734375,
"tag": {
"end": 364,
"start": 357,
"type": "TagDeclarator",
"value": "arc000"
},
"to": [
0.2734375,
0.0
],
"type": "Circle",
"units": {
"type": "Inches"
}
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
282,
365,
0
],
"tag": {
"end": 364,
"start": 357,
"type": "TagDeclarator",
"value": "arc000"
},
"type": "extrudeArc"
}
},
"__meta": [
{
"sourceRange": [
357,
364,
0
]
}
]
}
},
"artifactId": "[uuid]",
"originalId": "[uuid]",
"units": {
"type": "Inches"
},
"__meta": [
{
"sourceRange": [
282,
365,
0
]
}
]
}
},
"sketch000": {
"type": "Plane",
"value": {
"id": "[uuid]",
"artifactId": "[uuid]",
"value": "XY",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"xAxis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"yAxis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"zAxis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"units": {
"type": "Inches"
},
"__meta": []
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

View File

@ -2,9 +2,9 @@
source: kcl/src/simulation_tests.rs
description: Error from executing import_file_not_exist_error.kcl
---
KCL Engine error
KCL I/O error
× engine: Failed to read file `tests/import_file_not_exist_error/not-
× i/o: Failed to read file `tests/import_file_not_exist_error/not-
│ exist.kcl`: No such file or directory (os error 2)
╭────
1 │ import hotdog from "not-exist.kcl"

View File

@ -2024,3 +2024,55 @@ async fn kcl_test_error_no_auth_websocket() {
.to_string()
.contains("Please send the following object over this websocket"));
}
#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_ensure_nothing_left_in_batch_single_file() {
let code = r#"@settings(defaultLengthUnit = in)
// Set units in inches (in)
// Define constants
innerDiameter = 0.364
outerDiameter = 35 / 64
length = 1 + 1 / 2
// create a sketch on the 'XY' plane
sketch000 = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line(end = [0, innerDiameter / 2])
"#;
let ctx = kcl_lib::ExecutorContext::new_with_default_client(Default::default())
.await
.unwrap();
let mut exec_state = kcl_lib::ExecState::new(&ctx.settings);
let program = kcl_lib::Program::parse_no_errs(code).unwrap();
ctx.run_with_ui_outputs(&program, &mut exec_state).await.unwrap();
// Ensure nothing is left in the batch
assert!(ctx.engine.batch().read().await.is_empty());
assert!(ctx.engine.batch_end().read().await.is_empty());
}
#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_ensure_nothing_left_in_batch_multi_file() {
// Get the current working directory.
let current_dir = std::env::current_dir().unwrap();
// Get the code in the test directory we need.
let path = current_dir.join("kcl/tests/assembly_non_default_units/input.kcl");
let code = std::fs::read_to_string(&path).unwrap();
// Change the current working directory to the test directory.
std::env::set_current_dir(path.parent().unwrap()).unwrap();
let ctx = kcl_lib::ExecutorContext::new_with_default_client(Default::default())
.await
.unwrap();
let mut exec_state = kcl_lib::ExecState::new(&ctx.settings);
let program = kcl_lib::Program::parse_no_errs(&code).unwrap();
ctx.run_with_ui_outputs(&program, &mut exec_state).await.unwrap();
// Ensure nothing is left in the batch
assert!(ctx.engine.batch().read().await.is_empty());
assert!(ctx.engine.batch_end().read().await.is_empty());
}