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

Sub-modules

Aliases

  • math => __builtin::math
  • print => __builtin::print
  • type_of => __builtin::type_of
  • import => __builtin::import
  • debug => __builtin::debug
  • log => __builtin::log
  • color => __builtin::color
  • to_string => __builtin::to_string
  • array => __builtin::array
  • string => __builtin::string

geo2d

Sketches

Circle

Circle definition with an offset.

Examples:

  • With radius r: Circle(r = 10.0mm);
  • With diameter d: Circle(d = 5.0mm);

Parameters

  • radius: Length
  • center = (x = 0mm, y = 0mm)

init(diameter: Length, center = (x = 0mm, y = 0mm))

Frame

A frame with a thickness.

Parameters

  • width: Length
  • height: Length
  • thickness: Length

Hexagon

A regular hexagon.

Parameters

  • radius: Length

InvoluteGearProfile

Parameters

  • module: Length
  • teeth: Integer
  • pressure_angle = 0°

Line

Parameters

  • p0: Vec2
  • p1: Vec2

init(width: Length, y = 0mm)

init(height: Length, x = 0mm)

init(width: Length, p: (x: Length, y: Length))

Ngon

A regular convex polygon with n corners.

Parameters

  • n: Integer
  • radius: Length

Rect

Rectangle definition.

Examples

  • Centered rect with width and height: Rect(width = 10.0mm, height = 5.0mm);

Parameters

  • width: Length
  • height: Length
  • x: Length
  • y: Length

init(width: Length, height: Length)

init(size: Length)

Ring

Parameters

  • outer_radius: Length
  • inner_radius: Length

init(outer_radius: Length, thickness: Length)

init(outer_diameter: Length, inner_diameter: Length)

init(outer_diameter: Length, thickness: Length)

RoundedRect

A rounded rectangle.

Examples

  • Centered rect with width and height: RoundedRect(width = 10.0mm, height = 5.0mm);

Parameters

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

init(width: Length, height: Length, radius: Length)

init(size: Length, radius: Length)

Sector

Circle sector definition.

Parameters

  • radius: Length
  • start: Angle
  • end: Angle

init(radius: Length, angle: Angle, offset = 0°)

SinusoidalGearProfile

Parameters

  • module: Length
  • teeth: Integer
  • roundness = 0.5
  • stretch = 0.5

Text

Text definition.

Parameters

  • height: Length
  • text: String
  • font_file = ""

geo3d

Parts

Sphere

Sphere definition

Examples:

  • with radius r: Sphere(r = 10.0mm);

Parameters

  • radius: Length

init(diameter: Length)

Cube

Cube definition

Examples:

  • with size s: Cube(s = 10.0mm);
  • with size x, y, and z: Cube(size_x = 10.0mm, size_y = 5.0mm, size_z = 3.0mm);

Parameters

  • size_x: Length
  • size_y: Length
  • size_z: Length

init(size: Length)

Cylinder

Cylinder definition.

Examples:

  • with radius r and height h: Cylinder(r = 10.0mm, h = 5.0mm)

Parameters

  • radius_bottom: Length
  • radius_top: Length
  • height: Length
  • offset: Length = 0mm

init(radius: Length, height: Length)

Initialize by radius and height. Cylinder will be centered.

init(radius: Length, height: Length, offset: Length)

Initialize by radius, height and offset.

init(radius: Length, bottom: Length, top: Length)

Initialize by radius, bottom and top.

init(diameter: Length, height: Length)

Initialize by diameter and height. Cylinder will be centered.

Torus

A torus.

Examples:

  • Torus(major_radius = 45.0mm, minor_radius = 5.0mm)

Parameters

  • major_radius: Length
  • minor_radius: Length

ops

Operations

  • align: Align a geometry collection along an axis with a certain spacing.
  • buffer: Create a new geometry whose boundary is offset the specified distance from the input.
  • contour: Generate a contour geometry out of an input geometry.
  • distribute_grid: Distribute geometries within a 2D rectangular grid.
  • extrude: Linear extrude a 2D geometry into a 3D.
  • mirror: Mirror along an axis, keeping existing geometry.
  • orient: Orient an object towards a vector.
  • reflect: Reflect a geometry along an axis.
  • revolve: Revolve a geometry around 360°.
  • rotate: An operation that rotates a part.
  • scale: An operation that scales a part.
  • spiralize: Create a spiral with a height and an inner and outer radius.
  • translate: An operation that translates (moves) a geometry.

Aliases

  • center => __builtin::ops::center
  • hull => __builtin::ops::hull
  • intersect => __builtin::ops::intersect
  • subtract => __builtin::ops::subtract
  • multiply => __builtin::ops::multiply
  • union => __builtin::ops::union

align

Align a geometry collection along an axis with a certain spacing.

