3D Conception

First introduction

3D design adds another dimension to 2D design described in unit 4. As in 2D design (https://www.makersplus.eu/2d-conception-cad/) this design can be handmade (painting, sketching), but also made with computer help in computer aided design processes. Again, there exist different possibilities, from the analogon to pixel based painting programmes to vector based programmes as well as using (3D-) scanners to bring already existing physical objects into the virtual realm.

Practical relevance

– This is what you will need the knowledge and skills for

3D design allows you to create your own designs for 3D printers (which will be presented in the next unit, 3D Printing) and milling machines. This allows you to create three dimensional real world objects like housings, replacement parts and complex mechanical systems as well as virtual 3D objects and renderings, used in games and VR environments. Basically everything which exists in our  real 3D world can be recreated as a 3D design.

Overview of learning objectives and competences

In this module you are going to learn:

  • general concepts
  • design tools

Required skills for this module

Basic computer skills and 2D design skills  module 2: 2D Conception

3D Design basics

3D design is the process of creating three dimensional objects. It  allows you to create virtual 3D objects, which can be used in virtual reality, animations and renderings – but can be also brought into the real world with 3D printers and milling machines.

Pixel and voxels, 2D - and 3D-vector design

With 3D design you add another dimension to the known 2D design from chapter Milling. Compared to 2D design the added third dimension will be added to each basic part, pixels become voxels (3 dimensional cubes, arranged in the 3D space), and vectors get a third dimension. Therefore, you can either do a voxel based approach like pixel painting programs in 2D, or vector drawings either in 2D or 3D. 

3D design makes life as a designer a bit more complicated, because of the extra dimension: Your standard computer only has a 2D display, and the input devices are also optimized for 2D input (e.g. mouse/touchpad).

Furthermore, 3D design software is sometimes optimized for 3D rendering on the computer and not for 3D printing. A hollow sphere with an infinitely thin surface looks the same as a solid ball – which might make a difference if you want to print it. 

Similarly, complex color mappings are mostly done as a sort of surface print for renderings while colorized 3D prints at nowadays entry level (multi filament extruder) requires solid color blocks and even uses separate 3D structures and files for each color.

Interestingly both major file formats used for the makerspace machines (The svg format is used for 2D design, the stl file format for 3D design) are basically unitless. You should therefore check the dimensions of an object before manufacturing.

3D design in makerspaces

Carving of a relief structure in Wood with a CNC mill

In chapter 4 2D conception is explained, which could be used for designs both for cutting machines as well as milling machines. While the cutting machines work mostly in 2D (the laser cutter can engrave a relief as sort of 3D), the milling machine can also carve in 3D. More importantly for Makerspaces are the 3D printers, which you learn to operate in the next chapter 3D printing. 3D printers allow you to produce complex 3D forms as housings, art, replacement parts – basically whatever you want.

Design restrictions

When 3D designing in the virtual world, you can design almost anything, but there are limits to what you can do in the real world. The ugly truth is, while a 3D printer as a concept can print everything, in reality you need specialized printers for different materials and resolutions – a chocolate printer will have a different printhead, resolution and dimensions than a concrete printer which can print houses.

Therefore, when designing 3D, you should also consider design requirements and material and machine limitations.

For example, as you already know from the previous chapters, milling machines use tools with a certain diameter and conventional 3-axis machines cannot perform undercuts. With 3D printers you have more freedom, as you will see in the next chapter, but you still have to design your objects to be printable – and you can often optimize the designs to make them faster, without support structures and cheaper.

3D Design Software

There are various approaches to 3D design with computer support, depending on the available hardware but even more on personal preferences and the intended design possibilities. Some basic design variants are described here – but especially with VR- and AR environments more variants are researched. Depending on the use case these design methods can be combined to achieve the desired design in the easiest way possible.

Minecraft is a voxel-based game: Its 3d world consists of cubes arranged in a grid which can be placed and destroyed.

1) You can design an object based on defined basic shapes (e.g. cubes), which are then combined. This can be done in Lego/Minecraft style by simply placing blocks in the right places in the 3D world. This would be a voxel-based approach, similar to pixel-based design. As in pixel paintings, a color can be applied to each voxel, therefore colorized objects are also possible. In minecraft the voxels are the cubes (with different colors for different materials) from which the 3D world is made, in lego the bricks (which are also colorized).  It is an approach for beginners,  for complex designs it is not optimal due to resolution or memory issues.

Fun Fact
You can indeed use Minecraft as a 3D editor, as you will create your own 3D structures in the game. The main obstacle is to create an stl file from it if you want to print it later. But fortunately there are tools for this, e.g. Craftplicator

