Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

__builtin

Sub-modules

Built-in functions

import

__builtin::import function to import data from files.

type_of

to_string

print

array

Built-in functions

len

Return the number of elements in an array.

count

Return the count of elements in an array or string.

Note: This symbol might be deprecated in the future.

first

Return the first element in an array or string.

last

Return everything but the first element in an array or string.

Return the first element in an array or string.

Note this function is supposed to be deprecated in the future.

tail

Return everything but the first element in an array or string.

rev

Return reversed version of this array.

sorted

Return a sorted version of this array

is_ascending

Check if all items are sorted in ascending order.

is_descending

Check if all items are sorted in descending order.

contains

Check if an array contains an element.

color

Built-in functions

rgb

Create a color from red, green and blue.

rgba

Create a color from red, green, blue and alpha.

debug

Built-in functions

assert

Assertion with an optional message.

assert_eq

Assert equal.

is_valid

Check if a qualified name is a valid symbol.

assert_valid

Assert if the name string is a valid symbol.

assert_invalid

Assert if the name string is an invalid symbol.

geo2d

Built-in 2D primitives

Circle

A circle at origin.

Arguments

  • radius: Length: Circle radius.

InvoluteGearProfile

A parametric involute spur gear profile.

This type defines the geometric parameters for generating a 2D involute gear shape.

See also

References

Arguments

  • module: Length: Gear module (mm per tooth), controlling the overall gear size. Defines the ratio between the pitch diameter and the number of teeth: pitch_diameter = module * teeth.
  • teeth: Integer: Total number of teeth on the gear. Must be a positive integer.
  • pressure_angle: Angle: Pressure angle (radians or degrees), defining the shape of the involute flank. The standard pressure angle of the gear, typically 20° or 25°, which determines the shape of the involute profile and the base circle radius.

Line

Built-in line primitive.

Arguments

  • x0: Scalar:
  • y0: Scalar:
  • x1: Scalar:
  • y1: Scalar:

Ngon

Ngon primitive with radius.

Arguments

  • n: Integer: Number of sides.
  • radius: Length: Radius.

Sector

Circle sector geometry (a pie shape) with start and end angle.

Arguments

  • radius: Length: Radius of the circle.
  • start: Angle: Start angle.
  • end: Angle: End angle.

Rect

A rectangle.

Arguments

  • x: Length: X position (left side) of the rectangle.
  • y: Length: Y position (bottom side) of the rectangle.
  • width: Length: Width of the rectangle.
  • height: Length: Height of the rectangle.

RoundedRect

A rounded rectangle with a radius for each corner.

Arguments

  • x: Length:
  • y: Length:
  • width: Length:
  • height: Length:
  • radius_bottom_left: Length:
  • radius_bottom_right: Length:
  • radius_top_left: Length:
  • radius_top_right: Length:

SinusoidalGearProfile

A parametric sinusoidal spur gear profile.

Arguments

  • module: Length: Module (amplitude), teeth size.
  • teeth: Integer: Number of teeth.
  • roundness: Scalar: Tooth roundness parameter (0.0..1.0).
  • stretch: Scalar: Stretch factor (0.0..1.0)

Text

ThreadProfile

ISO metric thread profile (one period).

Arguments

  • p: Scalar: Pitch (distance between two threads).

geo3d

Built-in 3D primitives

  • Sphere: The builtin sphere primitive, defined by its radius.

Sphere

The builtin sphere primitive, defined by its radius.

Arguments

  • radius: Length: Radius of the sphere in millimeters.

lab

Built-in 2D primitives

BezierPolygon

log

Built-in functions

error

Log error.

warning

Log warning.

info

Log info message.

todo

Log todo message. Will throw an error when reached.

math

Built-in functions

abs

Absolute value abs(x)

sqrt

Calculate the square root sqrt(x).

int

Cast some Quantity into an Integer.

cos

Calculate cos(x).

sin

Calculate sin(x).

tan

Calculate tan(x).

acos

Calculate acos(x).

asin

Calculate asin(x).

atan

Calculate atan(x).

rotate_around_axis

rotate_xyz

Rotate around X, Y, Z (in that order).

rotate_zyx

Rotate around Z, Y, X (in that order).

ops

Built-in operations

Built-in transformations

union

subtract

intersect

multiply

align

Arguments

  • x: Scalar: x Direction.
  • y: Scalar: y Direction.
  • z: Scalar: z Direction.
  • spacing: Length: Spacing.

buffer

Transform a geometry whose boundary is offset the specified distance from the input.

Only implemented for 2D geometries at the moment.

Arguments

  • distance: Length: Specified distance in mm.

center

distribute_grid

Distribute a 2D or 3D geometry on a grid on the Z plane.

Arguments

  • x: Length: X offset of the grid.
  • y: Length: X offset of the grid.
  • width: Length: Overall width of the grid.
  • height: Length: Overall height of the grid.
  • rows: Integer: Number of rows in the grid.
  • columns: Integer: Number of columns in the grid.

hull

extrude

Linear extrude operation.

Arguments

  • height: Length: Extrusion height in mm (in Z direction).
  • scale_x: Scalar: Scale in X direction.
  • scale_y: Scalar: Scale in Y direction.
  • twist: Angle: Twist angle in °0 direction.

mirror

Mirror along a line (2D) or a plane (3D).

Arguments

  • x: Length:
  • y: Length:
  • z: Length:
  • nx: Scalar:
  • ny: Scalar:
  • nz: Scalar:

orient

reflect

Reflect along a line (2D) or a plane (3D).

Arguments

  • x: Length: X position of the reflection point.
  • y: Length: Y position of the reflection point.
  • z: Length: Z position of the reflection point.
  • nx: Scalar: X direction of the reflection plane.
  • ny: Scalar: Y direction of the reflection plane.
  • nz: Scalar: Z direction of the reflection plane.

revolve

Arguments

  • angle: Angle:

rotate

scale

spiralize

Arguments

  • height: Length:
  • inner_radius: Length:
  • outer_radius: Length:
  • angle: Angle:

translate

string

Built-in functions

len

Return the length a string.

count

Return the count of characters in a string.