OpenSCAD User Manual/MCAD

From Wikibooks, open books for an open world
< OpenSCAD User Manual
Jump to navigation Jump to search

NOTE: WIP


Contents

Overview of MCAD Library[edit]

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 which will be 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:

  • regular_shapes.scad
    • regular polygons, ie. 2D
    • regular polyhedrons, ie. 3D
  • involute_gears.scad (www dot thingiverse dot com/thing:3575):
    • gear()
    • bevel_gear()
    • bevel_gear_pair()
  • gears.scad (Old version):
    • gear(number_of_teeth, circular_pitch OR diametrial_pitch, pressure_angle OPTIONAL, clearance OPTIONAL)
  • motors.scad:
    • stepper_motor_mount(nema_standard, slide_distance OPTIONAL, mochup OPTIONAL)

Tools (alpha and beta quality):

  • nuts_and_bolts.scad: for creating metric and imperial bolt/nut holes
  • bearing.scad: standard/custom bearings
  • screw.scad: screws and augers
  • materials.scad: color definitions for different materials
  • stepper.scad: NEMA standard stepper outlines
  • servos.scad: servo outlines
  • boxes.scad: box with rounded corners
  • triangles.scad: simple triangles
  • 3d_triangle.scad: more advanced triangles

Very generally useful functions and constants:

  • math.scad: general math functions
  • constants.scad: mathematical constants
  • curves.scad: mathematical functions defining curves
  • units.scad: easy metric units
  • utilities.scad: geometric funtions and misc. useful stuff
  • teardrop.scad (www dot thingiverse dot com/thing:3457): parametric teardrop module
  • shapes.scad: DEPRECATED simple shapes by Catarina Mota
  • polyholes.scad: holes that should come out well when printed

Other:

  • alphabet_block.scad
  • bitmap.scad
  • letter_necklace.scad
  • name_tag.scad
  • height_map.scad
  • trochoids.scad
  • libtriangles.scad
  • layouts.scad
  • transformations.scad
  • 2Dshapes.scad
  • gridbeam.scad
  • fonts.scad
  • unregular_shapes.scad

Umetric_fastners.scad

  • lego_compatibility.scad
  • multiply.scad
  • hardware.scad

External utils that generate and process openscad code:

  • openscad_testing.py: testing code, see below
  • openscad_utils.py: code for scraping function names etc.

MCAD/regular_shapes.scad[edit]

2D regular shapes[edit]

regular_polygon(sides, radius), or in older libraries, reg_polygon(sides, radius)[edit]

n-gons 2D shapes[edit]

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)[edit]
pentagon(radius)[edit]
hexagon(radius)[edit]
heptagon(radius)[edit]
octagon(radius)[edit]
nonagon(radius)[edit]
decagon(radius)[edit]
hendecagon(radius)[edit]
dodecagon(radius)[edit]

ring(inside_diameter, thickness)[edit]

Example:

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

ellipse(width, height)[edit]

Example:

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

egg_outline(width, length)[edit]

Example:

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

3D regular shapes[edit]

cone(height, radius, center = false)[edit]

Example:

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

oval_prism(height, rx, ry, center = false)[edit]

Example:

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

oval_tube(height, rx, ry, wall, center = false)[edit]

Example:

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

cylinder_tube(height, radius, wall, center = false)[edit]

Example:

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

triangle_prism(height,radius)[edit]

Example:

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

triangle_tube(height,radius,wall)[edit]

Example:

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

pentagon_prism(height,radius)[edit]

Solid pentagon shape

pentagon_tube(height,radius,wall)[edit]

Hollow pentagon shape

hexagon_prism(height,radius)[edit]

Similar to above

hexagon_tube(height,radius,wall)[edit]

Similar to above

heptagon_prism(height,radius)[edit]

Similar to above

heptagon_tube(height,radius,wall)[edit]

Similar to above

octagon_prism(height,radius)[edit]

Similar to above

octagon_tube(height,radius,wall)[edit]

Similar to above

nonagon_prism(height,radius)[edit]

Similar to above

decagon_prism(height,radius)[edit]

Similar to above

hendecagon_prism(height,radius)[edit]

Similar to above

dodecagon_prism(height,radius)[edit]

Similar to above

torus(outerRadius, innerRadius)[edit]

Example:

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

torus2(r1, r2)[edit]

Example:

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

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

Example:

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

triangle_pyramid(radius)[edit]

Example:

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

square_pyramid(base_x, base_y, height)[edit]

Example:

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

egg(width, length)[edit]

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

MCAD/involute_gears.scad[edit]

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

bevel_gear_pair()[edit]

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

bevel_gear()[edit]

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;

gear()[edit]

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:

  • number_of_teeth number of teeth. Note that since circumference=2πr∝number_of_teeth the distance_between_gears∝total_number_of_teeth*pitch Basically if you have two gears, any two gears with the same sum number of teeth also fit at that distance.
  • circular_pitch, diametral_pitch proportional to the size of the teeth. (TODO proportionality constant)
  • pressure_angle
  • clearance
  • flat Makes the module a 2d object. This way you can `linear_extrude` it yourself.

The module has a lot of 'extra' features.

  • rim_thickness Thickness of edges(where it contacts.
  • gear_thickness Thickness inside, it cuts out a circle to make the inside flatter if smaller than rim thickness.
  • rim_width How far from the edge the gear is made at the
  • hub_thickness, hub_diameter, thicker bit in the center.
  • bore_diameter hole in center, for an axle, for instance.=
  • circles Makes the given number of holes around the center to save material
  • backlash
  • twist Twist in linear extruding. Used for making helical gears. (e.g.chevron/herringbone or worm drive gears)
  • involute_facets

Example:

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

Tests[edit]

test_gears()[edit]

Example:

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

test_meshing_double_helix()[edit]

Example:

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

test_bevel_gear()[edit]

Example:

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

test_bevel_gear_pair()[edit]

Example:

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

test_backlash()[edit]

Example:

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