2) Vector design is better scalable which improves both memory usage and resolution issues. 

  1. Here you can still use a set of basic shapes, which are again placed in 3D, but can also be resized and combined with boolean operations similar as the described in 2D conception: Create two overlapping objects in 3D and then either combine then or modify one object with the other through difference or intersection between each object.
  2. Sculpting is used for freeform objects. Here a base form is reshaped – Instead of adding additional objects the surface itself is modified.
  3. A less complex variant is using a 2D vector image (as in https://www.makersplus.eu/2d-conception-cad/) as a base form and extruding it along an axis, keeping the form of the moved outline as a 3D object: E.g. a circle will become a cylinder. Some Programs allow additional parameters for this extrusion – the shape might be scaled along the extrusion, or this axis is no straight line but also a more complex path in 2D or 3D.
  4. Additionally, you might want to colorize the objects with pictures on its surface if you design e.g. for 3D games and other artistic approaches. Makerspaces mostly use 3D printers that are not multicolour printers  – at least not in a photorealistic way – and therefore we will not address this type of design option in this learning material.

Excurs
3D printers with multiple Filament extruders (each one for a different material - which can also be a different color) do exist and become more available. So you can nowadays print at least in a (very) limited set of colors and low resolution. In this case you don’t design one colorized object, but one 3D design for each color and extruder.

Most of nowadays 3D design tools use the vector based approach, but might have a different focus on the design methods. Here we will focus on two open source software, OpenSCAD and FreeCAD. With these programs you can already do some great designs, and as a free open source software they are great for community exchange of designs.

OpenSCAD

OpenSCAD is an open-source 3D design software which uses a programming approach. It can be freely downloaded at OpenSCAD.orgYou design an object by adding basic objects, arrange and modify them in a text-based program code, rendering them later on in 3D. Advantage is that you have a limited toolset, which makes it relatively easy to learn, while loops and variables still allow complex and parametric objects. Furthermore, by starting with solid objects and precise dimensions (apart from being unitless as mentioned before) the objects will be (mostly) well printable.

FreeCAD

FreeCAD is a more complex design software. Again, it is also freely downloadable at freecadweb.org. Here you also start with basic forms which are defined with constraints. These constraints can be far more complex than just the simple three dimensions as used in OpenSCAD (as sort of basic constraints for an object), you can use different symmetries, helper objects and lines and so on. You just should make sure that an object is completely defined with its constraints, otherwise the resulting object might correct depending on your input, but not look and work as intended. But this software also allows the use of other design concepts – you could even use OpenSCAD design as one design option within FreeCAD.

Other design software and tools

Another basic design software would be TinkerCAD, an online editor with a limited toolset for simple objects, easy for beginners (children), and also free software (but not open source). 

For really complex designs, while still open source, you can use Blender – a 3D design software which can do almost anything, but learning this software is rather complex.

With Fusion 360 we would leave the open source area and get into professional, commercial tools. It is still free for hobbyists (at least for now) – otherwise it costs around 500€ per year. It has a good user interface and a great integration for almost direct machine usage.

For 3D design used for photorealistic renderings and animations Cinema4D (free for students) or Maya would be viable – but expensive – options.

Virtual Reality

Virtual reality allows painting and sculpting directly in a three-dimensional environment,  Google Tilt Brush is one option, but there exist also other open-source sculpting software.

3D displays as well as 3D input devices alone can support the 3D design flow. Virtual reality with the corresponding input devices finally allows a direct design in 3D. These include 3D mouses or drawing devices with haptic feedback like the Phantom Omni device and similar devices.

3D Scanner

If you just want to copy an already existing object in 3D, you might use a 3D scanner to get a design file. Depending on object size, resolution, and available hardware you can use e,g, your smartphone as a scanning device for photogrammetry scanning. There exist nowadays different apps for taking pictures as well as stitching these pictures together for smartphones.  

The Microsoft Kinect, a 3D input device for the XBox, was also popular as a person scanner, either as a handheld scanner or used with a rotating platform. Microsoft also delivered the corresponding 3D scanning software for the Kinect for free.

The girl on the rotating platform is scanned with the Kinect on the stativ in the middle, while on the computer on the table the corresponding Scan software from Microsoft is used for the scanning process.

For smaller objects the open-source 3D scanner FabScan Pi in the picture above is a cost-efficient solution.

But of course there exist also professional systems, from smaller scanners with rotational platforms, handheld scanners up to multiple-camera-photogrammetric rigs which can even record 3D movies.

OpenSCAD

OpenSCAD is a programming-based 3D design software. Its main window consists of multiple separate windows, which can be rearranged and resized depending on personal preferences.

In this example picture you can find the code area in the upper left area, where you program your design. 

The buttons above are responsible for the main functionalities. From left to right you will find:
New
Creates a blank new canvas for your next project
Load
Loads an existing .scad file
Save
Saves your file
Undo
Made a mistake? undo your last action
Redo
Was it no mistake? - undo the undone
Decrease Insert
Clean up your code by increasing indentations. Usually use the tab button instead
Increase Insert
Clean up you code by decreasing indentations
Preview
Show a quick render of you code in the display window
Render
Make a full 3D-rendering of your code. Takes more time but is required for stl export.
STL
Exports the design in the stl-file format, which can be used in other 3D-programs
3D-Print
Directly send your rendered design to a slicer software for the 3D-printer if set up.

At the bottom is the report window, which provides feedback – both to ensure that commands such as saving are carried out, and to report errors such as spell checking. 

On the right is the preview window showing the object in 3D, again with control buttons below.
Render
Same as above the code window, quick preview
STL
Same as above the code window, full rendering
Show all
zooms the view such that the full 3D image is shown
Zoom in
get closer to the 3D image for finer details
Zoom out
get away from the 3D image for broader overview
Center
Take the viewpoint back to the starting position (centering at axis origins)
Views (Right, Up, Down, Left, Front, Back)
6 different viewpoints (corresponding to looking frontal on the six sides of a cube)
Perspective /orthogonal
Switch between perspective and orthogonal (no distortion) view
show axis
Displays the axis
...with/without number
As an additional option to the shown axis you can also display/hide the axis division
show borders
Highlights the edges of the flat panels which the 3d object consists of.

You can also activate a so-called customizer window. If activated (under the view menu you can show or hide the customizer window), you can change variables live. This updates the 3D view correspondingly.

All these windows can be shown or hidden with an option in the view menu in your standard window bar, but the most important part in the menu structure is the link under help to https://OpenSCAD.org/cheatsheet/. This cheat sheet includes all important operations you need to know about OpenSCAD, and with links to examples. As you can see in the picture above, basic operations which you need to know are not that many – and you can still already design complex things with this.

Basic shapes

OpenSCAD uses a bunch of basic shapes both in 2D (which needs to be extruded into a 3D shape) and 3D shapes (which can be projected into an 2D image, if necessary, e.g. if you want to have a 2D design (svg export) for a laser cutter instead of an stl export for 3D objects). Each basic shape has parameters in brackets behind, which indicate the basic dimensions. Some of them, like the polygons, needs a list of coordinate pairs (the corner points), while others have alternative parameters – for a circle you can either just put in a number as radius – circle(10) – or define the diameter – circle(d=20) to achieve the same result. 

Hint: Use blank spaces and line breaks for better visibility – as long as you don’t break words itself it won’t produce errors (and otherwise: The program will give an error with line number to detect such errors). circle(10) will work as well as circle ( 10 )  or 

circle

(10)

More important is ending each command with a ;

2D objects
Creates a circle with either a certain radius or a certain diameter around the origin
Creates a square with equal length sides, either with one corner on the origin or optional centered around it
Creates a square with two different lengths of its sides
Creates a line of points with each point defined by its coordinates [x,y]
creates a text. The simplest version would be just text(“Maker+”), with other options for defining it further
let you import your own 2D design file stored on your computer (svg or dxf files)
Projects a 3D rendering onto the x-y plane. This can be either done by cutting through the object at this plane, or projecting the whole object on it (sort of biggest outline)
3D objects
Creates a sphere in 3D, analogue to the circle either defined by the radius or diameter.
Creates a cube in 3D, analogue to the square in 2D with all sizes with the same length
Here you can define all three length in 3D for a cube
Creates a cylinder in 3D, defined by its height and either radius or diameter
Creates a cone in 3D, by defining both height and upper and lower diameter or radius. If they are the same, you will of get an cylinder as before
Analogue to the polygon, you can also create an object in 3D through its corner points. First you need to define these corner points through their 3D coordinates, then create a list of sides with these points (each of them as a polygon path).
Lets you import an existing 3D object (stl file)
Creates a 3D object out of a 2D shape through extrusion for a certain height
Creates a 3D object out of a 2D shape by rotating the 2D Shape around an axis
Creates an 3D object out of an external image (color will be translated to height)

More complex objects will consist of multiple objects in relation to each other.

1) The basic brick
Let’s start as an example by designing a brick compatible with famous children’s toys.
A first step would be therefore a cube in the right dimensions (8mm width (x-direction), 8mm depth (y-direction), 9.6mm high (z-direction)) for a one-by-one-piece: 

