Importing GDS error with Text

edited October 2010 in KLayout Support
Hi,
By opening gds II file klayout makes an error as soon as a text element is present on the file.

The exact error is: XY record expected (position=3679052, record number=287423, cell=Grating2)

The gds II file is readable with the Raith software. The structure was prepared with a python script of my own, but reproducing exactly what the Raith program normally generate. I give you the python function generating the TEXT:

def addText(self, pos, txt, height=None, mag=22.22222, layer=0, width=0, dose=1,angle=0):
# height is given in micron!
if height!=None: mag=height*22.22222
self.addObj('TEXT')
self.addObj('LAYER',layer)
self.addObj('TEXTTYPE',0)
self.addObj('DATATYPE',self.doseEnc(dose))
self.addObj('\x17\x02')
self.addObj('WIDTH',width)
self.addObj('STRANS',0)
if angle!=0: self.addObj('ANGLE',angle*1.0)
self.addObj('MAG',mag)
self.addObj('XY',pos)
self.addObj('ASCII STRING',txt+'\x00')
self.addObj('\x11\x00')

The addObj function add binary data to the gds file where the first argument is the header ASCII (from http://www.rulabinsky.com/cavd/text/chapc.html) and the second argument is the parameter which is automatically converted in binary as the previous link suggest. Everything works fine with the Raith viewer.

This script that mimic what Raith is doing write the binary code \x17\x02 and \x11\x00. I have no idea what they mean, but klayout also crash when I don't include them.

Does anyone have an idea what is the exact problem?

Comments

  • edited October 2010

    Hi scholi,

    I assume the problem is caused by the DATATYPE specification. For TEXT objects, there is no DATATYPE, just TEXTTYPE. I'd suggest to try this:

    def addText(self, pos, txt, height=None, mag=22.22222, layer=0, width=0, dose=1,angle=0):
    # height is given in micron!
    if height!=None: mag=height*22.22222
    self.addObj('TEXT')
    self.addObj('LAYER',layer)
    self.addObj('TEXTTYPE',self.doseEnc(dose))
    # PRESENTATION (should be \x17\x01), this is not correct: self.addObj('\x17\x02')
    self.addObj('WIDTH',width)
    self.addObj('STRANS',0)
    self.addObj('MAG',mag)
    if angle!=0: self.addObj('ANGLE',angle*1.0)
    self.addObj('XY',pos)
    self.addObj('ASCII STRING',txt+'\x00')
    self.addObj('\x11\x00')  # == ENDEL
    

    I'd also suggest to drop the '\0x17\x02' line because it's probably not correct. Please note, that I have swapped ANGLE and MAG because that is suggested order in GDS2. The last line is actually 'ENDEL' but the binary code sequence should work as well.

    I have not tried the code myself (lacking the Raith software), but I follow the specifications available (for example here). KLayout is somewhat picky in order to avoid misinterpretations. Other readers may simply ignore records they can't understand.

    Best regards,

    Matthias

  • edited 7:30PM
    what is the solution for opending GDS2 files when they have been generated by ELPHY from Raith?

    I edit the gds2 file and add your text ?

    thank you

    Klaus
  • edited 7:30PM

    Hi Klaus,

    basically the GDS2 format is well specified in that respect, so I'd say ELPHY does not write a proper GDS file. One soution is to convert the Raith file into correct GDS2 by using a low-level GDS manipulation function, for example implemented with the GDS2 Perl module (http://search.cpan.org/~schumack/GDS2-3.00/lib/GDS2.pm).

    Another solution is to patch KLayouts GDS2 reader so it accepts DATATYPE instead of TEXTTYPE as well.

    Best regards,

    Matthias

Sign In or Register to comment.