the fair gds editor ReadCircleFromFile
Please Sign in

Read Circle Coordinates from a Text File

circles The macro will read center coordinates, radius and layer information for circles from a text file and generates the layout from it. The text file must be named 'circles.txt' and store in the same folder than the macro file.

Download: circles.layout

Text File with Circle Coordinates

#format:
#x,y,radius,layer

10.0,20.0,5.3,7 
14.0,25.0,2.3,5
4.0,5.0,2.3,2
10.0,-25.0,5.3,1
-14.0,25.0,2.3,15
-4.0,-5.0,2.3

LayoutEditor Macro

   1 #!/usr/bin/layout
   2 #name=read circles from file
   3 #help=reads and create circle from a file
   4 
   5 
   6 int main(){
   7   file f;
   8   f.filename="circles.txt";
   9   bool b=true;
  10   f.open(b);
  11   string s=f.read();
  12   f.close();
  13   stringList sl=s.split("\n");
  14   int i,k;
  15   layout->drawing->clearPoints();
  16   for(i=0;i<sl.size();i++){
  17     if (sl.at(i).left(1)!="#"){
  18       stringList sl2=sl.at(i).split(",");
  19       if (sl2.size()>=3){
  20         double x=sl2.at(0).toDouble();
  21         double y=sl2.at(1).toDouble();
  22         double r=sl2.at(2).toDouble();
  23         int layer=1;
  24         if (sl2.size()>3) layer=sl2.at(3).toInt();
  25         layout->drawing->activeLayer=layer;
  26         layout->drawing->p(x,y);
  27         layout->drawing->p(x,y+r);
  28         layout->drawing->circle();
  29       }
  30     }
  31   }
  32   layout->drawing->scaleFull();
  33 }

See also


CategoryMacro


ReadCircleFromFile (last edited 2011-05-25 16:26:28 by dslb-088-065-045-237)