the fair gds editor CutCellnamesMacro
Please Sign in

Cut Cellnames Macro

This macro renames any cell to a unique short cellname.

Download: cellnames.layout

   1 #!/usr/bin/layout
   2 #name=#4: cut cellnames
   3 #help=cut cellnames
   4 
   5 int  main() {
   6   layout->drawing->libname="libname";
   7 // get first cell
   8   cellList *cells=layout->drawing->firstCell;
   9  
  10   int num = 0 ;
  11 
  12   // loop over all cells
  13   while (cells!=NULL){  
  14     if (cells->thisCell!=NULL){
  15        
  16        if (cells->thisCell->cellName.length()>1) {
  17           num++;
  18           cells->thisCell->cellName="c"+num;
  19           }
  20     }
  21     cells=cells->nextCell;
  22   }
  23 }

for LayoutScript for Ruby:

   1 #encoding: UTF-8
   2 require 'LayoutScript'
   3 include LayoutScript
   4 
   5 #minimize the length of cell names
   6 l=Project.new_layout()
   7 
   8 
   9 s = Setup.macroDirectory
  10 l.open(s + "/examples/test.gds") 
  11 
  12 cl=l.drawing.firstCell # pointer to current cell
  13 count=0
  14 while (cl!=nil) do  # loop over all cells
  15    c=cl.thisCell
  16    el=c.firstElement
  17    cn=c.cellName
  18    if (cn.length>1) 
  19         count+=1
  20         c.cellName="c"+count.to_s  
  21 
  22    end
  23    cl=cl.nextCell
  24 end
  25 
  26 
  27 
  28 # save to your home folder
  29 l.drawing.save_file("#{Dir.home}/testout.gds")
  30 
  31 puts "Ruby script completed" 

for LayoutScript for Python:

   1 # -*- coding: utf-8 -*-
   2 import LayoutScript
   3 from LayoutScript import *
   4 
   5 #minimize the length of cell names
   6 
   7 l=project.newLayout(); # open new instance of layout class
   8 
   9 SetUp=setup()  # work around as static string variables are not handled correctly
  10 
  11 l.open(SetUp.macroDirectory+"/examples/test.gds") # load example design
  12 
  13 cl=l.drawing.firstCell # pointer to current cell
  14 count=0
  15 while (cl!=None):  # loop over all cells
  16    c=cl.thisCell
  17    el=c.firstElement
  18    cn=c.cellName
  19    if (len(cn)>1):
  20         count+=1
  21         c.cellName="c"+str(count);
  22    cl=cl.nextCell
  23 
  24 
  25 import os
  26 l.drawing.saveFile( os.path.expanduser('~')+"/testout.gds")
  27 
  28 
  29 print ("Python script completed" )

See also


CategoryMacro


CutCellnamesMacro (last edited 2017-05-07 08:33:28 by JurgenThies)