This can be easily achieved by 

cube([8,8,9.6]);

When you render it, you can see it is not centered on the middle but put one corner point at the zero-coordinates. It depends on the preferences if you like to work that way, or if you want to center it around the origin with 

cube([8,8,9.6],true);

You can of course also use other options, like creating a square and extruding it:

linear_extrude(9.6)
square([8,8]);

or, even more complicated, use a polygon path

linear_extrude(9.6)
polygon([[0,0],[8,0],[8,8],[0,8]]);

or even a polyhedron
polyhedron(
[[0,0,  0],  //0
[8,0,  0],  //1
[8,8,  0],  //2
[0,8,  0],  //3
[0,0,9.6],  //4
[8,0,9.6],  //5
[8,8,9.6],  //6
[0,8,9.6]], //7,
[[0,1,2,3],  // bottom
[4,5,1,0],  // front
[7,6,5,4],  // top
[5,6,2,1],  // right
[6,7,3,2],  // back
[7,4,0,3]]  // left
);

But as you might notice, the first one is in this case the easiest solution. As a side note, as mentioned before, line breaks are only used for better readability:

polyhedron([[0,0,0],[8,0,0],[8,8,0],[0,8,0],[0,0,9.6],[8,0,9.6],[8,8,9.6],[0,8,9.6]],[[0,1,2,3],[4,5,1,0],[7,6,5,4],[5,6,2,1],[6,7,3,2],[7,4,0,3]]);

