Skip to content

Update: Contour

Contour editing — produce NEW contours from an existing one. A contour is an outer ProfileHandle plus zero or more inner profiles that punch holes in it. Every method here is an immutable derive-new operation: it takes an opaque ContourHandle (plus any extra inputs) and returns a fresh ContourHandle for the resulting contour. The input contour is never mutated — the original handle keeps referring to the unchanged contour. Read the resulting geometry back as plain values with the query namespace. Accessed via snaptrude.core.geom.update.contour.

Functions

offset(contour, distance)

Offset a contour inward/outward by a signed distance. Immutable — returns a NEW contour and leaves the input unchanged.

  • Parameters:
    • contour: ContourHandle — The contour to offset
    • distance: number — Signed offset distance (outward when positive, inward when negative)
  • Returns: ContourHandle — The offset contour as a NEW handle
ts
// Shrink a contour inward by 0.5 Snaptrude units
const inset = await snaptrude.core.geom.update.contour.offset(contour, -0.5);

move(contour, translation)

Translate a contour by a vector. Immutable — returns a NEW contour and leaves the input unchanged.

  • Parameters:
    • contour: ContourHandle — The contour to move
    • translation: Vec3Handle — Translation vector to move the contour by
  • Returns: ContourHandle — The moved contour as a NEW handle
ts
const translation = await snaptrude.core.math.vec3.new(2, 0, 0);
const moved = await snaptrude.core.geom.update.contour.move(contour, translation);

rotate(contour, axis, angle, pivot?)

Rotate a contour about an axis through an optional pivot. Immutable — returns a NEW contour and leaves the input unchanged.

  • Parameters:
    • contour: ContourHandle — The contour to rotate
    • axis: Vec3Handle — Rotation axis direction
    • angle: number — Rotation angle in radians
    • pivot: Vec3Handle (optional) — Pivot point to rotate about (defaults to the origin)
  • Returns: ContourHandle — The rotated contour as a NEW handle

scale(contour, factor, pivot?)

Scale a contour uniformly or per-axis about an optional pivot. Immutable — returns a NEW contour and leaves the input unchanged.

  • Parameters:
    • contour: ContourHandle — The contour to scale
    • factor: number | Vec3Components — Uniform scale factor, or per-axis factors { x, y, z }
    • pivot: Vec3Handle (optional) — Pivot point to scale about (defaults to the origin)
  • Returns: ContourHandle — The scaled contour as a NEW handle

mirror(contour, plane)

Mirror a contour across a plane. Immutable — returns a NEW contour and leaves the input unchanged.

  • Parameters:
    • contour: ContourHandle — The contour to mirror
    • plane: { point: Vec3Handle, normal: Vec3Handle } — Mirror plane defined by a point on it and its normal
  • Returns: ContourHandle — The mirrored contour as a NEW handle

addHole(contour, hole)

Add a hole to a contour by appending an inner profile. Immutable — returns a NEW contour and leaves the input unchanged.

  • Parameters:
    • contour: ContourHandle — The contour to add a hole to
    • hole: ProfileHandle — The inner profile to add as a hole
  • Returns: ContourHandle — The contour with the added hole as a NEW handle
ts
const withHole = await snaptrude.core.geom.update.contour.addHole(contour, innerProfile);

removeHole(contour, index)

Remove a hole from a contour by inner-profile index. Immutable — returns a NEW contour and leaves the input unchanged.

  • Parameters:
    • contour: ContourHandle — The contour to remove a hole from
    • index: number — Zero-based index of the inner profile (hole) to remove
  • Returns: ContourHandle — The contour with the hole removed as a NEW handle

Errors

Failed calls reject with a typed PluginError — see Error Handling. Conditions specific to this namespace:

CodeThrown byWhendetails
OPERATION_FAILEDoffsetThe engine could not offset — a profile is open, or the outer profile or a hole collapses/self-intersects at that distancehandles; the message carries the engine reason
PRECONDITION_FAILEDremoveHoleindex is out of range for the contour's holeshandles, index, holeCount
HANDLE_INVALIDall methodsThe contour, profile, or point handle cannot be resolved