I’m trying to solve this problem and i don’t know if it’s a good idea to make it in grasshopper or if I rather should use VBA (excel), or processing, or any other programmation language.
I want to generate a shelf, depending on variable height and width. I want to fill the surface with square of predetermined size : height and width of 1,2,or 3 units (see image below).
The logic i’m thinking of is to first randomly fill the surface with 3x3 square (with a number determined by a percentage of the area of the total surface), then 3x2, then 2x2, … and finally fill the remaining holes by 1x1 square.
This kind of task seems to be more about algorithmic than 3D modeling, is it possible (and smart) to make this in grasshopper ? What about recursion, for(), while, … in grasshopper ? or can I program with an other language and export the data and grasshopper generate the 3D model ?
I have exactly what you want (done for some other purposes using C#). But is a bit “abstract” since returns a Matrix (or a DataTree of type int if you insist) … meaning that I must spend some minutes more to add some visual stuff:
Either Rectangle3d modules sampled in branches (where main dim is the num shown in the Matrix). This could be the demo mode.
Or divide a Surface List in pieces sampled in a Tree .This could be the real thing (rather requires proportional to size divisions in order to get “equal looking modules”, mind [easy]).
Found some 10 minutes more for the matrix to surf division thingy. However that’s far from perfect:
What if you have BrepFaces?
What if you have Lists with things that differ greatly in U/V size ? (meaning that the divisions should be proportional, say, to min U (for some item) and to min V (for some other item).
What if you want the “union” and not the individual pieces sampled in a given branch?
What if you want to “hide the seam” completely? (case closed in U or V).
So I must find some time more (I have already Methods for all the above from other cases) to copy paste some code.
I would use the nesting function of CAM software to do this. As long as you want to apply to flat sheets it would probably do what you want very easily. I use Rhinocam from MecSoft. You can download and try free.
Well … the bad news are that I had plans to do that in w/e … but this w/e is the mother of all things: F1 race in Mexico (where Lewis can win his 5th title). But the altitude (2K m) makes things complicated and tire life is a big issue. Lewis was 8th !!! in Q2 (life sucks).
So nothing from the things promised is done … but IF Lewis wins … you’ll get the hot cakes this Monday.
Anyway get the state of things as they are right now.
NOTE: this is NOT a packing thingy by any means. It just fits randomly regions (with a maxW/H [user controlled]) in some sort of grid [user controlled]. Anyway that’s what the matrix does … then a little translation is required for more pragmatic stuff (Rectangles, Surface pieces etc etc). Pieces are sampled in a tree (obviously) - see the numbers in the matrix (i.e. branches in the tree).
It’s not a big deal, mind (and again: NOT a packager) . But it could be a bit more challenging IF you want to “hide” the seam in surfaces closed in U/V. Plus the matrix solving Method requires some remake for respecting trim (i.e. dividing first the BrepFace, get nulls where required and then marking accordingly the matrix cells ).