2. Computer-Aided Design (CAD)#

The purpose of this module is to learn how to create 2D/3D models that will be used for 3D printing in the next module.

2.1 OpenSource softwares#

In the first class, we were introduced to three open-source software tools: Inkscape, OpenSCAD, and FreeCAD.

Usefulness of Inkscape:

  • 2D drawing Vectorization possible (.svg), which creates simpler text files than typical image files (.png, .jpg) and allows smooth scaling at any size
  • Clean and intuitive visual interface

Usefulness of OpenSCAD :

  • 3D modeling by coding
  • Better control over the manipulation of the model
  • Easier to model repetitive structures using loops (if, for,…)
  • Clean visual interface
  • Good documentation

Usefulness of FreeCAD :

  • 3D modeling through a graphical interface
  • Precise manipulation (point by point)

2.2 OpenSCAD#

The exercise was consisting in modelling a compliant mechanism, which is an object that, in response to an external force, returns to its initial shape. In other words, it is an object that uses its flexibility to perform a function. We could choose one in the Flexlinks construction kit.

Before modelling, we have to choose also a software for modeling. I decided to work with OpenSCAD because I am more familiar with coding, so it felt like a natural choice for me. The first step is to install it which can be done here. One can get acquainted by following the table of contents of OpenSCAD Tutorial that can be found in the documentation. I feel more comfortable about searching directly what I need when I’m doing my project as it is more pedagogical to me. Additionally, the documentation is very comprehensive and even includes a Cheat Sheet, which summarizes all the main coding references in one place.

2.3 3D modelisation#

2.3.1 The model#

The model I tried to reproduce was the following :

Throughout the modeling process, I kept the following sheet with dimensions by my side to ensure that my model would fit with a Lego when printed.

2.3.2 The code#

First I created the modules left_block() and right_block which are a combination of a rectangular parallelepiped with a cylinder at left and right end respectively. The hull() function allows to do this combination :


// Author : Altay Oralarkaya
// LICENCE : CC0 1.0 Universal 

length = 20;
width = 20;
height = 16;
radius = length/2;

// Positions of the cylinder relative to the cube for each block.

cylinder_vec1 = [radius,0,-height/2];
cylinder_vec2 = [-radius,0,-height/2];

//Creation of an object consisting of a left block and a cylinder joined using the hull() function.

module left_block(){
hull(){
translate([-10,0,0])
    cube([length,width,height], center = true);
translate(cylinder_vec1)
    cylinder(h = height, r1 = radius, r2 = radius);
}
};

//Creation of an object consisting of a right block and a cylinder joined using the hull() function.

module right_block(){
hull(){
translate(cylinder_vec2)
    cylinder(h = height, r1 = radius, r2 = radius);
translate([10,0,0])
    cube([length,width,height], center = true);
}
};

// Adding them to the world ro be able to see
// Function "translate()" to position them in the world

translate([30,0,0])
left_block();

translate([-30,0,0])
right_block();

We can now make holes in theses blocks by taking the difference of it with cylinders. This can be done with the function difference():

radius_hole = 6.5;

module hole(){
    cylinder(h = height, r1 = radius_hole, r2 = radius_hole, center = true);
};

//Positions of the holes in each block

hole_vec1 = [length/2,0,0];
hole_vec2 = [-length/2,0,0];

// Making holes in left block

module left_piece(){
difference(){
    left_block();
    translate(hole_vec1)
    hole();
    translate(hole_vec2)
    hole();
};
};

//Making holes in right block

module right_piece(){
difference(){
    right_block();
    translate(hole_vec1)
    hole();
    translate(hole_vec2)
    hole();
};
};

// Adding them to the world ro be able to see
// Function "translate()" to position them in the world

translate([30,0,0])
left_piece();

translate([-30,0,0])
right_piece();

Last step is to add the strip to link it all with the function union():

length_strip = 200;

// Creating the strip and postionning it with function "rotate()"

module line(){
rotate(a = 90, v=[1,0,0]){
rotate(a = 90, v=[0,0,1]){
rotate(a = 90,v=[0,1,0]){
cube([height*0.8,length_strip,3], center = true);
};
};
};
};

// Joining the strip with the two pieces

union(){
    right_piece();
translate([length_strip/2 + length,0,0])
    line();
translate([length_strip + length*2,0,0])
    left_piece();
};

We get a pretty good result ! Here is the full code in one piece :


// Author : Altay Oralarkaya
// LICENCE : CC0 1.0 Universal 

length = 20;
width = 20;
height = 16;
radius = length/2;

// Positions of the cylinder relative to the cube for each block.

cylinder_vec1 = [radius,0,-height/2];
cylinder_vec2 = [-radius,0,-height/2];

//Creation of an object consisting of a left block and a cylinder joined using the hull() function.

module left_block(){
hull(){
translate([-10,0,0])
    cube([length,width,height], center = true);
translate(cylinder_vec1)
    cylinder(h = height, r1 = radius, r2 = radius);
}
};

//Creation of an object consisting of a right block and a cylinder joined using the hull() function.

module right_block(){
hull(){
translate(cylinder_vec2)
    cylinder(h = height, r1 = radius, r2 = radius);
translate([10,0,0])
    cube([length,width,height], center = true);
}
};
radius_hole = 6.5;

module hole(){
    cylinder(h = height, r1 = radius_hole, r2 = radius_hole, center = true);
};

//positions of the holes in each block

hole_vec1 = [length/2,0,0];
hole_vec2 = [-length/2,0,0];

// Making holes in left block

module left_piece(){
difference(){
    left_block();
    translate(hole_vec1)
    hole();
    translate(hole_vec2)
    hole();
};
};

//Making holes in right block

module right_piece(){
difference(){
    right_block();
    translate(hole_vec1)
    hole();
    translate(hole_vec2)
    hole();
};
};

// Creating the strip and postionning it with function "rotate()"

length_strip = 200;
module line(){
rotate(a = 90, v=[1,0,0]){
rotate(a = 90, v=[0,0,1]){
rotate(a = 90,v=[0,1,0]){
cube([height*0.8,length_strip,3], center = true);
};
};
};
};

// Joining the strip with the two pieces

union(){
    right_piece();
translate([length_strip/2 + length,0,0])
    line();
translate([length_strip + length*2,0,0])
    left_piece();
};

2.3.3 The licence#

According to creative common licences I have chosen the CC0 licence which “is a public dedication tool, which enables creators to give up their copyright and put their works into the worldwide public domain. CC0 enables reusers to distribute, remix, adapt, and build upon the material in any medium or format, with no conditions”. It presents itself in the code as following :

// LICENCE : CC0 1.0 Universal