the fair gds editor SpiraleMacro

Spirale Macro

Here a macro which create a multi turn spirale. a other multi turn spirale is also part of the parametric shape library

Download: macrospirale.layout

   1 #!/usr/bin/layout
   2 #name=Multiturn Spiral
   3 #help= mai 30 2008 Serge Charlebois
   4 /*      Creates a new cell and draws a multiturn spiral in it.
   5         The spiral is centered on (0,0).
   6         Requests from the user the number of turns, trace width and spacing and the termination type.
   7         The cell name is forced to "Spiral#" where # is the number of turns.
   8 */
   9 
  10 int main(){
  11 int i, nt, cap;
  12 point origin, start, end;
  13 double step, gap, width, microns;
  14 string cellname;
  15 
  16 microns = 1/layout->drawing->userunits;
  17 origin.setX(0*microns);
  18 origin.setY(0*microns);
  19 
  20 nt = layout->getInteger("User entry","Number of turns for the spiral:");
  21 if (nt==0){
  22         layout->showMessage("Error message","The spiral needs at least 1 turn. Macro aborted.");
  23         return 0;
  24 }       
  25 width = microns * layout->getDouble("User entry","Width of the traces (userunits):");
  26 gap = microns * layout->getDouble("User entry","Distance between traces (userunits):");
  27 cap = layout->getInteger("User entry","Termination type: 0 for none, 1 for circle and 2 for square");
  28 
  29 step = width + gap;
  30 cellname.setNum(nt);
  31 cellname = "Spirale"+cellname;
  32 
  33 // add new empty cell
  34 cellList *cl=layout->drawing->addCell();
  35 // set new cellname
  36 cl->thisCell->cellName = cellname;
  37 // set new cell to current cell
  38 layout->drawing->setCell(cellname);
  39 
  40 
  41 // loop on all sprial turns
  42 i=0;
  43 while (i<nt){
  44 
  45 // calculate start point of one turn
  46 start.set(origin.y(),origin.x() + i*step);
  47 end.set(origin.y(),origin.x() + (i+1)*step);
  48 // calculate end point of one turn
  49 
  50 // create one spiral "turn"
  51 layout->drawing->point(origin);
  52 layout->drawing->point(start);
  53 layout->drawing->point(end);
  54 layout->drawing->spiral();
  55 layout->drawing->currentCell->firstElement->thisElement->setWidth(width); 
  56 layout->drawing->currentCell->firstElement->thisElement->setCap(cap); 
  57 
  58 i++;
  59 }
  60 
  61 // refresh the screen by adjusting the display scale
  62 layout->drawing->scaleFull();
  63 
  64 return 0;
  65 }

See also


CategoryMacro


SpiraleMacro (last edited 2011-02-28 13:52:14 by dslb-092-074-059-143)