# too many hexagons crashes openscad (how many is too many?)

13 messages
Open this post in threaded view
|

## too many hexagons crashes openscad (how many is too many?)

 I am a complete beginner trying to build a somewhat unusual object. I would like to 3D print in metal a thin sheet with 100,000 hexagons on top of it. However, once I go past 20,000 object openscad crashes every time. This is my code so far: union() { cube([600,400,2.5]);     for (x = [2:2:200], // <--- I WANT TO INCREASE THIS VALUE to 600          y = [2:2:200])   // <--- I WANT TO INCREASE THIS VALUE to 400 // ((x/2)%2) to alternate even and odd rows         translate([x,y+1*((x/2)%2),2.5]){             color([0.2,0.8,1])             // rotate([0,0,15*y])             cylinder(\$fn = 6, h = 1, r1 = 1.15, r2 = 1, center = true);         } } Which produces something like this: I may be missing something obvious which makes the code take too much memory.  Is there an alternative, or have I hit the limits?  Otherwise, does it simply seem like a limitation from my computer? Thank you for any guidance. -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: too many hexagons crashes openscad (how many is too many?)

 This works for me as it stays in 2D for the hexagons and also forces to collapse each line into a single internal object with the render() call. This is dropping the slight slanted sides of the hexagons, but I wonder if that would even show up on high resolution printers. cube([600,400,2.5]); color([0.2,0.8,1]) linear_extrude(3.5) {      for (x = [2:2:600]) {          render() for(y = [2:2:400]) {              translate([x,y+1*((x/2)%2),2.5]) {                  circle(\$fn = 6, r = 1, center = true);              }          }      } } ciao,    Torsten. _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org -- Torsten
Open this post in threaded view
|

## Re: too many hexagons crashes openscad (how many is too many?)

Open this post in threaded view
|

## Re: too many hexagons crashes openscad (how many is too many?)

 it shouldn't be to difficult to generate by using a "lazy union" of X*Y hexagon cylinders into a single polyhedron call and union that with the cube. -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: too many hexagons crashes openscad (how many is too many?)

 On 2018-11-01 10:42, Parkinbot wrote: > it shouldn't be to difficult to generate by using a "lazy union" of X*Y > hexagon cylinders into a single polyhedron call and union that with the > cube. The file I linked to contains a single polyhedron in an OpenSCAD .csg file (in addition to the STL). A good first test is to try to open that file in OpenSCAD, but I have not been successful doing that as it consumed all machine resources without finishing. It would surprise me if you could compute it in OpenSCAD (lazy or not), but I am willing to be surprised :-) Carsten Arnholm _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: too many hexagons crashes openscad (how many is too many?)

 Carsten, you might want to increase your CGAL and polyset cache. I screwed mine up to 400MB, which lets me construct even an 600x400 array. The approach is straight forward: calc a single cylinder, file X*Y shifted copies into a list and feed the right parts into a polyhedron. CFG (f5) takes 47s on my notebook, CGAL (f6) needs its time, as we know, about 60 min on my machine. I can export an STL.   X=300; Y=200; c=cyl(); cList = [for(x=[0:X-1], y=[0:Y-1]) shift(c, (x*Y+y)*12, [1+x*2+(y+1)%2*1,1+y*2,2.5])];     polyhedron(filter(cList,0), filter(cList,1)); cube([601,400,2.5]); function cyl(r1=1.15, r2=1,h=1) =    [concat(cyl2(r1), cyl2(r2,h)),  // points     [[5,4,3,2,1,0],[6,7,8,9,10,11], // verts      for(i=[0:5]) [0+i,(1+i)%6,6+(1+i)%6],      for(i=[0:5]) [i,6+(1+i)%6,6+i]]]; // verts         function cyl2(r=1,h=0,n=6) = [for(i=[0:n-1]) r*[sin(i*360/n),cos(i*360/n),h]];     function offs(L, i) = [for(x=L) [for(y=x) y+i]]; function T_(L, v) = [for(p=L) p+v]; function shift(obj, offs=0, t=[0,0,0]) = [T_(obj[0],t), offs(obj[1],offs)]; function filter(L,j) = [for(v=L) for(w=v[j]) w]; -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: too many hexagons crashes openscad (how many is too many?)

 @Torsten, thank you for the suggestion. Your code runs on my machine ... but I have not tried to render it. I'm trying to understand why 2D + extrude has better performance than what I wrote. @Carsten, "must be something important" is kind of relative. It is an art-piece I would like to make which represents (in a more or less abstract way) the columns in the neo-cortex (the outer layer of the brain which has roughly the surface area and width of this sheet). @Parkinbot, thanks for the feedback. Will read up on lazy union, CGAL and polyset cache and will try to understand your script. -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: too many hexagons crashes openscad (how many is too many?)

Open this post in threaded view
|

## Re: too many hexagons crashes openscad (how many is too many?)

Open this post in threaded view
|

## Re: too many hexagons crashes openscad (how many is too many?)

 I did a full run while having breakfast. F6 took 95 minutes. The export produced a 232MB STL and took about 2 minutes to execute. I think you can't get much faster within the scope of current single threaded OpenSCAD. -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: too many hexagons crashes openscad (how many is too many?)

 On 2018-11-02 12:22, Parkinbot wrote: > I did a full run while having breakfast. F6 took 95 minutes. The export > produced a 232MB STL and took about 2 minutes to execute. I think you > can't > get much faster within the scope of current single threaded OpenSCAD. That is a big file. The one I created is 70 MB (binary STL). http://www.fileconvoy.com/dfl.php?id=gf0b9d3183adfc0cd10001262478afc1a139ca26919Carsten Arnholm _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org