will work as well. Similarly, indents and line breaks can be used to structure the code. But you could also write the whole code in one line.

2) Adding a cylinder as brick connector

The second part would be the cylinder to connect bricks. Here you use a cylinder, with a diameter of 4.8mm, 1.6mm longer than the square piece. Therefore, you can make it either 1.6mm high and stack it on top, or longer up to 11.2mm, overlapping with the cube. Again, depends on your choice: The short option lets you easily spot errors in placement, an overlapping version lets you be safe to get no gaps in between while printing later on. 
A compromise will be a 9.6mm high cylinder, with the same length as the cube. You can first check alignment with the cube, and then make the correct 1.6mm offset later on.

While adding a 

cylinder(d=4.8,h=9.6);

to the code you might notice two things after rendering: First, the cylinder looks not very cylindrical, second, the position is not aligned – the basic circle is centered around the origin, but the height starts at origin like the cube before. This can be fixed with

cylinder(d=4.8,h=9.6, center=true); 

Now the cylinder is not visible anymore, hidden within the cube.

There are some modifiers that can be used to check the inside of the cube (and thus see the cylinder or whatever has been hidden before):
disable
comments out/disables objects. Similar to // or /* … */, but takes care of sub-objects as well
!
show only
The object is shown in preview, but disappears in the real rendering
#
highlight / debug
Tints the object red
%
transparent / background
Makes an object transparent to see the inside

Putting the % in front of the cube-command lets us see through it and makes the cylinder visible again.

%cube([8,8,9.6],true); 
cylinder(d=4.8,h=9.6, center=true);

In the next step you can try to make the cylinder rounder, this is where special variables come into place:

Special variables
minimum angle
for a round object to structure it into straight segments
minimum size
of each segment of a round object
number of fragments
Makes life easier, ignores $fs and $fa, just put a number here for circle segments
$t
animation step
Timing for animation videos
viewport rotation angles in degrees
Defines in which direction you look in the preview window
viewport translation
Defines from which position you look
viewport camera distance
Distance of the camera
viewport camera field of view
FOV of the camera
number of module children
Manipulates the following objects
true in F5 preview, false for F6
useful to decrease detail level for faster preview

Most of them are useful if you want to do animations, by changing parameters over time. This is not necessary for our 3D design for the printer (but can be useful e.g., for an assembly video). The important part for 3D designs of round objects is the $fn, which allows you to define the roundness of your object. Since OpenSCAD (and in fact almost every 3D design software) can only draw straight surfaces, each round object is emulated by a number of straight surfaces – the more the rounder. So an infinite number of surfaces would result in a perfectly round object, but rendering would take forever. The trick is to find a minimum number where the object looks and feels round (after 3D printing).

cylinder(d=4.8,h=9.6,center=true,$fn=36);

This looks nice with a 10-degree segmentation of its surface, and works with a fast enough computer.

Fun Fact
You can also produce the cube with the cylinder - just use 4 segments - although calculating the right diameter is not so easy.

Transformations

Now we need to change the position of the cylinder. It has the same height as the cube, but should  stick out 1.6 mm out of the cube. In the CheatSheet you find a list of transformation commands.

Transformation commands
Move an object according to the distances in the three dimensions
Rotate the object around the axis with certain degrees. With the rotation axis fixed on the coordinate system axis you might want to move the object at the right position beforehand.
Here you rotate the object around the axis defined by x,y,z with an angle a
Scales the object proportional to the given value (1 equal to original scale)
Resize the object to given values
Mirrors the object at the axis
Used to use multiple transformations at once
applies a color to an object, either by a predefined color by a predefined name like Yellow
… hexadecimal value…
… or RGB and Alpha values
create an interior/exterior by a given offset
Creates a hull over objects (connect outer points)
Creates an object by blowing up a given object with secondary objects placed at the corners and making a hull around it

For repositioning the cube, the translate option is the way to go. With 

translate([0,0,1.6]) cylinder(d=4.8,h=9.6,center=true,$fn=36);

The cylinder will be moved exactly by 1.6mm in z-direction (well, in fact 1.6 something – the design is unitless,  but as long as you use your values consequently with one imaginary unit, you are safe). Afterwards, the outer form seems to be correct, but you can’t stack it like a real lego brick. In the next step, you need to hollow it out.

Boolean operations

For the purpose of modifying the shape you can use boolean operations:
Unifies objects into one object
Subtract the following objects from the first one
Shows the overlapping area from multiple objects

As a first operation, you can combine both cylinder and cube in a single form:
union() {
     cube([8,8,9.6],true);
     translate([0,0,1.6]) cylinder(d=4.8,h=9.6,center=true,$fn=36);
}

In the rendering it will look exactly like before, but it counts now as one object for the next operations.

3) Hollowing out

The next operation is a difference, you can either subtract a cylinder (with the same diameter as before) or a cube (with the side length corresponding to the cylinders diameter).

difference() {
     union() {     cube([8,8,9.6],true);
     translate([0,0,1.6]) cylinder(d=4.8,h=9.6,center=true,$fn=36);
     }
     translate([0,0,-1.6]) cube([4.8,4.8,9.6],true);
}

In this case we choose the smaller cube, but with the same height as before, translated 1.6mm below the bottom, so that we get a 1.6 mm thick roof even without the cylinder.

Now, if we print it later, we have a parallel bridge to the bottom. With the small size this should work, but if you want to print a bigger brick, e.g., to build a real size home, this might cause problems (print might not work or take longer and need more material or require additional manual work for post processing. More on this in the chapter about 3D-printing

A dome structure would look better and be more stable (well, and complete overkill in our case due to the small size, but might be still useful if you intend to print a very big brick).  A dome can be produced by adding a sphere on top of the inner cube:

translate([0,0,4-0.8]) sphere(d=4.8, $fn=36); 

The sphere is already centered around the origin, and only needs to move up half of the height of the cube due to the cubes centering. As you can see, mathematical operations (and also logical operators) are also allowed within data input. But: If you remove the cylinder (or better: commenting it out with // if you don’t want to see the object, such that you can uncomment it later on if you need it again), there is a gap in the ceiling. Therefore, the sphere’s height needs to be modified to a height under 3.2 mm. This can be either done by 

  • by changing the size in percentages: 

translate([0,0,4-0.8]) scale([1,1,0.5]) sphere(d=4.8, $fn=36); 

  • by changing the size in absolute values:

translate([0,0,4-0.8]) resize([4.8,4.8,2.4]) sphere(d=4.8, $fn=36);

To check the design, you can add another difference of a cube to virtually halve the brick. Rotating the object in the 3D view with the mouse can also help:

difference() {
     difference() {
          union() {
             cube([8,8,9.6],true);
             translate([0,0,1.6]) cylinder(d=4.8,h=9.6,center=true,$fn=360);
          }
     union() {

     translate([0,0,-1.6]) cube([4.8,4.8,9.6],true);

     translate([0,0,4-0.8]) resize([4.8,4.8,2.4]) sphere(d=4.8, $fn=360);

     }

}

translate([50,0,0]) cube([100,100,100],true);

}

In the picture you can barely see that a problem remains: the corners between cube and sphere are not nice. In case of using a cylinder instead of the cube for hollowing out the brick, these edges won’t exist. But luckily, there exist another solution: Just using hull() instead of union() for the cube and resized sphere creates a smooth transition between both objects.

Variables & Modules

At some point you might notice that either you want to modify a bunch of values at the same time (e.g. producing a brick with different dimensions) or you might want to change the $fn value for faster rendering times. Luckily, as in normal programming, you can use variables to clean up your code and make it reusable. This is especially useful to adjust the printing parameters if your 3D printer does not print exactly the right dimensions due to thicker or thinner extrusion. You may need to change the outer and/or inner dimensions of your brick to make it fit together and with other compatible bricks.

Variables & Modules
Define a variable and assign a value
Comparison if a certain value is true then do something, otherwise do something different
Combine parts of the code for reuse
Create a functions to reuse calculations
Include the complete content of another OpenSCAD file
Includes modules and functions of another OpenSCAD file

In addition, the use of modules makes it easier for you to reuse these pieces of code later on.

bDiameter = 8;
bHeight = 3.2;
scaleOutside = 1;
scaleInside = 1;
resolution = 36;

baseBrick(3);

module baseBrick(z) {
     difference() {
          scale([scaleOutside,scaleOutside,scaleOutside]) union() {
               cube([bDiameter,bDiameter,z*bHeight],true);
               translate([0,0,bHeight/2])
                   cylinder(d=bDiameter-bHeight,h=z*bHeight, center=true, $fn=resolution);
           }
          scale([scaleInside,scaleInside,scaleInside]) hull() {
               translate([0,0, bHeight/2])
               cube([bDiameter-bHeight,bDiameter-bHeight,z*bHeight],true);
               translate([0,0,bHeight*(z-1)/2])
                    scale([1,1,0.5])
                   sphere(d=bDiameter-bHeight, $fn=resolution);
          }
     }
}

Here we changed the basic height of the brick from 9.6 to 3.2mm – from full brick height to plate height. To get a full lego brick we need therefore a stack of three plate bricks. A variable z in the module allows the creation of bricks with different heights. With baseBrick(3) a brick is created with the regular 9.6mm height as before  – It will therefore just look the same as before.

Loops

Just a one-by-one brick is of course a bit boring in the long run. To create larger pieces, you can use loops for repetitions instead of copying and pasting the code.

Loops
repeat for i from start to end, increasing i by one in each loop
same as above but increase by step in each loop
repeat for certain numbers
combines different variables in one statement
combines intersection and for in one loop…
…the for part allows the same options…
…as the for loop alone
conditional loop
set variables to a new value in the following subsection

4) Create Bricks in different sizes

You can 

  • use a for-loop to repeat your baseBrick-module a few times at different positions:

for(i=[0:3]) for(j=[0:1]) translate([i*8,j*8,0]) baseBrick();

  • use the translation inside the module before the first difference, and put the i and j as variables inside the module definition:

module baseBrick(x,y,z) {
     for(i=[0:x]) for(j=[0:y]) translate([i*8,j*8,0]) difference() {
          …
     }
}

If you want to design multiple bricks with different sizes, the second option might be a little bit better, since less code is used if the brick size can be defined within the module call. In the next step you might want to replace the numbers in the module call through variables again, that you define at the beginning of your code.

Customizer

If you activate the customizer window, you can see that all variables are listed and can be directly changed to update the object.

In reality, however, you only need to change the first 3 for the brick dimensions, the rest is usually predefined and will not change that much.

The Customizer only shows variables before the first module declaration, so you can hide the unnecessary variables by inserting a dummy declaration.

module dummy () {}

after the first three variable declarations. Furthermore, you can select different kinds of input options for the variables like slider, drop-down lists and checkboxes for boolean. With comments you can either create descriptions of the variables (// …) or organize the variables into tabs (/* […] */).
// Drop Down List
brickX = 3; // [0, 1, 2, 3]
// Slider
brickY = 1; // [0:20]
// labeled drop down box
brickZ = 3; // [1:Plate,
3:Brick]
/* [Offsets for printing] */
scaleOutside = 1; //
[1:0.01:1.1]
scaleInside = 1; //
[0.1:0.01:2]
module dummy () {}
bDiameter = 8;
bHeight = 3.2;
resolution = 36;

Now you have a basis to create whatever lego brick you want.

In the next part we will make a lego name plate out of it.

Round Brickplate

Make a round piece out of it – not in regular brick size, but a slightly larger and with rounded corner to be safer:
translate([0,0,1.6]) minkowski() {
     cylinder(d=22,center=true,h=0.8,$fn=resolution);
     sphere(d=bHeight-0.8,$fn=resolution);

}

This form should surround a 2*2 brick; therefore we delete the brickX, brickY and brickZ variables to create a fixed brick. Instead, we add some other variables:
clipWidth  = 50;
clipHeight = 18;
string = “Maker+”; 

The Brick itself needs to be centered to the origin in x- and y direction (and lifted by 1.6mm, such that it rests on top of the xy-plane). 
translate([-4,-4,1.6]) baseBrick(1,1,1);

Textfield borders

We want to add two cylinders as outlines for our clip onto the circle, the diameter would be its thickness, its length defined by the clipWidth. With the rotate you can bring the cylinders into the right orientation, and with translate they will get into the right positions. As you can see, a for loop reduces the code which you need to write:

for(i=[-clipHeight/2,clipHeight/2])
     translate([i,clipWidth/2,1.6])
     rotate([90,0,0])
    cylinder(h=clipWidth,d=bHeight,$fn=resolution/2, center=true);

At the far end you now need a round curve to connect both cylinders, here the circle in combination with the rotate_extrude is useful. A first translate is used to define the diameter of the curve, then a 180 degree angle extrusion creates the half circle as curve, and another translate brings this part into the right position:

translate([0,clipWidth,1.6])
     rotate_extrude(angle=180)
     translate([clipHeight/2,0,0])
     circle(d=bHeight,$fn=resolution/2);

Textfield bottom

A hull of two cylinders creates the bottom between the cylinder/circle structure:

hull() {
     for(i=[0,clipWidth])
         translate([0,i,0])
         cylinder(h=bheight/2,d=clipHeight,$fn=resolution/2);
}

Text

You can then add a text field, centered around the origin, rotated into the right direction and extruded… you might notice that the used commands start to repeat.

translate([0,(clipWidth+clipHeight)/2,0])
     linear_extrude(height=bHeight)
     rotate([0,0,90])
     text(string,halign=”center”,valign=”center”,size=clipHeight/2,font=”Liberation Sans:style=Bold”);

Combine and Customize

In a final step, you can combine all the clip parts into one module and pull the cube off of it so that the lower holes of the stone are accessible. Preview the design, change the parameters as you like, and finally render it completely and export it for 3D printing.

Feel free to modify it afterwards to your needs – you might e.g., subtract another cylinder from your clip form.

translate([0,clipWidth+5,0])
     cylinder(d=4,h=100,$fn=resolution,center=true); 

Thereafter you can easily attach this part to your keychain – of course then you might also need to adjust the clipWidth a bit such that this keychain hole doesn’t go through a letter of the text.

FreeCAD

FreeCad is a general purpose open source 3D-design software. It includes several different methods to design objects, including OpenSCAD.

General setup

In the general programme window you will find a row of buttons at the top. At the bottom is a report window that gives you feedback when something goes wrong. On the upper left side is the combo window – in the upper part you can switch between a model window – displaying the logic structure of your design with its part and the task window – allowing you to modify necessary parts. Below you can toggle between view (changing view options for the object, e.g. visibility) and data (changing parameters of the object, e.g. position). On the right side you see the big preview window for design and visual inspection

Some buttons stay the same for all design methods:

New Design - it will create a new kind of folder in the model window, each of the designs will get its own tab for the preview/design window

Loads an existing design

Save

Cut an object

Copy an object

Paste an object

Undo an action if something goes wrong

Redo an action if you undid too much

These general buttons also include the manipulation buttons for the preview/design window shown in the list below. These methods to change the view exist generally in  every 3D design software  – in OpenSCAD they could be found under the preview window.

Manipulation buttons for the preview/design window:

Center/Resize view of the preview window to fit the whole design

Center/Resize view of the preview window to fit the current selected objects

Select different drawing styles for the preview window

Show objects bounding box (outer dimension as cube)

View options for different documents/objects

3D perspective view

view design from front

view design from top

view design from right

view design from back

view design from below

view design from left

measure distance in preview window

Design methods

First you need to select the intended “design” methodology. Here we will focus on a design method using constraints. But as a reminder we will first use the known OpenSCAD as an introduction for using design methods before switching to the other design method. This will change the other buttons corresponding to the used method.

Drop down menu to select different design methods

Switch

to

Thereafter you will see an OpenSCAD symbol in the last button row. Pressing the button will open a text window on the left side, which allows you to create a new object as before.

If OpenSCAD is selected as design method, this button will create a new OpenSCAD design file

This adds an additional object in the model window and requires input in the task window – in this case the known code in the central window. You can either enter it here (“cylinder(d=4.8, h=1.6, $fn=36);”) or upload already existing code. You need to press the Add button to include the new object before closing the task window for the next step.

Part designer

Using another design method is similar in the beginning. Instead of OpenSCAD you select another design method, now part design. This design method allows you to design 3D objects through drawing with constraints.

After a switching from

you will get a different set of buttons:

to

Part design buttons:

Analog to the OpenSCAD button before this will create a new body, an empty hull for your new 3D object

Creates a new 2D Sketch as a base for 3D objects

Edits an (existing) sketch

Map a sketch on a 3D object

Check Constraints of the sketch

Leave Sketch

Reorient sketch on different coordinate plane

View sketch from above (edit plane)

View section

Besides the changed buttons, you see that some general ones stay the same: These are options for the preview/design window view (the perspective), and options to zoom and center the view. We will now use the body-button to create a new basic form.

If you click on the button “Create new body”, a new task window opens directly in which you have to decide in which coordinate level you want to design. When you have decided on one, you can close the window with “ok”.

Sketcher

Now you can start a first sketch by selecting the sketcher button (as you can see, it also changes the design method in the drop down menu from part design to sketcher). This will add a Sketch as a substructure from the previously generated body (the cylinder is the OpenSCAD-example from the beginning – which is not displayed at the moment, through setting visibility to false in the view-window).

You have several drawing options in the (rearranged) button structure. Here we use a circle, the design of the buttons resembles both the associated form as well as how you draw it (with the red dots as the points to click). You start off here with the center point by clicking on it somewhere on the canvas, a second click on a different position then sets the radius and thus the whole shape.

Drawing options:

Draw a single point

Draw a straight line between two points

Draw a part of a circle

Draws a full circle

Draw a curved line

Draw a polygon line

Draw a rectangle

Draw different symmetric forms

Draw a slot (A hull over two circles)

Edge manipulation - make a round corner

Edge manipulation - trim lines

Move point (change edge)

Insert an additional point (splits an edge)

Create an edge from objects outside the current sketch

Copies design from another sketch

Switch between visible construction lines (white/green) and invisible helper lines (blue)

Constraints

The shape is completely defined by constraints – some of which you can already create with the clicks to draw the circle – e.g., you can set the first point to the zero coordinates of the grid (indicated by a small cross when you move the mouse over it), which centers the circle around the origin. So you only need to set the diameter to define the circle completely. If you have not placed the center point on the origin, you can add additional constraints for the distance to the center point. As long as the lines of the object remain white, the object is not completely defined, if they turn red, it is over-defined. In this case, you can check the list of constraints in the task pane and in the notes above to see which ones conflict – and delete one from the list. It might still work if it is under- or over-defined, but it might – or better will – cause problems later when you want to change some parameters.

Constraints:

Constrains a point to another one

Constrains a point on another line

Constrains a line parallel to vertical axis

Constrains a line parallel to vertical axis

Constrains a line parallel to second one

Constrains a line perpendicular to a second one

Constrains a line to touch another

Two lines are equal

Constrains two points symmetric to line

Fixate edge

Lock point

Set edge to a certain horizontal length

Set edge to a certain vertical length

Set edge to a certain length

Set circle diameter

Set angle between two lines

Creates a constraint based on ray reflection

Toggle between sketching/helper variable constraints

Activate/deactivate a constraint

Extrusion

When all boundary conditions are defined and the sketch is ready, you can close the window (the method dropdown returns to part construction, as do the buttons). Here you can now select one of the extrusion options to create a 3D object from the 2D drawing. In this case we will use the pad button which makes a linear extrusion from your 2D drawing. As you can see, the inner circle has already been taken as a section. Another option would be to create a second sketch and choose one of the subtracting extrusion options.

Extrusion:

pad up 2D sketch - linear extrusion

rotate extrusion around axis

extrude between two or more shapes

extrude a form along another form

extrude a 2D-form by rotating around an axis

creates a basic form
Same can be done as subtractive extrusion of sketches from already existing 3D objects:

make a insertion into another form with a 2D shape

makes a hole into another shape

subtracts from a form through rotation of a shape around an axis

creates a hole through a shape with connected shapes

subtract a circular extruded shape

subtracts a basic form

Edge Manipulation

Of course, this cylinder form could be easily done with OpenSCAD. But part design gives you some other interesting options. With OpenSCAD creating round corners either by hull or minkowski is always a bit of work, especially for complex figures and afterwards. While you are still in the part design method, you can just select a line or area and round it (or even hollow out a whole structure if wanted), which is even parametric, if you want to change the design later on.

Edge Manipulation:

round corner by selecting a plane or edge

angled corner by selecting a plane or edge

frame structure

hollow out 3D form

Helper Lines

For a more complex design, you can use invisible help lines. First you create a new body and sketch as before, but here you use first the button to toggle into construction mode (the design forms are thereafter blue and not white) and draw shapes as before, again with constraints. When you switch back to normal drawing mode, you can use lines and points of your helper lines for the constraints of your new object (in this example, a small circle is centered at one corner point of an octagon).

After closing the sketcher window, you see that the helper lines are invisible, and only the new circle is visible (our rounded cylinder before, now named brick in the date window, is also made invisible).

Next, the circle is extruded again into a 3D object. In this case we use circular extrusion, with extrusion around the z-axis. You can of course also set a height and number of turns for the extrusion. Other extrusions will extrude between different 2D shapes. More complexity can be achieved by extruding not along axes but along defined paths.

Transformations

To create multiple copies of the extruded object you could normally use patterns. While the mirror would work, the polar pattern, which would be perfect for this use case, might not work in all cases. You just select an 3D object and select the number of copies as well as the places of the copies through angle area (or axis/length). Alternatively – more work but working in this case – you can copy and paste the object multiple times. Under Date you will find an “Angle” option that allows you to rotate the four copies at the designated positions.

Transformations:

mirror

place copies on a line

place copies polar

allows to use a general of different transformations

Finally, you can add a copy of the brick and move it with date/position to the right position along the z-Axis. The OpenSCAD cylinder can be also easily copied and its position changed. Even scaling works – in this case for changing the height for the upper and lower parts.

Boolean (again)

Of course, the part designer allows you to also use boolean operations, e.g. if you want to design more complex cutouts than the hole in the brick part. Just select two objects and apply the operation to them.

Boolean operation between 3D objects

Organizing your objects

To keep an overview over your design, create a folder structure, e.g., with a group to organize your parts hierarchically. Even more important, use meaningful names for all parts: Toppiece, BottomPiece, Connector, and Spiral1-Spiral4 instead of cylinder, brick, Con004-Con008 as in the design before.

Creates a group

Outlook

FreeCAD is a powerful tool. With the OpenSCAD part and the Part designer you only know a fraction of its design possibilities, and even these are not complete. One interesting option is the path method, where you can set up your design for your milling machine. There exists even a finite element simulation for the 3D parts. 

As always, keep learning and focus on things you need to know and make your life easier.

Summary

3D design allows you to create both art as well as functional objects either for virtual reality or for real world production. You know that there are different approaches to make the workflow as simple as possible, depending on the shape you want to achieve.

One option is a programming approach – reusing knowledge for the programming chapter. Here you design by defining basic forms, modify them by boolean operations and using loops and variables as well as modulus to structurize the code and reduce workload by reducing manual repetitions.

The second option you know now is the part designer within FreeCAD. This approach is more similar to 2D design, with using constraints for 2D shapes which are later extruded. Of course, the resulting 3D forms can be also manipulated, but here in a click and apply an option way and not typing and checking the results after rendering.

Depending on your desired design, other design methods – either within FreeCAD or by using another tool or even setup (e.g. VR environment for sculpting) – might even better suit your needs, but the basic features might still be recognizable.

As a general rule, you should never stop learning, each software is continuously developed, and other software might make your life easier depending on the use case. For each software exist several youtube channels for tutorials as well as books. But with continuous new videos, software updates and high dependency on use case, knowledge level and own preferences you need to to find the one which suits your interests best by yourself.

Quizz