Read time: 2.8 minutes (278 words)

Library Parts

Several of the OpenSCAD code files developed are useful in other projects, so they are collected into a library folder rather than just placing then in the general model design folders. OpenSCAD supports loading files from user libraries with a little setup. To do this, you must configure your system to add the OPENSCAD environment variable so that the application can see this when you start up OpenSCAD. Details can be found in the OpenSCAD documentation.

Colors

Here is a file listing available colors that can be used in generating the visual representation of parts and assemblies. I added one color to represent balsa wood. The original color file was created by David Powell and was found in a post on the OpenSCAD forum at https://forum.openscad.org/CSG-Difference-bogus-color-logic-td5265.html:

  1// colors.scad
  2// Credit: David Powell, OpenSCAN Forum
  3
  4
  5
  6//group ABS_<colorname>
  7//	discription  common 3d printer ABS filament colors
  8// actual colours may need some tweaking
  9
 10ABS_Nature =[0.8,0.8,0.8,0.8];
 11ABS_White =[0.9,0.9,0.9,1];
 12ABS_Black =[0.1,0.1,0.1,1];
 13ABS_Red = [0.7,0,0,1];
 14ABS_Green = [0,0.7,0,1];
 15ABS_Blue = [0,0,0.7,1];
 16ABS_Orange =[0.8,0.4,0,1];
 17ABS_Purple =[0.7,0,0.7,1];
 18ABS_Brown =[0.6,0.2,0.2,1];
 19ABS_Glow_Blue =[0,0,.99,1];
 20ABS_Flurescence_Green =[0,1,0,1];
 21ABS_Flurescence_Yellow = [0.9,0.9,0,1];
 22
 23//group PLA_<colorname>
 24//	discription  common 3d printer PLA filament colors
 25// actual colours may need some tweaking
 26
 27PLA_Nature =[0.8,0.8,0.8,0.8];
 28PLA_White =[0.9,0.9,0.9,1];
 29PLA_Black =[0.1,0.1,0.1,1];
 30PLA_Red = [0.7,0,0,1];
 31PLA_Green = [0,0.7,0,1];
 32PLA_Blue = [0,0,0.7,1];
 33PLA_Orange =[0.8,0.4,0,1];
 34PLA_Purple =[0.7,0,0.7,1];
 35PLA_Brown =[0.6,0.2,0.2,1];
 36PLA_Glow_Blue =[0,0,.99,1];
 37PLA_Flurescence_Green =[0,1,0,1];
 38PLA_Flurescence_Yellow = [0.9,0.9,0,1];
 39
 40//group ANODIZED_<colorname>
 41//	discription  common aluminium anodized colors
 42// these don't seem to follow normal color tables as the process
 43// produces a color change difference to the named color
 44// dew to base metal
 45// actual colours may need some tweaking
 46
 47ANODIZED_Red =[0.7,0,0,1];
 48ANODIZED_Gold =[0.8,0.8,0.0,1];
 49ANODIZED_Black =[0.1,0.1,0.1,1];
 50ANODIZED_Blue =[0,0,0.7,1];
 51ANODIZED_Green =[0,0.5,0,1];
 52ANODIZED_Gray =[0.4,0.4,0.4,1];
 53ANODIZED_Dark_Blue =[0,0.2,0.6,1];
 54ANODIZED_Lime_Green =[0,0.8,0,1];
 55ANODIZED_Purple =[0.5,0,0.7,1];		//more blue than purple
 56ANODIZED_Light_Blue =[0.4,0.4,1,1];
 57ANODIZED_Pink =[0.7,0,0.7,1];		//more purlpe than pink
 58ANODIZED_Orange =[0.9,0.5,0,1];
 59ANODIZED_Scandia_Gold =[0.9,0.6,0.3,1];
 60ANODIZED_Copper =[0.7,0.5,0,1];		//more brown than copper
 61ANODIZED_Clear =[0.7,0.7,0.9,1];	//natural aluminium color
 62ANODIZED_Light_Bronze =[0.4,0.4,0.3,1]; //more silver than bronze
 63ANODIZED_Gold_Nickel =[0.8,0.8,0.6,1];
 64ANODIZED_Brush_Nickel =[0.8,0.8,0.7,1];
 65
 66//group METAL_<typename>
 67//	discription common metal colors
 68// colors need tweaking
 69
 70METAL_Aluminium = [0.7,0.7,0.8,1];
 71METAL_Brass = [0.88,0.78,0.5,1];
 72METAL_Copper = [0.9,0.6,0.5,1];
 73METAL_Steel = [0.9,0.9,0.8,1];
 74METAL_Stainless = [0.8,0.8,0.7,1];
 75METAL_Titanium = [0.7,0.7,0.6,1];
 76METAL_Bronze = [0.9,0.4,0.4,1];
 77METAL_Gold = [0.9,0.9,0.0,1];
 78METAL_Silver = [0.8,0.8,0.8,1];
 79METAL_Iron = [0.6,0.6,0.6,1];
 80
 81// group WOOD_<typename>
 82//	discription common wood colors
 83// probabaly wrong
 84
 85WOOD_Oak = [0.4,0.2,0.2,1];
 86WOOD_Birch = [0.8,0.8,0.4,1];
 87WOOD_Red = [0.7,0.3,0.3,1];
 88WOOD_pine = [0.8,0.8,0.4,1];
 89WOOD_Beach = [0.8,0.6,0.3,1];
 90WOOD_Spruce = [0.8,0.8,0.7,1];
 91WOOD_Balsa = [0.95,0.86,0.73];
 92
 93// group GLASS_<color>
 94//	discription common glass colors
 95// needs tweaking
 96
 97GLASS_Clear = [0.8,0.8,0.8,0.2];
 98GLASS_Red = [0.8,0,0,0.4];
 99GLASS_Green = [0,0.8,0,.4];
