User LayoutEditorFull Monday 26th August 2019
I want to calculate the area of specific cells and save the value as a text file, by using macro.
Do I have to use shortcut key(Ctrl + 2), and copy to text by hand every time?
Jürgen LayoutEditorFull Monday 26th August 2019
That can be done in a macro. The code will look like:
```cpp
double areaLayer=layout->drawing->currentCell->areaLayer(1);
double areaSelected=layout->drawing->currentCell->areaSelect();
// conversion factor area databseuntis to µm²
double factor=layout->drawing->databaseunits*layout->drawing->databaseunits*1000000*1000000;
string areaLayerString, areaSelectedString;
areaLayerString=areaLayerString.setNum(areaLayer*factor,6) + " µm²";
areaSelectedString=areaSelectedString.setNum(areaSelected*factor,6) + " µm²";
string s="area of layer 1 is "+areaLayerString+"\r\n";
s+="area of selected shapes is "+areaSelectedString+"\r\n";
file f;
f.filename="/home/username/area.txt";
f.open(false); //open for output
f.write(s);
f.close();
```
The feature *selected area* (Ctrl + 2) will display the value on the screen., but did not make it available within the macro. So please the macro command `cell::areaSelect();`.