add loft example (#3810)
* add loft example Signed-off-by: Jess Frazelle <github@jessfraz.com> * add docs in between Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
File diff suppressed because one or more lines are too long
@ -147713,7 +147713,8 @@
|
|||||||
"deprecated": false,
|
"deprecated": false,
|
||||||
"examples": [
|
"examples": [
|
||||||
"// Loft a square and a triangle.\nconst squareSketch = startSketchOn('XY')\n |> startProfileAt([-100, 200], %)\n |> line([200, 0], %)\n |> line([0, -200], %)\n |> line([-200, 0], %)\n |> lineTo([profileStartX(%), profileStartY(%)], %)\n |> close(%)\n\nconst triangleSketch = startSketchOn(offsetPlane('XY', 75))\n |> startProfileAt([0, 125], %)\n |> line([-15, -30], %)\n |> line([30, 0], %)\n |> lineTo([profileStartX(%), profileStartY(%)], %)\n |> close(%)\n\nloft([squareSketch, triangleSketch])",
|
"// Loft a square and a triangle.\nconst squareSketch = startSketchOn('XY')\n |> startProfileAt([-100, 200], %)\n |> line([200, 0], %)\n |> line([0, -200], %)\n |> line([-200, 0], %)\n |> lineTo([profileStartX(%), profileStartY(%)], %)\n |> close(%)\n\nconst triangleSketch = startSketchOn(offsetPlane('XY', 75))\n |> startProfileAt([0, 125], %)\n |> line([-15, -30], %)\n |> line([30, 0], %)\n |> lineTo([profileStartX(%), profileStartY(%)], %)\n |> close(%)\n\nloft([squareSketch, triangleSketch])",
|
||||||
"// Loft a square, a circle, and another circle.\nconst squareSketch = startSketchOn('XY')\n |> startProfileAt([-100, 200], %)\n |> line([200, 0], %)\n |> line([0, -200], %)\n |> line([-200, 0], %)\n |> lineTo([profileStartX(%), profileStartY(%)], %)\n |> close(%)\n\nconst circleSketch0 = startSketchOn(offsetPlane('XY', 75))\n |> circle([0, 100], 50, %)\n\nconst circleSketch1 = startSketchOn(offsetPlane('XY', 150))\n |> circle([0, 100], 20, %)\n\nloft([\n squareSketch,\n circleSketch0,\n circleSketch1\n])"
|
"// Loft a square, a circle, and another circle.\nconst squareSketch = startSketchOn('XY')\n |> startProfileAt([-100, 200], %)\n |> line([200, 0], %)\n |> line([0, -200], %)\n |> line([-200, 0], %)\n |> lineTo([profileStartX(%), profileStartY(%)], %)\n |> close(%)\n\nconst circleSketch0 = startSketchOn(offsetPlane('XY', 75))\n |> circle([0, 100], 50, %)\n\nconst circleSketch1 = startSketchOn(offsetPlane('XY', 150))\n |> circle([0, 100], 20, %)\n\nloft([\n squareSketch,\n circleSketch0,\n circleSketch1\n])",
|
||||||
|
"// Loft a square, a circle, and another circle with options.\nconst squareSketch = startSketchOn('XY')\n |> startProfileAt([-100, 200], %)\n |> line([200, 0], %)\n |> line([0, -200], %)\n |> line([-200, 0], %)\n |> lineTo([profileStartX(%), profileStartY(%)], %)\n |> close(%)\n\nconst circleSketch0 = startSketchOn(offsetPlane('XY', 75))\n |> circle([0, 100], 50, %)\n\nconst circleSketch1 = startSketchOn(offsetPlane('XY', 150))\n |> circle([0, 100], 20, %)\n\nloft([\n squareSketch,\n circleSketch0,\n circleSketch1\n], {\n // This can be set to override the automatically determined\n // topological base curve, which is usually the first section encountered.\n baseCurveIndex: 0,\n // Attempt to approximate rational curves (such as arcs) using a bezier.\n // This will remove banding around interpolations between arcs and non-arcs.\n // It may produce errors in other scenarios Over time, this field won't be necessary.\n bezApproximateRational: false,\n // Tolerance for the loft operation.\n tolerance: 0.000001,\n // Degree of the interpolation. Must be greater than zero.\n // For example, use 2 for quadratic, or 3 for cubic interpolation in\n // the V direction. This defaults to 2, if not specified.\n vDegree: 2\n})"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -98,6 +98,39 @@ pub async fn loft(args: Args) -> Result<KclValue, KclError> {
|
|||||||
///
|
///
|
||||||
/// loft([squareSketch, circleSketch0, circleSketch1])
|
/// loft([squareSketch, circleSketch0, circleSketch1])
|
||||||
/// ```
|
/// ```
|
||||||
|
///
|
||||||
|
/// ```no_run
|
||||||
|
/// // Loft a square, a circle, and another circle with options.
|
||||||
|
/// const squareSketch = startSketchOn('XY')
|
||||||
|
/// |> startProfileAt([-100, 200], %)
|
||||||
|
/// |> line([200, 0], %)
|
||||||
|
/// |> line([0, -200], %)
|
||||||
|
/// |> line([-200, 0], %)
|
||||||
|
/// |> lineTo([profileStartX(%), profileStartY(%)], %)
|
||||||
|
/// |> close(%)
|
||||||
|
///
|
||||||
|
/// const circleSketch0 = startSketchOn(offsetPlane('XY', 75))
|
||||||
|
/// |> circle([0, 100], 50, %)
|
||||||
|
///
|
||||||
|
/// const circleSketch1 = startSketchOn(offsetPlane('XY', 150))
|
||||||
|
/// |> circle([0, 100], 20, %)
|
||||||
|
///
|
||||||
|
/// loft([squareSketch, circleSketch0, circleSketch1], {
|
||||||
|
/// // This can be set to override the automatically determined
|
||||||
|
/// // topological base curve, which is usually the first section encountered.
|
||||||
|
/// baseCurveIndex: 0,
|
||||||
|
/// // Attempt to approximate rational curves (such as arcs) using a bezier.
|
||||||
|
/// // This will remove banding around interpolations between arcs and non-arcs.
|
||||||
|
/// // It may produce errors in other scenarios Over time, this field won't be necessary.
|
||||||
|
/// bezApproximateRational: false,
|
||||||
|
/// // Tolerance for the loft operation.
|
||||||
|
/// tolerance: 0.000001,
|
||||||
|
/// // Degree of the interpolation. Must be greater than zero.
|
||||||
|
/// // For example, use 2 for quadratic, or 3 for cubic interpolation in
|
||||||
|
/// // the V direction. This defaults to 2, if not specified.
|
||||||
|
/// vDegree: 2,
|
||||||
|
/// })
|
||||||
|
/// ```
|
||||||
#[stdlib {
|
#[stdlib {
|
||||||
name = "loft",
|
name = "loft",
|
||||||
}]
|
}]
|
||||||
|
|||||||
BIN
src/wasm-lib/kcl/tests/outputs/serial_test_example_loft2.png
Normal file
BIN
src/wasm-lib/kcl/tests/outputs/serial_test_example_loft2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 126 KiB |
Reference in New Issue
Block a user