the fair gds editor labelArrayMacro

Label Array Macro

This macro create an array of labels with col and row.

Download: label.layout

   1 #!/usr/bin/layout
   2 #name=label macro
   3 #help=automatic labeling 
   4 
   5 
   6 int main(){
   7 int x,y;
   8 for (x=0;x<10;x++){
   9   for (y=0;y<10;y++){
  10         string s1,s2;
  11         s1.setNum(x);
  12         s2.setNum(y);
  13         layout->drawing->point(x*1800,y*800);
  14         layout->drawing->text("#"+s1+"/"+s2);
  15        }
  16 }
  17 layout->drawing->selectAll();
  18 layout->drawing->setWidth(400);
  19 layout->drawing->toPolygon();
  20 layout->drawing->deselectAll();
  21 }

A version for LayoutScript for Ruby:

   1 require 'LayoutScript'
   2 include LayoutScript
   3 
   4 # automatic labeling of an array
   5 
   6 l=Project.new_layout()
   7 
   8 dr=l.drawing # pointer to the main drawing
   9 
  10 dr.currentCell.cellName="ruby_example_label"
  11 
  12 for x in (0..9)
  13         for y in (0..9)
  14                 dr.point(x*1800,y*800)
  15                 dr.text("##{x}/#{y}")
  16         end
  17 end
  18 
  19 dr.select_all()
  20 dr.set_width(400)
  21 dr.to_polygon()
  22 dr.deselect_all();
  23 
  24 # save to your home folder
  25 l.drawing.save_file("#{Dir.home}/testout.gds")
  26 
  27 puts "Ruby script completed" 

A version for LayoutScript for Python:

   1 import LayoutScript
   2 from LayoutScript import *
   3 
   4 # automatic labeling of an array
   5 
   6    
   7 l=project.newLayout(); 
   8 
   9 dr=l.drawing # pointer to the main drawing
  10 
  11 dr.currentCell.cellName="python_example_label"
  12 
  13 dr.clearPoints()
  14 
  15 
  16 
  17 for x in range (0,10):
  18         for y in range (0,10):
  19                 dr.point(x*1800,y*800)
  20                 dr.text("#"+str(x)+"/"+str(y))
  21         
  22 
  23 
  24 dr.selectAll()
  25 dr.setWidth(400)
  26 dr.toPolygon()
  27 dr.deselectAll();
  28 
  29 # writes result to the home folder
  30 
  31 import os
  32 l.drawing.saveFile( os.path.expanduser('~')+"/testout.gds")
  33 
  34 
  35 print ("Python script completed" )

See also


CategoryMacro


labelArrayMacro (last edited 2017-05-07 08:31:19 by JurgenThies)