From a95c75faeaf31cb907ca451201e387f966ae4b69 Mon Sep 17 00:00:00 2001 From: Elmom Date: Sat, 8 Jan 2011 11:46:57 +0200 Subject: [PATCH 01/14] Fixed a missing argument, tests for it, and made the API saner --- shapes.scad | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/shapes.scad b/shapes.scad index bd10730..047a38f 100644 --- a/shapes.scad +++ b/shapes.scad @@ -13,7 +13,7 @@ //roundedBox(width, height, depth, factor); //cone(height, radius); //ellipticalCylinder(width, height, depth); -//ellipsoid(width, height); +//ellipsoid(width, height); //tube(height, radius, wall); //ovalTube(width, height, depth, wall); //hexagon(height, depth); @@ -49,12 +49,12 @@ module ellipticalCylinder(w,h, height, center = false) { scale([1, h/w, 1]) cylinder(h=height, r=w, center=center); } -module ellipse(w, h) { - scale([1, h/w, 1]) circle(r=w, center=center); +module ellipse(w, h, center = false) { + scale([1, h/w, 1]) circle(r=w/2, center=center); } -module ellipsoid(w, h) { - scale([1, h/w, 1]) sphere(r=w, center=center); +module ellipsoid(w, h, center = false) { + scale([1, h/w, 1]) sphere(r=w/2, center=center); } // wall is wall thickness @@ -137,4 +137,9 @@ module 12ptStar(size, height) { //MOVES THE ROTATION AXIS OF A BOX FROM ITS CENTER TO THE BOTTOM LEFT CORNER module dislocateBox(w, h, d) { translate([0,0,-d/2]) cube([w,h,d]); -} \ No newline at end of file +} + +//----------------------- +// Tests +//module test2D_ellipse(){ellipse(10, 5);} +module test_ellipsoid(){ellipsoid(10, 5);} From 8d0d254eb538a74a05a13d1e99ddd41b208132e1 Mon Sep 17 00:00:00 2001 From: Elmom Date: Sat, 8 Jan 2011 12:27:28 +0200 Subject: [PATCH 02/14] Added an egg outline --- shapes.scad | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/shapes.scad b/shapes.scad index 047a38f..d41ba83 100644 --- a/shapes.scad +++ b/shapes.scad @@ -57,6 +57,16 @@ module ellipsoid(w, h, center = false) { scale([1, h/w, 1]) sphere(r=w/2, center=center); } +module egg_outline(width=5, length=7){ + union(){ + difference(){ + ellipse(width, 2*length-width, center=true); + translate([0, length/2, 0]) square(length, width, center=true); + } + circle(r=width/2, center=true); + } +} + // wall is wall thickness module tube(height, radius, wall, center = false) { difference() { @@ -143,3 +153,5 @@ module dislocateBox(w, h, d) { // Tests //module test2D_ellipse(){ellipse(10, 5);} module test_ellipsoid(){ellipsoid(10, 5);} + +//module test2D_egg_outline(){egg_outline();} From 3cc3b882ee477397a752433dc56d5615e034e5b3 Mon Sep 17 00:00:00 2001 From: Elmom Date: Sat, 8 Jan 2011 12:45:14 +0200 Subject: [PATCH 03/14] Fixed an insignificant typo --- shapes.scad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shapes.scad b/shapes.scad index d41ba83..8992543 100644 --- a/shapes.scad +++ b/shapes.scad @@ -61,7 +61,7 @@ module egg_outline(width=5, length=7){ union(){ difference(){ ellipse(width, 2*length-width, center=true); - translate([0, length/2, 0]) square(length, width, center=true); + translate([0, length/2, 0]) square(length, center=true); } circle(r=width/2, center=true); } From 25b184e25244cf94cbac6a4cea74df31bef740e1 Mon Sep 17 00:00:00 2001 From: Elmom Date: Sat, 8 Jan 2011 12:46:48 +0200 Subject: [PATCH 04/14] Added a doc line about the egg_outline module --- shapes.scad | 1 + 1 file changed, 1 insertion(+) diff --git a/shapes.scad b/shapes.scad index 8992543..cb4c6a6 100644 --- a/shapes.scad +++ b/shapes.scad @@ -7,6 +7,7 @@ // 2D Shapes //ellipse(width, height); +//egg_outline(width=5, length=7); // 3D Shapes //box(width, height, depth); From 50e821e4a39c0f4cb6aa87b3883956be334b22bb Mon Sep 17 00:00:00 2001 From: Elmom Date: Sat, 8 Jan 2011 13:32:58 +0200 Subject: [PATCH 05/14] Fixed the API of box and roundedBox --- shapes.scad | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shapes.scad b/shapes.scad index cb4c6a6..dfd3af1 100644 --- a/shapes.scad +++ b/shapes.scad @@ -28,12 +28,13 @@ //---------------------- // size is a vector [w, h, d] -module box(size) { - cube(size, true); +module box(width, height, depth,) { + cube([width, height, depth,], true); } // size is a vector [w, h, d] -module roundedBox(size, radius) { +module roundedBox(width, height, depth, radius) { + size=[width, height, depth,] cube(size - [2*radius,0,0], true); cube(size - [0,2*radius,0], true); for (x = [radius-size[0]/2, -radius+size[0]/2], From d21103e652d213b3b3da0c880fa0a97136b98bd1 Mon Sep 17 00:00:00 2001 From: Elmom Date: Sat, 8 Jan 2011 13:35:24 +0200 Subject: [PATCH 06/14] Fixed the previous fix :) --- shapes.scad | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shapes.scad b/shapes.scad index dfd3af1..b4b1ea7 100644 --- a/shapes.scad +++ b/shapes.scad @@ -1,6 +1,7 @@ /* * OpenSCAD Shapes Library (www.openscad.org) * Copyright (C) 2009 Catarina Mota + * Copyright (C) 2010 Elmo Mäntynen * * License: LGPL 2.1 or later */ @@ -34,7 +35,7 @@ module box(width, height, depth,) { // size is a vector [w, h, d] module roundedBox(width, height, depth, radius) { - size=[width, height, depth,] + size=[width, height, depth,]; cube(size - [2*radius,0,0], true); cube(size - [0,2*radius,0], true); for (x = [radius-size[0]/2, -radius+size[0]/2], From 868730fec75d5f3871eb02644f1b489d0cae026f Mon Sep 17 00:00:00 2001 From: Elmom Date: Sat, 8 Jan 2011 15:37:56 +0200 Subject: [PATCH 07/14] Added a general ngon and improved some api docs --- shapes.scad | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/shapes.scad b/shapes.scad index b4b1ea7..ae8eac6 100644 --- a/shapes.scad +++ b/shapes.scad @@ -9,6 +9,7 @@ // 2D Shapes //ellipse(width, height); //egg_outline(width=5, length=7); +//ngon(sides, radius, center=false); // 3D Shapes //box(width, height, depth); @@ -16,8 +17,9 @@ //cone(height, radius); //ellipticalCylinder(width, height, depth); //ellipsoid(width, height); -//tube(height, radius, wall); -//ovalTube(width, height, depth, wall); +//tube(height, radius, wall, center = false); +//tube2(height, ID, OD, center = false); +//ovalTube(width, height, depth, wall, center = false); //hexagon(height, depth); //octagon(height, depth); //dodecagon(height, depth); @@ -78,6 +80,14 @@ module tube(height, radius, wall, center = false) { } } +// wall is wall thickness +module tube2(height, ID, OD, center = false) { + difference() { + cylinder(h=height, r=OD/2, center=center); + cylinder(h=height, r=ID/2, center=center); + } +} + // wall is wall thickness module ovalTube(height, rx, ry, wall, center = false) { difference() { @@ -86,6 +96,11 @@ module ovalTube(height, rx, ry, wall, center = false) { } } +// The orientation might change with the implementation of circle... +module ngon(sides, radius, center=false){ + rotate([0, 0, 360/sides/2]) circle(r=radius, $fn=sides, center=center); +} + // size is the XY plane size, height in Z module hexagon(size, height) { boxWidth = size/1.75; From fbe7cd6162aeb721f0fa3c01ce8a78719622340f Mon Sep 17 00:00:00 2001 From: Elmom Date: Wed, 12 Jan 2011 14:13:28 +0200 Subject: [PATCH 08/14] Changed README to markup and added a 'StillMaintained?' button --- README.markup | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 README.markup diff --git a/README.markup b/README.markup new file mode 100644 index 0000000..f94d8ae --- /dev/null +++ b/README.markup @@ -0,0 +1,86 @@ +OpenSCAD MCAD Library [![](http://stillmaintained.com/user/project.png)](http://stillmaintained.com/user/project) +===================== + +This library contains components commonly used in designing and moching up +mechanical designs. It is currently unfinished and you can expect some API +changes, however many things are already working. + +This library is licensed under the LGPL 2.1 +See http://creativecommons.org/licenses/LGPL/2.1/ or the included file, lgpl-2.1.txt. + +## Usage ## + +You can import these files in your scripts with "use ", but some +files include useful constants which will be 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: + +* involute_gears.scad (http://www.thingiverse.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) + +Other 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 + +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 (http://www.thingiverse.com/thing:3457): parametric teardrop module +* shapes.scad: simple shapes by Catarina Mota + +External utils that generate and and process openscad code: +* openscad_testing.py: testing code, see below +* openscad_utils.py: code for scraping function names etc. + +## Development ## + +You are welcome to fork this project in github and request pulls. I will try to +accomodate the community as much as possible in this. If for some reason you +want collaborator access, just ask. + +Github is fun (and easy), but I can include code submissions and other +improvements directly, and have already included code from various sources +(thingiverse is great :) + +### Code style ### +I'd prefer to have all included code nicely indented, at least at the block +level, and no extraneous whitespace. I'm used to indent with four spaces as +opposed to tabs or other mixes of whitespace, but at least try to choose a style +and stick to it. + +### Testing ### +I've started a minimal testing infrastucture for OpenSCAD code. It's written in +python and uses py.test (might be compatible with Nose also). Just type py.test +inside the lib dir in a terminal and you should see a part of the tests passing +and tracebacks for failing tests. It's very simplistic still, but it should test +that no syntax errors occur at least. + +The code is included in openscad_testing.py, and can be imported to be +used in other codebases. From 5fbe970f59cd12ebc5fe5c3eae92c06a1ad1e54d Mon Sep 17 00:00:00 2001 From: Elmom Date: Wed, 12 Jan 2011 14:16:00 +0200 Subject: [PATCH 09/14] Forgot to remove the old README --- README | 84 ---------------------------------------------------------- 1 file changed, 84 deletions(-) delete mode 100644 README diff --git a/README b/README deleted file mode 100644 index 7f5e503..0000000 --- a/README +++ /dev/null @@ -1,84 +0,0 @@ -OpenSCAD MCAD Library -===================== - -This library contains components commonly used in designing and moching up -mechanical designs. It is currently unfinished and you can expect some API -changes, however many things are already working. - -This library is licensed under the LGPL 2.1 -See http://creativecommons.org/licenses/LGPL/2.1/ or the included file, lgpl-2.1.txt. - -== Usage == -You can import these files in your scripts with "use ", but some -files include useful constants which will be 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: - -* involute_gears.scad (http://www.thingiverse.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) - -Other 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 - -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 (http://www.thingiverse.com/thing:3457): parametric teardrop module -* shapes.scad: simple shapes by Catarina Mota - -External utils that generate and and process openscad code: -* openscad_testing.py: testing code, see below -* openscad_utils.py: code for scraping function names etc. - -== Development == -You are welcome to fork this project in github and request pulls. I will try to -accomodate the community as much as possible in this. If for some reason you -want collaborator access, just ask. - -Github is fun (and easy), but I can include code submissions and other -improvements directly, and have already included code from various sources -(thingiverse is great :) - -=== Code style === -I'd prefer to have all included code nicely indented, at least at the block -level, and no extraneous whitespace. I'm used to indent with four spaces as -opposed to tabs or other mixes of whitespace, but at least try to choose a style -and stick to it. - -=== Testing === -I've started a minimal testing infrastucture for OpenSCAD code. It's written in -python and uses py.test (might be compatible with Nose also). Just type py.test -inside the lib dir in a terminal and you should see a part of the tests passing -and tracebacks for failing tests. It's very simplistic still, but it should test -that no syntax errors occur at least. - -The code is included in openscad_testing.py, and can be imported to be -used in other codebases. From 19657b67e836aa613eb37e3def21c042b8e18d1d Mon Sep 17 00:00:00 2001 From: Elmom Date: Wed, 12 Jan 2011 14:18:28 +0200 Subject: [PATCH 10/14] Now to name it so that github reconises it actually :) --- README.markup => README.markdown | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README.markup => README.markdown (100%) diff --git a/README.markup b/README.markdown similarity index 100% rename from README.markup rename to README.markdown From a9616c7fdf2a58ccd31fbc157500a8c4c3c7fcbb Mon Sep 17 00:00:00 2001 From: Elmom Date: Wed, 12 Jan 2011 14:20:27 +0200 Subject: [PATCH 11/14] Forgot to add the project name to the StillMaintaned? links. --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index f94d8ae..562273a 100644 --- a/README.markdown +++ b/README.markdown @@ -1,4 +1,4 @@ -OpenSCAD MCAD Library [![](http://stillmaintained.com/user/project.png)](http://stillmaintained.com/user/project) +OpenSCAD MCAD Library [![](http://stillmaintained.com/elmom/MCAD.png)](http://stillmaintained.com/elmom/MCAD) ===================== This library contains components commonly used in designing and moching up From 006508acded63b4d8238eed0900ec4406eabf147 Mon Sep 17 00:00:00 2001 From: Elmom Date: Wed, 12 Jan 2011 14:28:23 +0200 Subject: [PATCH 12/14] Now actually convert the syntax to markdown :) --- README.markdown | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.markdown b/README.markdown index 562273a..a34b749 100644 --- a/README.markdown +++ b/README.markdown @@ -10,31 +10,31 @@ See http://creativecommons.org/licenses/LGPL/2.1/ or the included file, lgpl-2.1 ## Usage ## -You can import these files in your scripts with "use ", but some -files include useful constants which will be available with "include ", +You can import these files in your scripts with `use `, but some +files include useful constants which will be 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 +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. +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: * involute_gears.scad (http://www.thingiverse.com/thing:3575): - - gear() - - bevel_gear() - - bevel_gear_pair() +** gear() +** bevel_gear() +** bevel_gear_pair() * gears.scad (Old version): - - gear(number_of_teeth, circular_pitch OR diametrial_pitch, pressure_angle OPTIONAL, clearance OPTIONAL) +** 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) +** stepper_motor_mount(nema_standard, slide_distance OPTIONAL, mochup OPTIONAL) Other tools (alpha and beta quality): * nuts_and_bolts.scad: for creating metric and imperial bolt/nut holes @@ -77,7 +77,7 @@ and stick to it. ### Testing ### I've started a minimal testing infrastucture for OpenSCAD code. It's written in -python and uses py.test (might be compatible with Nose also). Just type py.test +python and uses py.test (might be compatible with Nose also). Just type `py.test` inside the lib dir in a terminal and you should see a part of the tests passing and tracebacks for failing tests. It's very simplistic still, but it should test that no syntax errors occur at least. From 69bffb03974f4b52340c72a31008c9367044316c Mon Sep 17 00:00:00 2001 From: Elmom Date: Wed, 12 Jan 2011 14:33:04 +0200 Subject: [PATCH 13/14] And undo some :) --- README.markdown | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.markdown b/README.markdown index a34b749..a825b65 100644 --- a/README.markdown +++ b/README.markdown @@ -26,15 +26,15 @@ do `cd PATH; git checkout master; git pull`. See `git help submodule` for more i Currently Provided Tools: * involute_gears.scad (http://www.thingiverse.com/thing:3575): -** gear() -** bevel_gear() -** bevel_gear_pair() + - gear() + - bevel_gear() + - bevel_gear_pair() * gears.scad (Old version): -** gear(number_of_teeth, circular_pitch OR diametrial_pitch, pressure_angle OPTIONAL, clearance OPTIONAL) + - 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) + - stepper_motor_mount(nema_standard, slide_distance OPTIONAL, mochup OPTIONAL) Other tools (alpha and beta quality): * nuts_and_bolts.scad: for creating metric and imperial bolt/nut holes From 6fbb27cca0cbce394310c3f865ef4e9bd43d5f3f Mon Sep 17 00:00:00 2001 From: Elmom Date: Wed, 12 Jan 2011 14:35:18 +0200 Subject: [PATCH 14/14] Maybe this is enough... --- README.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.markdown b/README.markdown index a825b65..b83c415 100644 --- a/README.markdown +++ b/README.markdown @@ -37,6 +37,7 @@ Currently Provided Tools: - stepper_motor_mount(nema_standard, slide_distance OPTIONAL, mochup OPTIONAL) Other 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 @@ -47,6 +48,7 @@ Other tools (alpha and beta quality): * triangles.scad: simple triangles Very generally useful functions and constants: + * math.scad: general math functions * constants.scad: mathematical constants * curves.scad: mathematical functions defining curves @@ -56,6 +58,7 @@ Very generally useful functions and constants: * shapes.scad: simple shapes by Catarina Mota External utils that generate and and process openscad code: + * openscad_testing.py: testing code, see below * openscad_utils.py: code for scraping function names etc.