Files
modeling-app/docs/kcl-std/intersect.md
Nick Cameron 1841e63021 Misc docs polishing (#6712)
* Fake modules for Rust std lib functions

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Include the missing @ in Rust std lib fns

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Move revolve and mirror2d to better modules

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Use docs from KCL mods for type summaries

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Use type docs to describe types from KCL std lib

Signed-off-by: Nick Cameron <nrc@ncameron.org>

---------

Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-05-06 16:09:59 +12:00

158 KiB

title, excerpt, layout
title excerpt layout
std::solid::intersect Intersect returns the shared volume between multiple solids, preserving only overlapping regions. manual

Intersect returns the shared volume between multiple solids, preserving only overlapping regions.

Intersect computes the geometric intersection of multiple solid bodies, returning a new solid representing the volume that is common to all input solids. This operation is useful for determining shared material regions, verifying fit, and analyzing overlapping geometries in assemblies.

intersect(
  @solids: [Solid],
  tolerance?: number,
): [Solid]

Arguments

Name Type Description Required
solids [Solid] The solids to intersect. Yes
tolerance number The tolerance to use for the intersection operation. No

Returns

[Solid]

Examples

// Intersect two cubes using the stdlib functions.


fn cube(center, size) {
  return startSketchOn(XY)
    |> startProfile(at = [center[0] - size, center[1] - size])
    |> line(endAbsolute = [center[0] + size, center[1] - size])
    |> line(endAbsolute = [center[0] + size, center[1] + size])
    |> line(endAbsolute = [center[0] - size, center[1] + size])
    |> close()
    |> extrude(length = 10)
}

part001 = cube(center = [0, 0], size = 10)
part002 = cube(center = [7, 3], size = 5)
  |> translate(z = 1)

intersectedPart = intersect([part001, part002])

Rendered example of std::solid::intersect 0

// Intersect two cubes using operators.
// NOTE: This will not work when using codemods through the UI.
// Codemods will generate the stdlib function call instead.


fn cube(center, size) {
  return startSketchOn(XY)
    |> startProfile(at = [center[0] - size, center[1] - size])
    |> line(endAbsolute = [center[0] + size, center[1] - size])
    |> line(endAbsolute = [center[0] + size, center[1] + size])
    |> line(endAbsolute = [center[0] - size, center[1] + size])
    |> close()
    |> extrude(length = 10)
}

part001 = cube(center = [0, 0], size = 10)
part002 = cube(center = [7, 3], size = 5)
  |> translate(z = 1)

// This is the equivalent of: intersect([part001, part002])
intersectedPart = part001 & part002

Rendered example of std::solid::intersect 1