<-- back to the index of scripting examples

Zillion(): create a lot of copies

Create a lot of copies of the selection in a matrix groeing right and up next to the selection.
Example implementation
zillion.fawk
Explanation, step by step
Create a lot of copies of the selection in a matrix groeing right and up next to the selection.

The action runs a query() to find all first-level selected objects and calculate their bounding box union. This is the smallest boxaround all selected objects. This needs to deal with first-levle objects only: objects on deeper level (e.g. within symbols or wirenets) are specified relative to their parent which would result in low coordinates; these objects are also calculated in the parent group's bbox so it is enough to deal with the parent (top level) groups.

Using the bbox an origin ("grab point") and an offset (dx, dy) are caclulated, all rounded to 4k grid. Then a loop copies selection to a nx * ny matrix starting from the original selection. Copies are placed n*dx and n*dy away, so there is no overlap with the original selection.

If the user did not specify nx and ny as parameters, a modal dialog box is popped up so these values an be specified. The dialog box doesn't permit setting the matrix to 1x1, in such case one of the sizes is increased to 2.

How to test: