Please visit http://OpenSCAD.DIY3DTech.com for more information on this and many other projects! As in this episode we will be taking a look at a utility I developed in Open-SCAD for generating various sizes of pegboards and yes pegs. The idea is wanted as utility that could create both so I could import the result into other projects. Also while I have uploaded this to thingiverse, Customizer seems to be having an issue with the double “if” statements in the code logic.
For more information as well as the complete source code, please visit http://openscad.diy3dtech.com/pegboard-and-holes-utility/
Pegboard and Holes Utility!
https://www.thingiverse.com/thing:2459745
If your looking for looking 3D Printer, Laser Cutter and CNC Swag (T-Shirts, Hats, Mugs, etc), please support the channel by visiting our online shop at: http://swag.DIY3DTech.com
Also subscribe to our parent YouTube Channel DIY3DTech.com YouTube Channel for 3D Printing, Laser Manufacturing and CNC Machining: http://YouTube.DIY3DTech.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
/* Open SCAD Name.: PegboardandHoles_v2.scad * Copyright (c)..: 2017 www.DIY3DTech.com * * Creation Date..: July-2017 * Description....: Code to create pegboard or pegboard holes * * Rev 1: Develop Model * Rev 2: * * This program 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 2 of the License, or * (at your option) any later version. * * This program 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. */ /*------------------Customizer View-------------------*/ // preview[view:north, tilt:top] /*---------------------Parameters---------------------*/ //board width in mm board_width = 90; //[1:1:500] //board height in mm board_height = 90; //[1:1:500] //board thickness in mm board_thick = 3; //[1:0.5:10] //hole offset (1 inch or 25.6mm is standard) hole_offset = 25.60; //hole diamiter (standard is 1/4 inch or 6.25mm) hole_dia = 6.25; //[5:0.25:8] //Peg height for export hole_height = 6.0; //[1:1:30] //chamfer of of the board corners (will add to width) chamfer = 3; //[1:0.5:5] //Pegboard = 1 Pegs Only = 0 type = 1; //[0:1:1] /*-----------------------Execute----------------------*/ main_module(); /*-----------------------Modules----------------------*/ module main_module(){ //create module difference() { union() {//start union if (type ==1) { //create pegboard if type == 1 translate ([((board_width/2)-((board_width-(round((board_width-(hole_offset-(hole_dia/2)))/hole_offset))*hole_offset)/2)),((board_height/2)-((board_height-(round((board_height-(hole_offset-(hole_dia/2)))/hole_offset))*hole_offset)/2)),0]) rotate ([0,0,0]) rounded(board_width,board_height,board_thick,chamfer,true); }else{ //create pegs if type == 0 for (i=[0:round((board_width-(hole_offset-(hole_dia/2)))/ hole_offset)]) for (j=[0:round((board_height-(hole_offset-(hole_dia/2)))/ hole_offset)])translate ([i*hole_offset,j*hole_offset,0]) rotate ([0,0,0]) cylinder(hole_height,hole_dia/2,hole_dia/2,$fn=60,true); }; //end if union if staement } //end union //start subtraction of difference if (type ==1) { //create holes in pegboard if type == 1 for (i=[0:round((board_width-hole_offset)/ hole_offset)]) for (j=[0:round((board_height-hole_offset)/ hole_offset)]) {translate ([i*hole_offset,j*hole_offset,0]) rotate ([0,0,0]) cylinder(hole_height,hole_dia/2,hole_dia/2,$fn=60,true); } } else{ }; //end of diff if statement } //end difference }//end module module rounded(x,y,z,c,center) { // c = Chamfer amount this will add (in mm) to each axis //create overlapping cubes //cube one overlapps in the X axis with chamfer "c" being doubled cube ([x+(c*2),y,z],true); //cube two overlapps in the Y axis with chamfer "c" being doubled cube ([x,y+(c*2),z],true); //end overlapping cubes //create corner circles translate ([-(x/2),-(y/2),0]) { cylinder( z,c,c,$fn=60,true); } translate ([-(x/2),(y/2),0]) { cylinder( z,c,c,$fn=60,true); } translate ([(x/2),-(y/2),0]) { cylinder( z,c,c,$fn=60,true); } translate ([(x/2),(y/2),0]) { cylinder( z,c,c,$fn=60,true); } //end coner circle } //end module /*----------------------End Code----------------------*/ |
More Ideas!
OpenSCAD – Designing a Compression Cover!
OpenSCAD – Designing a Pressure Fit Endcap!
Open SCAD – Complex Flange Designer!