In the beginning we have a certain number of closed figures in one layer - they represent panels of exterior finishing material, usually drawn in 1:10 scaling to the real world. Such panels come in definite size: 3030x455 mm, or it can be 3000x455 mm, the size should be prompted when the macro begins. The panels are cut in length and height and placed onto the building's facades. So our closed figures which are often rectangles can be equal to size of a whole panel, or less than a whole panel.
The task is to create a macro that puts clones of all selected figures of our panel layer into a grid with cells sized like one panel, filling it in such a way that pieces of a panel that can form a whole panel are put in single cell, thus giving us a grid that shows all the panels that are going to be used on the project and how they can be cut to get the custom pieces to put on a certain building. The panels can be cut only perpendicularly in length and height, so if there is a triangle sized for example 1000x455 mm, than a rectangle of this size is cut from a whole panel and then shaped into triangle. If we have two such triangles, we can't get them from a 1000x455 mm rectangle. The panel's upside is different from its downside, resembling parquet which makes them able to actually connect and leave no visible horizontal seams.
The macro also has to put a number of a certain cell on all the original pieces, thus giving the indication of which particular whole panel can be cut to provide a particular piece. Clone of this number goes to each original figure.
So, before the macro's execution we have a layer with cut panels, and after its execution we have a grid in the same layer, with cells of length and height that we command, filled with clones of our original objects and in the layer above there are original numbers on the pieces in the grid and clones of the numbers placed on each original piece of a panel.
After the macro's execution we should be able to customize the numbers on the pieces by manipulating the original ones inside the grid, and customize the clones of pieces inside the grid by manipulating the initial ones that we had in the beginning. This is used to make slight cosmetic changes, no script takes place, and I’m only stating this to explain why we need those certain dependences between the grid items and the items on the facade.
If there are panels of different colors they have to be put into separate grids and each color has its own process with no correlation between the groups. To perform in such a way the macro only applies to previously selected group of objects.
Initially some of our objects can be grouped or joined together, so before doing anything I usually select them all and hit ungroup a couple of times, then join them all into one object with ALT+D and then break it apart with ALT+SHIFT+D. This leads to having only one closed figure to represent each panel piece. This could be also done by the macro.
The whole process is currently implemented by me manually and I can provide a video or a complete .cdr file to clarify details if you have questions.