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, where 'filename' is one of the files listed below like 'motors' or 'servos'. Some files include useful constants that are available with include , 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 (on Thingiverse): 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 trianglesVery 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 printedOther: 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.scadUmetric_fastners.scad lego_compatibility.scad multiply.scad hardware.scadExternal 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 == === 2D regular shapes === ==== regular_polygon(sides, radius), or in older libraries, reg_polygon(sides, radius) ==== ==== n-gons 2D shapes ==== Example: use 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: use ring(10, 5); ==== ellipse(width, height) ==== Example: use ellipse(30, 15); ==== egg_outline(width, length) ==== Example: use egg_outline(10, 15); === 3D regular shapes === ==== cone(height, radius, center = false) ==== Example: use cone(20, 10); ==== oval_prism(height, rx, ry, center = false) ==== Example: use oval_prism(20, 15, 5); ==== oval_tube(height, rx, ry, wall, center = false) ==== Example: use oval_tube(20, 10, 5, 1); ==== cylinder_tube(height, radius, wall, center = false) ==== Example: use cylinder_tube(20, 10, 1); ==== triangle_prism(height,radius) ==== Example: use triangle_prism(20,10); ==== triangle_tube(height,radius,wall) ==== Example: use 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: use torus(30, 15); ==== torus2(r1, r2) ==== Example: use torus2(30, 5); ==== oval_torus(inner_radius, thickness=[0, 0]) ==== Example: use oval_torus(20, thickness=[4, 8], $fn=50); ==== triangle_pyramid(radius) ==== Example: use triangle_pyramid(20); ==== square_pyramid(base_x, base_y, height) ==== Example: use 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: number_of_teeth number of teeth cone_distance Important to the angle of your gear teeth. See Cone Distance pressure_angle Part of the terms that, taken together, make up the gear tooth profile. See Pressure_angle bore_diameter Size of hole in middle of gear outside_circular_pitch Roughly, this is the circumference of the gear. This is one of the most important measurements, and is worth looking up more precisely. See Pitch_circle. This indirectly controls the gear radius. Your gear's overall diameter is roughly the outside_circle_pitch / 360 * number_of_teeth. For example, 1000 / 360 * 36 would result in a gear approx 100mm in diameter. finish Special parameter. Setting this equal to bevel_gear_flat (0) vs bevel_gear_back_cone (1) changes whether your gear looks like a flat bevel gear, or whether a back cone (similar to the 'cone' before) is used. See Back Cone gear_thickness Bit of a misnomer. This is not the "typical" gear definition of thickness. Instead, it has nothing to do with the teeth of your gear and instead asks how tall of a cylinder the gear teeth should be placed on top oc === 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: 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_facetsExample: gear(number_of_teeth=20, circular_pitch=200, flat=true); === Tests === ==== test_gears() ==== Example: use test_gears(); ==== test_meshing_double_helix() ==== Example: use test_meshing_double_helix(); ==== test_bevel_gear() ==== Example: use test_bevel_gear(); ==== test_bevel_gear_pair() ==== Example: use test_bevel_gear_pair(); ==== test_backlash() ==== Example: use 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: use ; 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: include ; 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: use ; include ; $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: use ; 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);