Miscellany icon indicating copy to clipboard operation
Miscellany copied to clipboard

Could your nodes be used for 2d packing?

Open thomascorrie opened this issue 6 years ago • 6 comments

Could your nodes be used for 2d packing? If the z values were just 0? Wondering if I could then pack rectangles and get there centre points for locations to pack views on sheets. I would be inputting bounding boxes. Not sure what your exact container input formula is that the nodes take. Sorry for the comment in the wrong place. Still understanding git hub and couldn't figure out how else to ask.

I'm not at work to try it with 2d. What node is going into the algorithm inputs? Do you have a YouTube video or some example graphs set up?

Originally posted by @Vanman989 in https://github.com/thomascorrie/Miscellany/issues/1#issuecomment-436485104

thomascorrie avatar Nov 07 '18 12:11 thomascorrie

@Vanman989 yes, the node can be used for 2D packing although I don't know off-hand how optimised it is for 2D because EB-AFIT was originally written for 3D. Feeding 0 for Z for items or containers into the algorithm will fail (something I need to fix in future releases) so I used a value of 1 for items and containers and then ignore Z from the outputs and build rectangles instead of cuboids. I have attached a sample graph to this comment which is adapted from the sample included in the package for ContainerPacking: Miscellany-Samples-PackContainer2D.zip (I had to zip it to add to the comment as GitHub doesn't support adding dyn files to comments). I hope this is of help

pack2d 2dpackinggeometry

thomascorrie avatar Nov 07 '18 12:11 thomascorrie

One additional thing to note is that EB-AFIT will test all possible orientations, so in its current form it isn't possible to restrict the X and Y dimensions to their original axes, which I assume you would want given that you want to use it to place views on sheets (and I assume you don't want them arbitrarily rotated 90 degrees just to fit in)

thomascorrie avatar Nov 07 '18 15:11 thomascorrie

Thanks Thomas, this is great. Yes, unfortunately I would not want the rectangles rotated and positioned top left of the page to start and then along the page, then placed underneath and so on. Thank you for the sample. Missed your original sample you uploaded getting a good understanding of github. I will definitely be testing with your nodes to see what sort of results I can get.

The only solution I can think of to achieve the rectangle stacking I want at the moment is to place the rectangle (view) in the center of a rectangle (sheet) and create some sort of python loop to move the rectangle towards the top left until it clashes with the sheet bounding box. Then proceed with the next. I have very minimal knowledge of python at the moment but hoping I can implement it with some more research into what other nodes are out there.

Vanman989 avatar Nov 08 '18 01:11 Vanman989

As well as in this repository, the samples are included in Miscellany when you install from the Dynamo package manager, within the folder \packages\Miscellany\extra\

An implementation in Python could follow similar lines to this Ruby version. Most implementations seem to follow a tree route.

As for 2D implementation in MIscellany, I can look to add one where it would be possible to choose the starting point and also whether objects are allowed to be rotated. I'm reopening this issue as an enhancement with the aim of adding it soon.

thomascorrie avatar Nov 08 '18 08:11 thomascorrie

Anything you do would be appreciated. Thank you for the great info. Points me in the right direction. I know many people on the dynamo forum struggle with the issue of stacking views like windows, shop drawings, precast and steel onto sheets from a list. I'll be sure to share any of your Miscellany enhancements towards 2D on the dynamo forum.

Your output of unpacked things is great. Can use that to create the next sheet for stacking

Vanman989 avatar Nov 08 '18 19:11 Vanman989

Hi John, if its of any interest to you. This guy has so many great methods to 2D Bin packing :)

https://github.com/juj/RectangleBinPack

Vanman989 avatar Aug 08 '19 21:08 Vanman989