Parameters

  • direction: Vec3
  • spacing = 0mm

buffer

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

Parameters

  • distance: Length

contour

Generate a contour geometry out of an input geometry.

Parameters

  • thickness: Length
  • distance = 0mm

distribute_grid

Distribute geometries within a 2D rectangular grid.

The distribute_grid operator arranges elements evenly inside a rectangular region, subdivided into a specified number of rows and columns. Each grid cell receives one element, allowing for structured placement of objects, points, or geometries.

The grid is defined by its position (x, y), total dimensions (width, height), and subdivision counts (rows, columns).

Parameters

  • x: Length
  • y: Length
  • width: Length
  • height: Length
  • rows: Integer
  • columns: Integer

init(width: Length, height: Length, rows: Integer, columns: Integer)

Initialize a centered rectangular grid.

init(size: Length, rows: Integer, columns: Integer)

Initialize a centered square grid.

The init helper simplifies grid creation by specifying a single size value instead of separate width and height. It automatically centers the grid around the origin and defines its overall dimensions.

init(cell_size: Length, rows: Integer, columns: Integer)

Initialize a centered grid with a squared cell size.

The init helper simplifies grid creation by specifying a single cell_size value instead of separate width and height. It automatically centers the grid around the origin and defines its overall dimensions.

extrude

Linear extrude a 2D geometry into a 3D.

Parameters

  • height: Length
  • scale = (x = 100%, y = 100%)
  • twist = 0°

mirror

Mirror along an axis, keeping existing geometry.

Parameters

  • x = 0mm
  • y = 0mm
  • z = 0mm
  • n: Vec3

orient

Orient an object towards a vector.

Parameters

  • v: Vec3

reflect

Reflect a geometry along an axis.

Parameters

  • x = 0mm
  • y = 0mm
  • z = 0mm
  • n: Vec3

revolve

Revolve a geometry around 360°.

Parameters

  • angle = 360°

rotate

An operation that rotates a part.

See the inits for examples on how to use this operation.

Parameters

  • matrix: Matrix3x3

init(angle: Angle, axis = __builtin::math::Z)

Rotate around an axis by an angle using a 3D vector.

The axis vector will be normalized.

  • angle - An angle.
  • axis - An axis to rotate around (Z axis is default).

Examples:

  • Rect(42mm).rotate(45°);: 2D rotation of a square by 45°.
  • Cube(42mm).rotate(45°, (x = 1, y = 1, z = 1)) ;: Rotates a cube by 45° around a diagonal axis.
  • Cube(42mm).rotate(30°, Y);: Rotates a cube by 30° around Y axis.

init(x = 0°, y = 0°, z = 0°)

Euler rotation around X, Y, Z.

  • x - X angle.
  • y - Y angle.
  • z - Z angle.

Examples:

  • Cube(42mm).rotate(45°, (1, 0, 0));: Rotates a cylinder by 45° around X axis (unnamed tuple).

init(roll = 0°, pitch = 0°, yaw = 0°)

Euler rotation around X, Y, Z (nautical angles)

  • roll - Roll angle, rotates around X axis.
  • pitch - Pitch angle, rotates around Y axis.
  • yaw - Yaw angle, rotates around Z axis.

Example:

  • Cube(42mm).rotate(roll = 30°): Rotates a cylinder by 45° around X axis.

init(xyz = (x = 0°, y = 0°, z = 0°))

Euler rotation around X, Y and Z axis (with a vector of angles)

  • Cube(42mm).rotate(xyz = (30°,20°,10°)): Euler rotation for a cube around X, Y, Z axis.

init(zyx = (x = 0°, y = 0°, z = 0°))

Euler rotation around Z, Y and X axis (with a vector of angles)

  • Cube(42mm).rotate(zyx = (30°,20°,10°));: Euler rotation for a cube around Z, Y, X axis.

scale

An operation that scales a part.

See the inits for examples on how to use this operation.

Parameters

  • v: Vec3

init(s: Scalar)

Uniform scale.

  • s - Scale factor.

Examples:

  • Rect(42mm).scale(200%);: Scale a rectangle by 200%.

init(x: Scalar = 1, y: Scalar = 1, z: Scalar = 1)

Non-uniform scale.

  • x - Scale factor in X direction.
  • y - Scale factor in Y direction.
  • z - Scale factor in Z direction.

Examples:

  • Rect(42mm).scale(x = 2.0);: Scale a rectangle in X direction.

spiralize

Create a spiral with a height and an inner and outer radius.

Parameters

  • inner_radius: Length
  • outer_radius: Length
  • angle: Angle
  • height = 0mm

translate

An operation that translates (moves) a geometry.

Parameters

  • x = 0mm
  • y = 0mm
  • z = 0mm

init(distance: Length, angle: Angle)

Polar-style translate with distance and angle.