hohlraum / gdsCAD

A simple but powerful Python package for creating photolithography masks in the GDSII format.
GNU General Public License v3.0
88 stars 52 forks source link

core.Layout.save(layout,outfile) not working #42

Closed muab closed 8 years ago

muab commented 8 years ago

After importing the layout, when trying to save the same file to an output file, it will give the following error: imported correctly Writing the following cells IGA_SQ_AI_124_A: Cell ("IGA_SQ_AI_124_A", 1911170 elements, 0 references) Traceback (most recent call last): File "gds_tests.py", line 13, in core.Layout.save(amarks, myoutfile) File "/usr/local/lib/python2.7/dist-packages/gdsCAD-0.5.0-py2.7.egg/gdsCAD/core.py", line 1325, in save outfile.write(cell.to_gds(self.unit / self.precision, duplicates)) File "/usr/local/lib/python2.7/dist-packages/gdsCAD-0.5.0-py2.7.egg/gdsCAD/core.py", line 1491, in to_gds data += element.to_gds(multiplier) File "/usr/local/lib/python2.7/dist-packages/gdsCAD-0.5.0-py2.7.egg/gdsCAD/core.py", line 736, in to_gds return data + struct.pack('>2h2l2h', 12, 0x1003, int(round(self.points[0] * multiplier)), int(round(self.points[1] * multiplier)), 4 + len(text), 0x1906) + text.encode('ascii') + struct.pack('>2h', 4, 0x1100) struct.error: 'l' format requires -2147483648 <= number <= 2147483647

is it a float problem in the original gds?

muab commented 8 years ago

after a successful import, the saving doesn't work without making any changes to the gds. a hierarchical gds will fail in line 1857, while a flat one will fail in 736.

import correctly Writing the following cells IGA_AI_124_A_PR_childs: Cell ("IGA_AI_124_A_PR_childs", 0 elements, 3 references) WIRE_CELL: Cell ("WIRE_CELL", 31302 elements, 0 references) inter_otft_AI_v_w65_l6_nf5: Cell ("inter_otft_AI_v_w65_l6_nf5", 602 elements, 0 references) pad_iga_matrix: Cell ("pad_iga_matrix", 87264 elements, 42 references) IGA_SAMPLE: Cell ("IGA_SAMPLE", 8 elements, 100 references) PAD_IGA: Cell ("PAD_IGA", 404 elements, 0 references) SQ_OTFT_AI_124_A: Cell ("SQ_OTFT_AI_124_A", 0 elements, 126 references) inter_otft_AI_v_w40_l6_nf4: Cell ("inter_otft_AI_v_w40_l6_nf4", 1075 elements, 0 references) VERTICAL: Cell ("VERTICAL", 4071 elements, 0 references) IGA_PAS1: Cell ("IGA_PAS1", 504 elements, 0 references) inter_otft_AI_v_w80_l6_nf8: Cell ("inter_otft_AI_v_w80_l6_nf8", 1388 elements, 0 references) Traceback (most recent call last): File "gdsCAD_tests.py", line 31, in prt = core.Layout.save(importedgds, 'gdsCAD_outfile.gds') File "C:\Python27\lib\site-packages\gdscad-0.5.0-py2.7.egg\gdsCAD\core.py", line 1325, in save outfile.write(cell.to_gds(self.unit / self.precision, duplicates)) File "C:\Python27\lib\site-packages\gdscad-0.5.0-py2.7.egg\gdsCAD\core.py", line 1489, in to_gds data += element.to_gds(multiplier, duplicates) File "C:\Python27\lib\site-packages\gdscad-0.5.0-py2.7.egg\gdsCAD\core.py", line 1857, in to_gds return data + struct.pack('>2h2l2h', 12, 0x1003, int(round(self.origin[0] * multiplier)), int(round(self.origin[1] * multiplier)), 4, 0x1100) struct.error: integer out of range for 'l' format code

muab commented 8 years ago

also a different error is that if the gds has no text layout objects at all, core.Layout.save(layout,outfile) will fail in line 723 (core.py), since len(text) won't work when text is trying to be substituted by object 'NoneType'.

muab commented 8 years ago

The last commented error was due to a gds layout that had undesired empty text elements inserted by the layout tool. Once eliminated the errors in the gds then core.Layout.save(layout,outfile) worked fine. The other error was also related to the exporting of the gds by the layout tool. This was saving the date data incorrectly (out of range). I used another tool for exporting the gds and again it worked fine.