100GLASS_Blue = [0,0,0.8,.4];
101GLASS_Brown = [0.5,0.3,0.1,.4];
102
103CONCRETE = [210/255, 209/255, 205/255];

Positioning

Since we need to position components many times during the building of the final design, I created a simple routine that will translate and rotate components for final placement in an assembly. This code uses a neat feature of the OpenSCAD language that lets you apply a function to the code that follow this one. The align function defined here significantly reduces the clutter of the design code. The included position function applies translations only:

 1//#####################################
 2// position.scad
 3// (c) 2021 by Roie R. Black
 4//=====================================
 5
 6// apply rotation, then translation
 7module align(d) {
 8  translate([d[0],d[1],d[2]])
 9    rotate([d[3],d[4],d[5]]) children();
10}
11
12// apply translation only
13module position(d) {
14  translate([d[0],d[1],d[2]]) children();
15}

Simple Spars

We use three basic spars in models: a straight square spar, a single tapered spar, and a double tapered spar. Eventually, I will modify these routines to allow for rectangular cross sections.

Square Spar

 1//####################################
 2// square_spar.scad
 3// (c) 2021 by Roie R. Black
 4//====================================
 5
 6
 7module square_spar(length=6,size=1/16) {
 8  translate([size/2, 0, size/2])
 9    cube([size,length,size], center=true);
10}
11
12square_spar(6,1/16);
../_images/square_spar.png

Single Tapered Spar

 1//#######################################################################
 2// single_taper_spar.scad - spat tapered on one side
 3// (c) 2021 - Roie R. Black
 4// docs: https://rblack.github.io/math-magik/magik/single_taper_spar.html
 5
 6module single_taper_spar(l=5, z1=1, z2=0.5, t=1, debug=false) {
 7  // calculate taper angle
 8  ang = atan2(z1-z2,l);
 9
10  difference() {
11    // basic spar
12    cube([l,t,z1]);
13
14    // trimming block
15    translate([0,-t/2, z1])
16    rotate([0,ang,0])
17    if (debug) {
18      #cube([l+1, 2*t, z1]);
19    } else {
20      cube([l+1, 2*t, z1]);
21    }
22  }
23}
24
25single_taper_spar(debug=true);
../_images/single_taper_spar.png

Double taper Spar

 1//######################################################################
 2// double_taper_spar.scad - creates a spar tapered on two sides
 3// (c) 2021 - Roie R. Black
 4// docs: https://rblack.github.io/math-magik/magik/double_taper_spar.html
 5
 6module double_taper_spar(l=5, y1=1, y2=0.5, z1=1, z2=0.5, debug=false) {
 7  // calc taper angles
 8  yang = atan2(z1-z2,l);
 9  zang = atan2(y1-y2,l);
10
11
12  difference() {
13    // z taper
14    difference() {
15      cube([l,y1,z1]);
16      translate([0,-y1/2, z1])
17        rotate([0,yang,0])
18          if (debug) {
19            #cube([l+1, 2*y1, z1]);
20          } else {
21            cube([l+1, 2*y1, z1]);
22          }
23    // y taper
24    translate([0,y1, -z1/2])
25      rotate([0,0,-zang])
26        if (debug) {
27          #cube([l+1, y1, 2*z1]);
28        } else {
29          cube([l+1, y1, 2*z1]);
30        }
31    }
32  }
33}
34
35double_taper_spar();
../_images/double_taper_spar.png

Mounting Posts

Indoor models are usually not glued together permanently. Instead, we use posts and paper tubes to allow parts to be separated for transport.

Rounded Posts

These are simple square pieces with a rounded top for the paper tube to slide over.

 1//########################################################
 2// rounded post.scad - square post with rounded top
 3// (c) 2021 - Roie R. Black
 4//========================================================
 5$fn=100;
 6
 7module rounded_post(z1=3, z2=2.5, t = 0.25) {
 8  union() {
 9      translate([-t/2,-t/2,0])
10      cube([t,t,z2]);
11      translate([0,0,z2])
12      cylinder(r=t/2, h=z1-z2);
13  }
14}
15
16rounded_post();
17
../_images/rounded_post.png

Paper Tubes

Paper tubes, formed by glueing tissue strips wound over a mandrel of some sort are attached to structural parts and placed to slide over mounting posts.

 1//################################################################
 2// paper tube.scad - creates simple hollow cylinder
 3// (c) 2021 - Roie R. Black
 4// docs: https://rblack.github.io/math-magik/magik/paper_tube.html
 5
 6$fn = 100;
 7
 8module paper_tube(r=1, h=2, t=0.25) {
 9  th = 3 * h;
10  difference() {
11    cylinder(r=r+t,h=h);
12    translate([0,0,-h])
13      cylinder(r=r, h=th);
14  }
15}
16
17paper_tube();
../_images/paper_tube.png