diff --git a/lib.scad b/lib.scad index eab0bac..1e13eaa 100644 --- a/lib.scad +++ b/lib.scad @@ -43,6 +43,7 @@ include include include include +include include include include diff --git a/libtest.png b/libtest.png index c51cd96..e7dfb84 100644 Binary files a/libtest.png and b/libtest.png differ diff --git a/libtest.scad b/libtest.scad index f1a3db3..7f70683 100644 --- a/libtest.scad +++ b/libtest.scad @@ -50,6 +50,7 @@ use use use use +use use use use @@ -271,8 +272,9 @@ translate([x1, leadnuts_y]) leds_y = 0; carriers_y = leds_y + 40; -spades_y = carriers_y + 40; -buttons_y = spades_y + 40; +magnets_y = carriers_y + 40; +spades_y = magnets_y + 20; +buttons_y = spades_y + 20; jacks_y = buttons_y + 40; microswitches_y = jacks_y + 40; rockers_y = microswitches_y + 40; @@ -288,6 +290,9 @@ translate([x2 + 35, leds_y]) translate([x2 + 8, carriers_y]) carriers(); +translate([x2, magnets_y]) + magnets(); + translate([x2 + 20, carriers_y]) led_meters(); diff --git a/readme.md b/readme.md index 4487e20..706bd9a 100644 --- a/readme.md +++ b/readme.md @@ -26,21 +26,21 @@ See [usage](docs/usage.md) for requirements, installation instructions and a usa Bulldogs Leadnuts SK_brackets Door_hinge Hanging_hole Sphere Buttons Light_strips SMDs Door_latch Horiholes Teardrops Cable_strips Linear_bearings SSRs Fan_guard Layout - Cameras Mains_sockets Screws Fixing_block Maths - Circlips Microswitches Sealing_strip Flat_hinge Offset - Components Microview Sheets Foot Quadrant - DIP Modules Spades Handle Round - D_connectors Nuts Spools PCB_mount Rounded_cylinder - Displays O_ring Springs PSU_shroud Rounded_polygon - Extrusion_brackets Opengrab Stepper_motors Printed_box Sector - Extrusions PCB Swiss_clips Ribbon_clamp Sweep - Fans PCBs Toggles SSR_shroud Thread - Fuseholder PSUs Transformers Screw_knob Tube - Geared_steppers Panel_meters Tubings Socket_box - Green_terminals Pillars Variacs Strap_handle - Hot_ends Pin_headers Veroboard - Hygrometer Pulleys Washers - IECs Wire + Cameras Magnets Screws Fixing_block Maths + Circlips Mains_sockets Sealing_strip Flat_hinge Offset + Components Microswitches Sheets Foot Quadrant + DIP Microview Spades Handle Round + D_connectors Modules Spools PCB_mount Rounded_cylinder + Displays Nuts Springs PSU_shroud Rounded_polygon + Extrusion_brackets O_ring Stepper_motors Printed_box Sector + Extrusions Opengrab Swiss_clips Ribbon_clamp Sweep + Fans PCB Toggles SSR_shroud Thread + Fuseholder PCBs Transformers Screw_knob Tube + Geared_steppers PSUs Tubings Socket_box + Green_terminals Panel_meters Variacs Strap_handle + Hot_ends Pillars Veroboard + Hygrometer Pin_headers Washers + IECs Pulleys Wire Inserts Zipties @@ -1676,6 +1676,36 @@ LMnUU linear bearings. | 1 | ```linear_bearing(LM8UU)``` | Linear bearing LM8UU | +Top + +--- + +## Magnets +Cylindrical and ring magnets. + + +[vitamins/magnets.scad](vitamins/magnets.scad) Object definitions. + +[vitamins/magnet.scad](vitamins/magnet.scad) Implementation. + +[tests/magnets.scad](tests/magnets.scad) Code for this example. + +### Properties +| Function | Description | +|:--- |:--- | +| ```magnet_h(type)``` | Height | +| ```magnet_id(type)``` | Inside diameter if a ring | +| ```magnet_od(type)``` | Outer diameter | +| ```magnet_r(type)``` | Corner radius | + +### Modules +| Module | Description | +|:--- |:--- | +| ```magnet(type)``` | Draw specified magnet | + +![magnets](tests/png/magnets.png) + + Top --- diff --git a/tests/magnets.scad b/tests/magnets.scad new file mode 100644 index 0000000..c619b5c --- /dev/null +++ b/tests/magnets.scad @@ -0,0 +1,29 @@ +// +// NopSCADlib Copyright Chris Palmer 2020 +// nop.head@gmail.com +// hydraraptor.blogspot.com +// +// This file is part of NopSCADlib. +// +// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the +// GNU General Public License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along with NopSCADlib. +// If not, see . +// +include <../core.scad> +use <../utils/layout.scad> + +include <../vitamins/magnets.scad> + +module magnets() + layout([for(m = magnets) magnet_od(m)], 5) + magnet(magnets[$i]); + +if($preview) + magnets(); diff --git a/tests/png/magnets.png b/tests/png/magnets.png new file mode 100644 index 0000000..0ef675a Binary files /dev/null and b/tests/png/magnets.png differ diff --git a/vitamins/magnet.scad b/vitamins/magnet.scad new file mode 100644 index 0000000..9659fa8 --- /dev/null +++ b/vitamins/magnet.scad @@ -0,0 +1,49 @@ +// +// NopSCADlib Copyright Chris Palmer 2020 +// nop.head@gmail.com +// hydraraptor.blogspot.com +// +// This file is part of NopSCADlib. +// +// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the +// GNU General Public License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along with NopSCADlib. +// If not, see . +// + +// +//! Cylindrical and ring magnets. +// +include <../utils/core/core.scad> + +function magnet_od(type) = type[1]; //! Outer diameter +function magnet_id(type) = type[2]; //! Inside diameter if a ring +function magnet_h(type) = type[3]; //! Height +function magnet_r(type) = type[4]; //! Corner radius + +module magnet(type) { //! Draw specified magnet + od = magnet_od(type); + id = magnet_id(type); + h = magnet_h(type); + r = magnet_r(type); + + //vitamin(str("magnet(", type[0], "): Magnet ", od, "mm diameter, ", h, "mm high", id ? str(", ", id, "mm bore") : "" )); + + or = od / 2; + ir = id / 2; + color(silver) + rotate_extrude() + union() { + translate([ir, 0]) + rounded_square([or - ir, h], r, center = false); + if(!ir) + square([r, h]); + } + +} diff --git a/vitamins/magnets.scad b/vitamins/magnets.scad new file mode 100644 index 0000000..f2be322 --- /dev/null +++ b/vitamins/magnets.scad @@ -0,0 +1,30 @@ +// +// NopSCADlib Copyright Chris Palmer 2020 +// nop.head@gmail.com +// hydraraptor.blogspot.com +// +// This file is part of NopSCADlib. +// +// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the +// GNU General Public License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along with NopSCADlib. +// If not, see . +// +// +//! Cylindrical and ring magnets. +// + +// od, id, h, r +MAG8x4x4p2 = ["MAG8x4x4p2", 8, 4.2, 4, 0.5]; +MAG484 = ["MAG484", inch(1/4), inch(1/8), inch(1/4), 0.5]; +MAG5x8 = ["MAG484", 8, 0, 5, 0.5]; + +magnets = [MAG8x4x4p2, MAG484, MAG5x8]; + +use