2D Primitives
All 2D primitives can be transformed with 3D transformations and are typically used as input for extrusion operations.
square
Create a rectangle in the first quadrant. When center is true, it is centered at the origin.
Syntax:
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
dim |
number or [x, y] |
1 |
A single number creates a square; a list creates a rectangle |
center |
bool | False |
Center on the origin |
Examples:
OpenSCAD reference: square
circle
Create a circle at the origin.
Syntax:
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
r |
float | 1 |
Radius |
d |
float | — | Diameter (alternative to r; cannot specify both) |
angle |
float | 360 |
Arc angle in degrees (PythonSCAD extension) |
fn |
int | — | Number of segments (also sets polygon sides, e.g. fn=6 for hexagon) |
fa |
float | — | Minimum angle per segment |
fs |
float | — | Minimum segment size |
PythonSCAD extensions:
The angle parameter creates a pie/sector shape:
Examples:
OpenSCAD reference: circle
polygon
Create a 2D polygon from a list of points.
Syntax:
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
points |
list of [x, y] |
— | Vertex coordinates |
paths |
list of index lists | None |
Optional paths defining which points form each outline/hole. If omitted, points are connected in order |
convexity |
int | 2 |
Maximum number of front/back faces a ray can intersect |
Examples:
OpenSCAD reference: polygon
polyline
Create an open polyline from a list of points. Unlike polygon, a polyline is not necessarily closed and has no area. It is useful for defining cut lines in laser cutting workflows.
Syntax:
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
points |
list of [x, y] |
— | Vertex coordinates connected by line segments |
Polylines can carry color but have no area and are ignored in CSG operations.
Examples:
spline
Create a smooth 2D curve that passes through the given control points. Similar to polygon but produces a smooth, rounded shape.
Syntax:
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
points |
list of [x, y] |
— | Control points the spline passes through |
fn |
float | 0 |
Number of interpolation segments |
fa |
float | 0 |
Minimum angle |
fs |
float | 0 |
Minimum segment size |
Examples:
text
Create 2D text geometry.
Syntax:
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
t |
string | — | The text string to render |
size |
float | 10 |
Font size |
font |
string | "" |
Font name (system font or path) |
spacing |
float | 1 |
Character spacing multiplier |
direction |
string | "ltr" |
Text direction: "ltr", "rtl", "ttb", "btt" |
language |
string | "en" |
Language for text shaping |
script |
string | "latin" |
Script for text shaping |
halign |
string | "left" |
Horizontal alignment: "left", "center", "right" |
valign |
string | "baseline" |
Vertical alignment: "top", "center", "baseline", "bottom" |
fn |
int | — | Number of segments for curves |
Examples:
OpenSCAD reference: text
textmetrics
Get the bounding box metrics of a text string without creating geometry. Returns a dictionary with dimension information.
Syntax:
Parameters:
Same parameters as text.
Returns: A dictionary containing text metrics (bounding box dimensions, advance width, etc.).
Examples: