doc: Add more docs and links for KCL import (#4488)
* Add links in docs to KCL module documentation * Add import statement test in import() stdlib doc comments * Update doc test outputs * Update doc outputs
This commit is contained in:
File diff suppressed because one or more lines are too long
@ -7,6 +7,7 @@ layout: manual
|
|||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
* [Types](kcl/types)
|
* [Types](kcl/types)
|
||||||
|
* [Modules](kcl/modules)
|
||||||
* [Known Issues](kcl/KNOWN-ISSUES)
|
* [Known Issues](kcl/KNOWN-ISSUES)
|
||||||
* [`abs`](kcl/abs)
|
* [`abs`](kcl/abs)
|
||||||
* [`acos`](kcl/acos)
|
* [`acos`](kcl/acos)
|
||||||
|
@ -74007,7 +74007,7 @@
|
|||||||
{
|
{
|
||||||
"name": "import",
|
"name": "import",
|
||||||
"summary": "Import a CAD file.",
|
"summary": "Import a CAD file.",
|
||||||
"description": "For formats lacking unit data (such as STL, OBJ, or PLY files), the default unit of measurement is millimeters. Alternatively you may specify the unit by passing your desired measurement unit in the options parameter. When importing a GLTF file, the bin file will be imported as well. Import paths are relative to the current project directory.\n\nNote: The import command currently only works when using the native Modeling App.",
|
"description": "For formats lacking unit data (such as STL, OBJ, or PLY files), the default unit of measurement is millimeters. Alternatively you may specify the unit by passing your desired measurement unit in the options parameter. When importing a GLTF file, the bin file will be imported as well. Import paths are relative to the current project directory.\n\nNote: The import command currently only works when using the native Modeling App.\n\nFor importing KCL functions using the `import` statement, see the docs on [KCL modules](/docs/kcl/modules).",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"args": [
|
"args": [
|
||||||
{
|
{
|
||||||
@ -74411,7 +74411,8 @@
|
|||||||
"model = import(\"tests/inputs/cube.obj\", { type: \"obj\", units: \"m\" })",
|
"model = import(\"tests/inputs/cube.obj\", { type: \"obj\", units: \"m\" })",
|
||||||
"model = import(\"tests/inputs/cube.gltf\")",
|
"model = import(\"tests/inputs/cube.gltf\")",
|
||||||
"model = import(\"tests/inputs/cube.sldprt\")",
|
"model = import(\"tests/inputs/cube.sldprt\")",
|
||||||
"model = import(\"tests/inputs/cube.step\")"
|
"model = import(\"tests/inputs/cube.step\")",
|
||||||
|
"import height, buildSketch from 'common.kcl'\n\nplane = 'XZ'\nmargin = 2\ns1 = buildSketch(plane, [0, 0])\ns2 = buildSketch(plane, [0, height() + margin])"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
20
src/wasm-lib/kcl/common.kcl
Normal file
20
src/wasm-lib/kcl/common.kcl
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// This file is used by the import docs.
|
||||||
|
|
||||||
|
export fn width = () => {
|
||||||
|
return 10
|
||||||
|
}
|
||||||
|
|
||||||
|
export fn height = () => {
|
||||||
|
return 10
|
||||||
|
}
|
||||||
|
|
||||||
|
export fn buildSketch = (plane, offset) => {
|
||||||
|
w = width()
|
||||||
|
h = height()
|
||||||
|
return startSketchOn(plane)
|
||||||
|
|> startProfileAt(offset, %)
|
||||||
|
|> line([w, 0], %)
|
||||||
|
|> line([0, h], %)
|
||||||
|
|> line([-w, 0], %)
|
||||||
|
|> close(%)
|
||||||
|
}
|
@ -7,6 +7,7 @@ layout: manual
|
|||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
* [Types](kcl/types)
|
* [Types](kcl/types)
|
||||||
|
* [Modules](kcl/modules)
|
||||||
* [Known Issues](kcl/KNOWN-ISSUES)
|
* [Known Issues](kcl/KNOWN-ISSUES)
|
||||||
{{#each functions}}
|
{{#each functions}}
|
||||||
* [`{{name}}`](kcl/{{name}})
|
* [`{{name}}`](kcl/{{name}})
|
||||||
|
@ -144,6 +144,9 @@ pub async fn import(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
|||||||
/// Note: The import command currently only works when using the native
|
/// Note: The import command currently only works when using the native
|
||||||
/// Modeling App.
|
/// Modeling App.
|
||||||
///
|
///
|
||||||
|
/// For importing KCL functions using the `import` statement, see the docs on
|
||||||
|
/// [KCL modules](/docs/kcl/modules).
|
||||||
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// const model = import("tests/inputs/cube.obj")
|
/// const model = import("tests/inputs/cube.obj")
|
||||||
/// ```
|
/// ```
|
||||||
@ -163,6 +166,15 @@ pub async fn import(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
|||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// const model = import("tests/inputs/cube.step")
|
/// const model = import("tests/inputs/cube.step")
|
||||||
/// ```
|
/// ```
|
||||||
|
///
|
||||||
|
/// ```no_run
|
||||||
|
/// import height, buildSketch from 'common.kcl'
|
||||||
|
///
|
||||||
|
/// plane = 'XZ'
|
||||||
|
/// margin = 2
|
||||||
|
/// s1 = buildSketch(plane, [0, 0])
|
||||||
|
/// s2 = buildSketch(plane, [0, height() + margin])
|
||||||
|
/// ```
|
||||||
#[stdlib {
|
#[stdlib {
|
||||||
name = "import",
|
name = "import",
|
||||||
tags = [],
|
tags = [],
|
||||||
|
BIN
src/wasm-lib/kcl/tests/outputs/serial_test_example_import5.png
Normal file
BIN
src/wasm-lib/kcl/tests/outputs/serial_test_example_import5.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
Reference in New Issue
Block a user