


The rotation is proportional to the step index.The size is smaller at each step, by an exponential factor.Make_cube_edges(SIZE / exp(i/STEPS), i/STEPS * TOTAL_ROTATION)
#Openscad tutorial full#
We introduce the two constants STEPS and TOTAL_ROTATION, and replace the two calls to make_cube_edges() by one call enclosed in the for loop: WALL_THICKNESS = 3 Ĭube(, true) // full cubeĬube(, true) // dig along X axisĬube(, true) // dig along Y axisĬube(, true) // dig along Z axis Very handy for debugging.īut we do not want to add all the cubes one by one, so let's use a for loop. Notice the "#" modifier, which tells OpenSCAD, in preview mode, to draw the substracted objects in a translucent way.So the red inner cube is not exactly a cube, but a parallelepiped.This margin is here WALL_THICKNESS, but it could be anything > 0. The d2 variable defines a length greater than the cube size by a margin, in order to make sure we leave nothing from the face.The d1 variable defines a length smaller than the cube size, in order to leave out a border equal to the desired WALL_THICKNESS.(There are also functions, but they may only return a value.) In OpenSCAD, module is somehow equivalent to a function.Here is the first step: we create the outer cube (here blue), and substract an inner cube (here red) using difference() : WALL_THICKNESS = 3 ĭ1 = size - WALL_THICKNESS*2 // to keep wallsĭ2 = size + WALL_THICKNESS // to dig face We could build and align these 12 edges one by one, but instead we'll hollow out a cube in just 3 steps. It consists of the 12 edges of a cube, with a given thickness. The principal constituent (mentioned and shown in the previous step) is a cube frame. The OpenSCAD website: Also very handy, the cheat sheet:

I suggest you to browse them after (or, if you need clarifications, while) reading this Instructable. The OpenSCAD documentation and examples are excellent.
#Openscad tutorial code#
If you have seen code in C/C++, Java, Javascript or similar, you'll have no difficulty getting started. It allows to design arbitrarily complex objects in a programmatic way, using simple operations.īeing programmatic means precision and reproducibility, but also a certain learning curve, which is fortunately not steep. OpenSCAD is free and open-source, and runs on Linux, OSX and Windows. The 5th shows the principal constituent with which all is constructed: a cube frame. The 4th shows a variation, which will be explained below. The first 3 pictures show the finished object. And the ratio visual effect to design complexity being interesting, it was ideal for a tutorial.
#Openscad tutorial how to#
This Instructable explains how to build this object, using the OpenSCAD software, that is, programmatically.Īfter I 3D-printed this object, I saw it becoming popular among my children.
