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

gdsImport does not support hierarchy #21

Closed tom-varga closed 9 years ago

tom-varga commented 9 years ago

It appears that gdsImport as implemented in gdsCAD doesn't support reading in a gds with hierarchy. In gdspy where it works, I can see that self._incomplete is defined and used within the gdsImport class 4 times. However in gdsCAD, it is defined in the gdsImport function but is attempted to be accessed in two other functions which results in the following error: NameError: global name '_incomplete' is not defined

As a testcase, please try the following slightly edited userguide-20.py example. It simply saves the gds file with hierarchy and then attempts to read it back in.

I'm trying to figure out how to fix the issue, but haven't had luck yet. I hope that somebody could take a look at this further. Thanks, -Tom

from gdsCAD import *

one = shapes.Box((-10,-10), (10,10), 0.5) two = shapes.Rectangle((-10,-10), (0,0), layer=2) three = shapes.Disk((5,5), 5, layer=3)

cell = core.Cell('DEVICE')

cell.add(one) cell.add(two) cell.add(three)

top = core.Cell('TOP')

ref1 = core.CellReference(cell) top.add(ref1)

Translate

ref2 = core.CellReference(cell, origin=(40,0)) top.add(ref2)

Scale and Translate

ref3 = core.CellReference(cell, origin=(0, 40), magnification=1.5) top.add(ref3)

Rotate and Translate

ref4 = core.CellReference(cell, origin=(40,40), rotation=45) top.add(ref4)

top.show()

Add the copied cell to a Layout and save

layout = core.Layout('LIBRARY') layout.add(top) layout.save('userguide-20.gds')

Read the gds with hierarchy back in

layout2 = core.GdsImport('userguide-20.gds')

hohlraum commented 9 years ago

Hi Tom, thanks for the bug report, and thanks for the test case. This goes to show how often (and intensively) I use the import facility. I'll start working on a fix, but it will take a little time.

-AM

tom-varga commented 9 years ago

Thanks Andrew. I really appreciate the help. I'm really looking to use gdsCAD to analyze and munge existing gds files, hence an ability to read in anything that gdsCAD could write out is pretty important. On this same topic, all paths do have a PATHTYPE record too. ie UserWarning: [GDSPY] Record type PATHTYPE not supported by gds_import. I do see that the original gdspy didn't support this record either, although I don't see why that one would be so difficult to add. If it's difficult, reading it in without complaint and allowing only type 0 would be a good start. Would it be possible to communicate with you directly? My email is my full name without the hypthen at gmail. Thanks again, -Tom

hohlraum commented 9 years ago

Commit 89ce443b should (I hope) fix most import problems. Hierarchy is correctly imported and for my (limited) suite of test files import now successfully reproduces the gdsCAD output. PATHTYPE is included too. As I said, I don't use the import function very often, and for only very simple cases, so these problems hadn't come to my attention. If you're going to be doing a lot of importing, it would be great if you could keep up the bug reports telling me where things go wrong.

Thanks,

-AM