MCAD

NOTE: WIP


Overview of MCAD Library

Download source: github dot com/openscad/MCAD

The MCAD library contains components commonly used in designing and making mockup mechanical designs. It is currently unfinished and you can expect some API changes, however many things are already working.

This library was created by various authors as named in the individual files' comments. All the files are licensed under the LGPL 2.1 (see creativecommons dot org/licenses/LGPL/2.1/ or the included file lgpl-2.1.txt), some of them allow distribution under more permissive terms (as described in the files' comments).

Usage

You can import these files in your scripts with use <MCAD/filename.scad>, where 'filename' is one of the files listed below like 'motors' or 'servos'. Some files include useful constants that are available with include <MCAD/filename.scad>, which should be safe to use on all included files (ie. no top level code should create geometry). (There is a bug/feature that prevents including constants from files that "include" other files - see the openscad mailing list archives for more details. Since the maintainers aren't very responsive, may have to work around this somehow)

If you host your project in git, you can do git submodule add URL PATH in your repo to import this library as a git submodule for easy usage. Then you need to do a git submodule update --init after cloning. When you want to update the submodule, do cd PATH; git checkout master; git pull. See git help submodule for more info.

Currently Provided Tools:

Tools (alpha and beta quality):

Very generally useful functions and constants:

Other:

Umetric_fastners.scad

External utils that generate and process openscad code:

MCAD/regular_shapes.scad

2D regular shapes

regular_polygon(sides, radius), or in older libraries, reg_polygon(sides, radius)

n-gons 2D shapes

Example:

Screenshot of regular 2D shapes with varying number of sides
use <MCAD/regular_shapes.scad>

radius = 5;

translate([00,0,0]) triangle(radius);
translate([10,0,0]) pentagon(radius);
translate([20,0,0]) hexagon(radius);
translate([30,0,0]) heptagon(radius);
translate([40,0,0]) octagon(radius);
translate([50,0,0]) nonagon(radius);
translate([60,0,0]) decagon(radius);
translate([70,0,0]) hendecagon(radius);
translate([80,0,0]) dodecagon(radius);
triangle(radius)
pentagon(radius)
hexagon(radius)
heptagon(radius)
octagon(radius)
nonagon(radius)
decagon(radius)
hendecagon(radius)
dodecagon(radius)

ring(inside_diameter, thickness)

Example:

Screenshot of ring shape
use <MCAD/regular_shapes.scad>
ring(10, 5);

ellipse(width, height)

Example:

Screenshot of ellipse()
use <MCAD/regular_shapes.scad>
ellipse(30, 15);

egg_outline(width, length)

Example:

Screenshot of Egg_outline()
use <MCAD/regular_shapes.scad>
egg_outline(10, 15);

3D regular shapes

cone(height, radius, center = false)

Example:

Screenshot of cone()
use <MCAD/regular_shapes.scad>
cone(20, 10);

oval_prism(height, rx, ry, center = false)

Example:

Screenshot of oval_prism()
use <MCAD/regular_shapes.scad>
oval_prism(20, 15, 5);

oval_tube(height, rx, ry, wall, center = false)

Example:

Screenshot of oval_tube()
use <MCAD/regular_shapes.scad>
oval_tube(20, 10, 5, 1);

cylinder_tube(height, radius, wall, center = false)

Example:

Screenshot of cylinder_tube()
use <MCAD/regular_shapes.scad>
cylinder_tube(20, 10, 1);

triangle_prism(height,radius)

Example:

Screenshot of triangle_prism()
use <MCAD/regular_shapes.scad>
triangle_prism(20,10);

triangle_tube(height,radius,wall)

Example:

Screenshot of triangle_tube()
use <MCAD/regular_shapes.scad>
triangle_tube(20,10, 1);

pentagon_prism(height,radius)

Solid pentagon shape

pentagon_tube(height,radius,wall)

Hollow pentagon shape

hexagon_prism(height,radius)

Similar to above

hexagon_tube(height,radius,wall)

Similar to above

heptagon_prism(height,radius)

Similar to above

heptagon_tube(height,radius,wall)

Similar to above

octagon_prism(height,radius)

Similar to above

octagon_tube(height,radius,wall)

Similar to above

nonagon_prism(height,radius)

Similar to above

decagon_prism(height,radius)

Similar to above

hendecagon_prism(height,radius)

Similar to above

dodecagon_prism(height,radius)

Similar to above

torus(outerRadius, innerRadius)

Example:

Screenshot of torus()
use <MCAD/regular_shapes.scad>
torus(30, 15);

torus2(r1, r2)

Example:

Screenshot of torus2()
use <MCAD/regular_shapes.scad>
torus2(30, 5);

oval_torus(inner_radius, thickness=[0, 0])

Example:

Screenshot of oval_torus()
use <MCAD/regular_shapes.scad>
oval_torus(20, thickness=[4, 8], $fn=50);

triangle_pyramid(radius)

Example:

Screenshot of triangle_pyramid()
use <MCAD/regular_shapes.scad>
triangle_pyramid(20);

square_pyramid(base_x, base_y, height)

Example:

Screenshot of square_pyramid()
use <MCAD/regular_shapes.scad>
square_pyramid(10, 20, 30);

egg(width, length)

NOTE: I couldn't get egg() to work at the time of creating this document.

To Fix egg(): replace 'cube(' with 'square(' at line 254 pos 40 on regular_shapes.scad

MCAD/involute_gears.scad

NOTE regarding bevel gears: Two bevel gears mesh when they have the same cone distance, circular pitch (measured at the cone distance), and pressure angle.

bevel_gear_pair()

bevel_gear_pair (gear1_teeth = 41, gear2_teeth = 7, axis_angle = 90, outside_circular_pitch=1000)

bevel_gear()

bevel_gear (
    number_of_teeth=11, 
    cone_distance=100, 
    face_width=20, 
    outside_circular_pitch=1000, 
    pressure_angle=30,
    clearance = 0.2, 
    bore_diameter=5,
    gear_thickness = 15, 
    backlash = 0, 
    involute_facets=0, 
    finish = -1) 
    Bevel Gear Finishing Options:
    bevel_gear_flat = 0;
    bevel_gear_back_cone = 1;

More INFO:

gear()

gear (
    number_of_teeth=15,
    circular_pitch=false, diametral_pitch=false,
    pressure_angle=28,
    clearance = 0.2,
    gear_thickness=5,
    rim_thickness=8,
    rim_width=5,
    hub_thickness=10,
    hub_diameter=15,
    bore_diameter=5,
    circles=0,
    backlash=0,
    twist=0,
    involute_facets=0,
    flat=false)

More INFO:

The module has a lot of 'extra' features.

Example:

 gear(number_of_teeth=20, circular_pitch=200, flat=true);

Tests

test_gears()

Example:

Demonstration of output from test_gears()
use <MCAD/involute_gears.scad>
test_gears();

test_meshing_double_helix()

Example:

Screenshot of output of testing_meshing_double_helix()
use <MCAD/involute_gears.scad>
test_meshing_double_helix();

test_bevel_gear()

Example:

Screenshot of test_bevel_gear
use <MCAD/involute_gears.scad>
test_bevel_gear();

test_bevel_gear_pair()

Example:

Screenshot of test_bevel_gear_pair()
use <MCAD/involute_gears.scad>
test_bevel_gear_pair();

test_backlash()

Example:

Screenshot of test_backlash()
use <MCAD/involute_gears.scad>
test_backlash ();

MCAD/teardrop.scad

The teardrop shape can be used to make printing vertical holes easier for the 3d printer by avoiding steep overhangs.

Example:

Screenshot of Teardrop Shaped Cutouts
 use <MCAD/teardrop.scad>;
 
 difference() {
     cube([5, 60, 40], center=true);
     translate([0, -15, 0]) teardrop(radius=6, length=20, angle=90);
     translate([0,   0, 0]) teardrop(radius=5, length=20, angle=60);
     translate([0,  15, 0]) teardrop(radius=4, length=20, angle=45);
 }


MCAD/stepper.scad

The stepper's shaft is pointing in negative Z-direction. The stepper's round front plate is flush with the Z-Plane.


Example:

Screenshot of Stepper Motors
 include <MCAD/stepper.scad>;
 
 for (size = [NemaShort, NemaMedium, NemaLong]) {  
   translate([50, size*100,0])  motor(Nema34, size, dualAxis=false);
   translate([150,size*100,0])  motor(Nema23, size, dualAxis=false);
   translate([250,size*100,0])  motor(Nema17, size, dualAxis=true);
   translate([350,size*100,0])  motor(Nema14, size, dualAxis=true);
   translate([450,size*100,0])  motor(Nema11, size, dualAxis=true);
   translate([550,size*100,0])  motor(Nema08, size, dualAxis=true);
 }
 % translate([0, 150, 0.01]) cube([600, 200, 0.1]); 


MCAD/nuts_and_bolts.scad

Example:

Screenshot of a M3 Bolt and Nut
 use <MCAD/nuts_and_bolts.scad>;
 include <MCAD/units.scad>;
 
 $fn=50;
 
 //M3 is an alias for 3 . It is defined in units.scad
 boltHole(M3, length=10);
 %boltHole(M3, length=10, tolerance=0.3);
 translate([-7, 0, 0]) nutHole(M3, tolerance=0.3);

MCAD/2Dshapes.scad

Example:

Screenshot of various 2D shapes
 use <MCAD/2Dshapes.scad>;
 
 ellipse(width=50, height=80);
 
 translate([100, 0, 0]) pieSlice([50, 100], start_angle=0, end_angle=250);
 
 translate([210, 0, 0]) donutSlice(20,50,0,300);
 
 translate([320, 0, 0]) ngon(6, 50, center=false);