Macro Example 5
This example shows the handling of elements or shapes in cells.
Download: Sample5.layout
This examples as well as a LayoutScript version of it is also included in any LayoutEditor package in the folder macros/examples.
1 #!/usr/bin/layout
2 #name=#5: Elements
3 #help=eleminate negative (absolute) width
4
5 int main() {
6 // get first cell
7 cellList *cells=layout->drawing->firstCell;
8
9 // loop over all cells
10 while (cells!=NULL){
11 if (cells->thisCell!=NULL){
12 // get first Element of this cell
13 elementList *l=cells->thisCell->firstElement;
14 cells->thisCell->deselectAll();
15
16 // loop over all elements
17 while (l!=NULL) {
18 if (l->thisElement!=NULL) {
19
20 // if element is a path with a width less than 0
21 if ((l->thisElement->getWidth()< 0) &&
22 l->thisElement->isPath() ){
23
24 // setWidth to zero
25 l->thisElement->setWidth(0);
26
27
28 /* to set to userunits use:
29 l->thisElement->setWidth(60/layout->drawing->userunits);
30 */
31
32 // select this element
33 l->thisElement->selectAll();
34 }
35 if ((l->thisElement->getWidth()< 0) &&
36 l->thisElement->isText() ){
37 l->thisElement->setWidth(-10);
38 }
39 }
40 l=l->nextElement;
41 }
42
43 //round all selected elements
44 cells->thisCell->roundSelect(10);
45 cells->thisCell->deselectAll();
46 }
47 cells=cells->nextCell;
48 }
49 }