Packing a list of views on to specific range of sheets?

Hi,

I would like know if it’s possible to use any node like the ʳʰʸᵗʰᵐ|GenerativeDesign.PackViewports to place a long list of views onto many sheets?

Basically I have a structured list of interior elevation views that I want to place in consecutive order (by name) onto a specific range of sheets (A800 series). Depending on sheet size and view size, the amount of views on the sheet would change, but stay in consecutive order as much as possible.

Define as much as possible…
Say sheet 3 gets view 8 placed on it, and while views 9-16 don’t fit, view 17 could… would you want 17 on sheet 3 or sheet (after 16)?

Are you really after packing associated views on a sheet, that is “all the elevations associated to room 100 are on sheet 2”, or if all but one are on sheet 2 and the next is on sheet 3 is that ok? What if that one was on sheet 17?

Okay, so the script is used to create interior elevations based on a selection of rooms. The views are created and renamed according to the room they’re located in and given a NSWE bearing in the name too. This allowed me to organize the list of views how ever I want and group the views together based on the room.

So for example, Room A (views 1-4) would be placed on sheet A800. That is only four views so most likely 4-8 more views could fit, so to say. So next, Room B (views 5-8) and Room C (views 9-12) would then be placed on the sheet. If you look at the sheet and read it like a page top left to bottom right it should read views Room A views (1-4), Room B views (5-8), and Room C views (9-12).

So lets say view 4 (of Room A) does not fit on the page for what ever reason. Then, Room B and Room C views would shuffle over/spill over to A801 until view 4 fits. So it might be that only views 11 and 12 move on to their own sheet (A801) Priority is given to keep the group of views (four per room) on the same sheet and in order on the sheet.

When it comes to determining the amount of space on the sheet available for the views, it should be based on a rectangular area established depending on what sheet you select. Additionally, the script works using already created sheets (that are also filtered out and ordered so only the A800 series are sued). I don’t want the script to create sheets. Just views and to place the views onto A800 series.

Hope that makes sense! Thanks!

Just to add:

I have the first half of the script completed (getting the views and sheets), the second half is adding the list of views on to sheets. That all I’m inquiring about at the moment… taking a list of views i have and placing them on a list of sheets i have

here is John’s script for packing views I was trying to use with my script but with couldn’t get it working. It’s a starting point though.
Pack Sheets.dyn (38.3 KB)

What you describe isn’t so much ‘optimizing for fit’ which is what I recall John’s workflow does, but more about placing into a known sequence and order to ensure data is communicated clearly. There are three steps to this: prep the data; group the rows, group the columns.

To start with we’ll prep the data. So what you need to do is pull the bounding box of each view’s crop region, offset that a bit for the boundaries and view title, and then scale that down based on the view’s scale. From the scaled bounding box extract the width and height, and now you have the objects to pack, but they need to be a combination of the width, height, and view - I like to use a dictionary object for each, with a key for width, height, and element. Then pull the ‘open’ space from your title blocks which is the rectangle that you can populate with views - that will become your container. From the container, extract the width and the height and hold them aside for now.

Now you need to iterate your views into rows by grouping them. From the list of view dictionaries extract the widths and perform a mass addition on the resulting data (I like this but if design script for that Math.Sum(List.DropItems(viewsList, -List.Count(viewsList)..-1));). Divide those values by the width of the container (the maximum width of the sheet), and round the value down to the nearest whole number (Math.Floor node). These integers can then be used to group each of the original dictionaries, using a List.GroupByKey node. We now have our rows, with each row being the next which has to be placed, and all views of a room being sequential in each group.

Now we need to place the rows in order, so we take the height of each dictionary in the groups (keeping the level 3 list structure). Take the largest of each sublist (List.MaximumItem node at level 2) and do the same mass addition as before. Divide the sums by the height of the container, and round down again. These resulting integers represent the sheet number which each row wants to be placed on. Group the list of grouped dictionaries using the integer as a key, and suddenly you have groups of groups of dictionaries. If you extract the view and width and height values from the dictionary you can now generate your sheets.

Thanks for the reply. I sort of understand what you’ve recommended but I don’t see how this would solve the issue of views not fitting… which is why I was interested in John’s work flow. That is unless your math formula solves this?

I’ll give this a shot THANKS!