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

CallArgumentsWhat it does
cube()size, centerA box, size a number or [x, y, z], from the origin or centred.
sphere()r; by name also dA sphere, always exact whatever $fn says. Give r or d.
cylinder()h, r1, r2, center; by name also r, d, d1, d2A cylinder or cone, r1 at the bottom and r2 at the top. Give r, d, d1 or d2 by name.

2D shapes

CallArgumentsWhat it does
circle()r; by name also dA true circle unless $fn is set. Give r or d.
square()size, centerA rectangle, size a number or [x, y].
polygon()points, paths, convexityAn 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, emA string in ReDo Sans, laid out as OpenSCAD lays it out: size, halign, valign, spacing, em.

Extrusion

CallArgumentsWhat it does
linear_extrude()height, center, convexity, twist, slices, scaleRaises a 2D shape height along Z. A twist or a scale other than 1 is refused.
rotate_extrude()angle, convexityTurns a 2D profile about Z, all the way round or by angle degrees.

Moving and shaping

CallArgumentsWhat it does
translate()vMoves its children by v.
rotate()a, vTurns its children: [x, y, z] degrees, or a degrees about the axis v.
scale()vStretches its children by v.
mirror()vReflects its children in the plane whose normal is v.
multmatrix()mApplies a 4 × 4 matrix m.
resize()newsize, auto, convexityScales its children to the size newsize; auto fills in a 0.
offset()r, delta, chamferGrows or shrinks a 2D shape: r rounds the corners, delta keeps them sharp or, with chamfer, cuts them.
color()c, alphaPaints its children: a name such as "red" or "#rrggbb", and an alpha.

Combining

CallArgumentsWhat it does
union()noneJoins its children into one.
difference()noneCuts every later child from the first.
intersection()noneKeeps what all its children share.
hull()noneThe convex hull of its children, curved faces sampled finely. 2D and 3D together are refused.
render()convexityAccepted and ignored: every shape is already exact.

Maths

CallArgumentsWhat it does
abs()xThe value without its sign.
sign()x-1, 0 or 1.
sin()xSine of an angle in degrees.
cos()xCosine of an angle in degrees.
tan()xTangent of an angle in degrees.
asin()xArcsine, in degrees.
acos()xArccosine, in degrees.
atan()xArctangent, in degrees.
atan2()y, xThe angle of the point [x, y], in degrees.
floor()xRounds down.
round()xRounds to the nearest whole number, halves away from zero.
ceil()xRounds up.
ln()xNatural logarithm.
log()xLogarithm base 10.
pow()base, exponentbase raised to exponent.
sqrt()xSquare root.
exp()xe raised to x.
cbrt()xCube root.
hypot()any number of valuesThe length of the vector its numbers make.
min()any number of valuesThe smallest of its values, or of one list.
max()any number of valuesThe largest of its values, or of one list.
norm()vA vector's length.
cross()a, bThe cross product of two vectors.

Lists and text

CallArgumentsWhat it does
len()vHow many items a list or characters a string holds.
concat()any number of listsJoins lists into one.
lookup()key, tableReads a value off a [key, value] table, between rows by straight line.
search()match_value, string_or_vector, num_returns_per_match, index_col_numFinds values in a string or list, as OpenSCAD's search does.
str()any number of valuesWrites its values as one string.
chr()any number of codesThe characters for character codes.
ord()sThe character code of a one-character string.

Type tests and version

CallArgumentsWhat it does
is_undef()vTrue for undef.
is_bool()vTrue for true or false.
is_num()vTrue for a number.
is_string()vTrue for a string.
is_list()vTrue for a list.
is_function()vTrue for a function literal.
version()none[2021, 1, 0]: the OpenSCAD release whose grammar ReDo.Core reads.
version_num()noneThe 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.

SettingDefaultWhat it does
$fn00 draws exact circles. A number draws them as polygons with that many sides; past 512 is refused.
$fa12Accepted and has no effect: a circle is exact, or has the $fn sides asked for.
$fs2Accepted and has no effect, as $fa.
$t0The animation step. Always 0: a part does not animate.
$previewfalseAlways false.
$vpr[55,0,25]The view's rotation, fixed.
$vpt[0,0,0]The view's centre, fixed.
$vpd140The view's distance, fixed.
$vpf22.5The view's field of view, fixed.
$childrenHow 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.

CallWhy 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.