Smith.Measure (Smith v0.4.0)

Copy Markdown View Source

Dimensions measured from evaluated geometry, with world-space anchors.

Measurements retain the source BREP revision, units, and the points used to locate them on a drawing. They do not drive the model or implement sketch constraints. Selectors must resolve to exactly one edge or face: an empty selection returns :empty_selection, multiple matches :ambiguous_selection. Use Smith.inspect_edges/2 and Smith.inspect_faces/2 to refine a selector.

Sources may be recipes, evaluated results, or native subshapes. Existing results have their revision checked. Native geometry errors propagate. See inspection and validation for reports and drawings.

Summary

Functions

Measures the angle between two straight edges, in degrees from 0 through 180.

Measures a selected circular edge's diameter in mm, including opposite radial anchors and its axis.

Measures distance between two geometry anchors.

Measures world-axis extent (:x, :y, or :z) from native bounds.

Measures a selected circular edge's radius in mm, retaining its center, radial point, and axis.

Types

anchor()

@type anchor() ::
  {:circle_center | :edge_start | :edge_end | :face_center,
   Smith.Selector.input()}

source()

@type source() :: Smith.Drawing.source() | OCEx.Shape.t()

t()

@opaque t()

Functions

angle(source, first, second)

@spec angle(source(), Smith.Selector.input(), Smith.Selector.input()) ::
  {:ok, t()} | {:error, term()}

Measures the angle between two straight edges, in degrees from 0 through 180.

Uses the edges' directed traversal vectors. Reversing one edge changes the angle to its supplement. Parallel edges are measurable but cannot produce a nondegenerate angular drawing annotation. The edges need not intersect; the annotation uses their directions at the first edge's starting point.

diameter(source, selector)

@spec diameter(source(), Smith.Selector.input()) :: {:ok, t()} | {:error, term()}

Measures a selected circular edge's diameter in mm, including opposite radial anchors and its axis.

distance(source, from, to, opts \\ [])

@spec distance(source(), anchor(), anchor(), keyword()) ::
  {:ok, t()} | {:error, term()}

Measures distance between two geometry anchors.

Anchors are {:circle_center, edge_selector}, {:edge_start, edge_selector}, {:edge_end, edge_selector}, or {:face_center, face_selector}. A face center is its area centroid and may not lie on a curved or concave face. Circle centers also work for circular arcs; they are not arc centroids.

axis: :aligned (default) measures Euclidean distance; :x, :y, or :z measures the absolute world-axis component. Unknown or duplicate options return :invalid_options. Unsupported anchor geometry returns :wrong_geometry_type. Arbitrary input coordinates are not measured features.

extent(source, axis)

@spec extent(source(), :x | :y | :z) :: {:ok, t()} | {:error, term()}

Measures world-axis extent (:x, :y, or :z) from native bounds.

Returns a linear measurement. Its anchors lie on the bounding envelope, not necessarily on a surface. Curved bounds are numerical; use a tolerance when checking them. Empty geometry returns :empty_shape.

radius(source, selector)

@spec radius(source(), Smith.Selector.input()) :: {:ok, t()} | {:error, term()}

Measures a selected circular edge's radius in mm, retaining its center, radial point, and axis.