Break a Layout into Tiles
The macro will split a desing into an array of small files like tiles on a wall.
Download: tiles-macro.layout
1 #!/usr/bin/layout
2 #name=tile a layout
3 #help=breaks a layout into tiles
4
5
6 int main(){
7 file f;
8
9 // enter your parameter here:
10 int nx=10;
11 int ny=10;
12 string outPath=f.homePath();
13 string baseName="layoutTile";
14 string tempFile=f.tempPath()+"/tempLayout.gds.gz";
15 // end of parameter entry
16
17 layout->drawing->saveFile(tempFile);
18
19 point pmax,pmin;
20 pmax.set(-1000000000,-1000000000);
21 pmin.set(1000000000,1000000000);
22 layout->drawing->currentCell->maximum(&pmax);
23 layout->drawing->currentCell->minimum(&pmin);
24 int stepX=(pmax.x()-pmin.x())/nx+1;
25 int stepY=(pmax.y()-pmin.y())/ny+1;
26
27 int x,y;
28 int layerbackup=layout->drawing->activeLayer;
29 layout->drawing->activeLayer=999;
30 layout->drawing->currentCell->deselectAll();
31 string sx,sy;
32 for (x=0;x<nx;x++) {
33 for (y=0;y<ny;y++){
34 sx.setNum(x);
35 sy.setNum(y);
36 layout->drawing->point(pmin.x()+x*stepX,pmin.y()+y*stepY);
37 layout->drawing->point(pmin.x()+(x+1)*stepX,pmin.y()+(y+1)*stepY);
38 layout->drawing->box();
39 layout->drawing->currentCell->selectLayer(999);
40 layout->drawing->currentCell->cropWithSelection();
41 layout->drawing->stripUnneeded();
42 layout->drawing->saveFile(outPath+"/"+baseName+sx+"_"+sy+".gds");
43 layout->drawing->openFile(tempFile);
44 }
45 }
46
47 layout->drawing->activeLayer=layerbackup;
48 layout->drawing->openFile(tempFile);
49 }