the fair gds editor CirclesOnCircumference

Circles On Circumference

The macro adds circles around any selected shapes. Radius and distance of the added circles is defined in the macro.

Download: circumference.layout

circles on curcumference

   1 #!/usr/bin/layout
   2 #name=circumference
   3 #help=add circles around the circumference of any selected shape
   4 
   5 int main() {
   6   double step=1000; // distance between circles in database units
   7   double radius=400; // radius in database units
   8   int onLayer=3;
   9   cell *cells=layout->drawing->currentCell;
  10   //convert anything to polygon
  11   cells->toPolygonSelect();
  12   elementList *l=cells->firstElement;
  13   // loop over all elements
  14   while (l!=NULL) {
  15      if (l->thisElement!=NULL) {
  16       if (l->thisElement->isPolygon()&&(l->thisElement->select) ){
  17          //process any selected polygon
  18          pointArray pa=l->thisElement->getPoints();
  19          point last=pa.point(0);
  20          point current;
  21          int k;
  22          double way=0;
  23          //going around the polygon
  24          for (k=1;k<pa.size();k++){
  25           current=pa.point(k);
  26           double length=element::distance(current,last);
  27           // processing one side
  28           while ( length-way >= step){
  29               double pos= (step+way)/length;
  30               double ext = radius/length;
  31               point p=(current-last);
  32               point pc;
  33               pc.setX(pos*p.x()+ext*p.y());
  34               pc.setY(pos*p.y()-ext*p.x());
  35               cells->addCircle(onLayer,last+pc,radius);
  36               way=way+step;
  37           }
  38           //calculation of the remaining way
  39           way=way-length;
  40           last=current;
  41           }
  42       }}
  43       l=l->nextElement;
  44   }
  45 }

See also


CategoryMacro


CirclesOnCircumference (last edited 2011-11-25 18:05:28 by dslb-088-065-253-206)