Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*******MODULE TO GENERATE A GRID**************
- * num = Number of points for the grid, it will generate a
- * matrix[num][num]
- * space = space between points
- * elem = within showGrid() you can create the shape for the
- * dots to be shown in the grid.
- * zAxis = grid will move this value along the z Axis
- * */
- module showGrid(num=10, space=10, elem=0,zAxis=0){
- grid(num, space, elem, zAxis) {
- color("plum")sphere(.4); //child(0)
- color("OrangeRed")cube(.1,center=true); //child(1)
- color("Lime")cylinder(h = .1, r=.1,$fn=28); //child(2)
- }
- }
- module grid(num, space, elem, zAxis) {
- translate([-space*(num-1)/2,-space*(num-1)/2, zAxis])
- for (i = [0 : num-1])
- for (j = [0 : num-1])
- translate([ space*i, space*j, zAxis ]) child(elem);
- //origin, comment if not needed
- translate([0,0,0])child(elem);
- }
- //dummy value
- gap = 10;
- /* Example1: GRID WITH DEFAULT SETTINGS*/
- *showGrid();
- /* Example2: GRID WITH A GAP SPACE USING ELEM(1) */
- //dummy height
- myHeight =5;
- *showGrid(space=gap, elem=1,zAxis=-myHeight/2);
- /* Example3: MOVE GRID ON Z AXIS USING ELEM(2) */
- *showGrid(elem=2,zAxis=myHeight/2);
- //dummy shape
- translate([gap*2,0,0])
- cube(10,center= true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement