ReDo.Core reads the grammar of OpenSCAD 2021.01 and runs nearly all of it. The tables on this page are drawn from the same list the compiler checks every call against, so they are always the current list.
Where a command builds something slightly different from OpenSCAD, Where it differs from OpenSCAD says how.
The language
All of OpenSCAD's language works:
- Values: numbers, strings,
true and false, undef, lists, ranges such as [0 : 2 : 10], and function literals such as function (x) x * 2. - Operators:
+ - * / % ^, comparisons, && || !, and ? :. Lists add, subtract and multiply as vectors and matrices do. - Names: assignments,
function and module declarations, default arguments and named arguments. Variables, functions and modules each have their own names, as in OpenSCAD. - Control:
if / else, for (over lists and ranges, several variables at once), intersection_for, and let. - List comprehensions:
[for (i = [0 : 3]) i * 2], with if, else, let, each and the C-style for (i = 0; i < 4; i = i + 1). - Children:
children(), children(i) and $children inside a module. - Checks and messages:
echo(...) prints to the console beside the code, and assert(condition, message) stops the build with your message there. - Markers:
* leaves a subtree out, % leaves it out too (it is not drawn see-through), ! builds only that subtree, and # is accepted. - Files:
include <name.scad> reads one of ReDo's own library files. See The ReDo library. - Constants:
PI.
Commands and functions
3D shapes
| Call | Arguments | What it does |
|---|
cube() | size, center | A box, size a number or [x, y, z], from the origin or centred. |
sphere() | r; by name also d | A sphere, always exact whatever $fn says. Give r or d. |
cylinder() | h, r1, r2, center; by name also r, d, d1, d2 | A cylinder or cone, r1 at the bottom and r2 at the top. Give r, d, d1 or d2 by name. |
2D shapes
| Call | Arguments | What it does |
|---|
circle() | r; by name also d | A true circle unless $fn is set. Give r or d. |
square() | size, center | A rectangle, size a number or [x, y]. |
polygon() | points, paths, convexity | An outline through points; paths cut holes. An outline that crosses itself is refused. |
text() | text, size, font; by name also direction, language, script, halign, valign, spacing, em | A string in ReDo Sans, laid out as OpenSCAD lays it out: size, halign, valign, spacing, em. |
Extrusion
| Call | Arguments | What it does |
|---|
linear_extrude() | height, center, convexity, twist, slices, scale | Raises a 2D shape height along Z. A twist or a scale other than 1 is refused. |
rotate_extrude() | angle, convexity | Turns a 2D profile about Z, all the way round or by angle degrees. |
Moving and shaping
| Call | Arguments | What it does |
|---|
translate() | v | Moves its children by v. |
rotate() | a, v | Turns its children: [x, y, z] degrees, or a degrees about the axis v. |
scale() | v | Stretches its children by v. |
mirror() | v | Reflects its children in the plane whose normal is v. |
multmatrix() | m | Applies a 4 × 4 matrix m. |
resize() | newsize, auto, convexity | Scales its children to the size newsize; auto fills in a 0. |
offset() | r, delta, chamfer | Grows or shrinks a 2D shape: r rounds the corners, delta keeps them sharp or, with chamfer, cuts them. |
color() | c, alpha | Paints its children: a name such as "red" or "#rrggbb", and an alpha. |
Combining
| Call | Arguments | What it does |
|---|
union() | none | Joins its children into one. |
difference() | none | Cuts every later child from the first. |
intersection() | none | Keeps what all its children share. |
hull() | none | The convex hull of its children, curved faces sampled finely. 2D and 3D together are refused. |
render() | convexity | Accepted and ignored: every shape is already exact. |
Maths
| Call | Arguments | What it does |
|---|
abs() | x | The value without its sign. |
sign() | x | -1, 0 or 1. |
sin() | x | Sine of an angle in degrees. |
cos() | x | Cosine of an angle in degrees. |
tan() | x | Tangent of an angle in degrees. |
asin() | x | Arcsine, in degrees. |
acos() | x | Arccosine, in degrees. |
atan() | x | Arctangent, in degrees. |
atan2() | y, x | The angle of the point [x, y], in degrees. |
floor() | x | Rounds down. |
round() | x | Rounds to the nearest whole number, halves away from zero. |
ceil() | x | Rounds up. |
ln() | x | Natural logarithm. |
log() | x | Logarithm base 10. |
pow() | base, exponent | base raised to exponent. |
sqrt() | x | Square root. |
exp() | x | e raised to x. |
cbrt() | x | Cube root. |
hypot() | any number of values | The length of the vector its numbers make. |
min() | any number of values | The smallest of its values, or of one list. |
max() | any number of values | The largest of its values, or of one list. |
norm() | v | A vector's length. |
cross() | a, b | The cross product of two vectors. |
Lists and text
| Call | Arguments | What it does |
|---|
len() | v | How many items a list or characters a string holds. |
concat() | any number of lists | Joins lists into one. |
lookup() | key, table | Reads a value off a [key, value] table, between rows by straight line. |
search() | match_value, string_or_vector, num_returns_per_match, index_col_num | Finds values in a string or list, as OpenSCAD's search does. |
str() | any number of values | Writes its values as one string. |
chr() | any number of codes | The characters for character codes. |
ord() | s | The character code of a one-character string. |
Type tests and version
| Call | Arguments | What it does |
|---|
is_undef() | v | True for undef. |
is_bool() | v | True for true or false. |
is_num() | v | True for a number. |
is_string() | v | True for a string. |
is_list() | v | True for a list. |
is_function() | v | True for a function literal. |
version() | none | [2021, 1, 0]: the OpenSCAD release whose grammar ReDo.Core reads. |
version_num() | none | The same version as one number, 20210100. |
Settings
The $ settings, with the value each starts at. A $ setting holds for the block it is set in and everything that block calls, as in OpenSCAD.
| Setting | Default | What it does |
|---|
$fn | 0 | 0 draws exact circles. A number draws them as polygons with that many sides; past 512 is refused. |
$fa | 12 | Accepted and has no effect: a circle is exact, or has the $fn sides asked for. |
$fs | 2 | Accepted and has no effect, as $fa. |
$t | 0 | The animation step. Always 0: a part does not animate. |
$preview | false | Always false. |
$vpr | [55,0,25] | The view's rotation, fixed. |
$vpt | [0,0,0] | The view's centre, fixed. |
$vpd | 140 | The view's distance, fixed. |
$vpf | 22.5 | The view's field of view, fixed. |
$children | | How many children a module was handed. |
Refused
These would need a mesh, a file or a random number, which an exact part cannot use. Each stops the build with a message naming it.
| Call | Why it is refused |
|---|
minkowski() | A sum of meshes with no exact answer. Round a shape with offset() before extruding it, or with hull(). |
projection() | Would flatten a solid into a mesh outline. |
polyhedron() | A shape made of triangles, which an exact kernel cannot use as a solid. |
import() | A part reads no file; everything is in its code. |
surface() | A height map is a mesh. |
rands() | A part builds the same every time, so it draws no random numbers. |
parent_module() | The modules calling one are not kept. |
dxf_dim() | DXF files are not read. |
dxf_cross() | DXF files are not read. |