It looks like you're new here. If you want to get involved, click one of these buttons!
Hello Matthias, Thank you for your work on this great project. I was wondering if there was a way to use klayout code base as a shared library (preferably a python module even) to run the drc engine functionality(preferably from python) natively. I am not aware of a way to do that. Is there a documented way to do that ? Or is that not supported currently?
If my question is not very clear. I mean I would like to do something like this
in c/c++ : #include <libklayout>
in python: import klayout
and then I will be able to mayb do something like this:
gds_input = klayout.drc_engine.read_gds('path/to/file')
gds_input.polygons()
.......
And perform boolean operations on the layers the same way I would be able to if I had written a script and passed it to klayout
via the -r
option (for drc verification for instance)
Comments
@nofal There is a klayout module on PyPI already.
It does not provide the DRC engine as this is a Ruby wrapper around the Region, Edges, EdgePairs and Texts classes. I can't wrap Ruby into a Python module and the DRC engine has more integration into the application framework that is good for a Python module.
But everything you can do with DRC you can also do with the klayout module. It's just somewhat more low level.
Matthias
Thank you @Matthias for the quick response. I am not sure where to look for documentation on how to use the klayout pypi module. Can you point me in the right direction or mayb include a code snippet that reads a layout; loads a couple of layers and performs an AND operation ?
@nofal Here is some sample code
Matthias
Hello @Matthias thank you for your response. I tried to
import klayout
but could not findpya
anywhere.How can I read a gds file. I am sorry to be asking so many questions. I am not sure where to look for documentation on this specific topic.
Thank you.
@nofal You can start reading a file this way:
There is some documentation you should read for an introduction: https://www.klayout.de/doc-qt5/programming/index.html and the subchapters.
Matthias
I am afraid you are not using the pypi module here. I need to use the pypi module without invoking the klayout binary and passing it the python script. I am not sure how to get
pya
Is it possible to use the klayout pypi module (the one installable via pip :
pip install klayout
) to do what can be done in a python script that is PASSED to klayout EXECUTABLE ?essentially I would like to have a file called
somedrc.py
and then call it this way
python somedrc.py
and in
somedrc.py
:I DO NOT want to call it this way
klayout -b -r somedrc.py
The Python module does not provide "pya", but "klayout.db" for most classes. Some special classes may be found in "klayout.lib" or "klayout.tl".
Usually you can do:
I skipped that part because I was assuming you're familiar with the Python module concept. Please read "pya" as "the appropriate module the way you have imported it".
But frankly, saying "I do not want to ..." is not the smoothest way to solve problems. There are easy paths and thorny ones. You are choosing the second type and you need to be prepared for a some more learning cycles. When I say, that klayout.db is capable of emulating the DRC features I'm not saying "easily". If you want to learn about the details, you can study the sources of the DRC layer which are found here: https://github.com/KLayout/klayout/tree/master/src/drc/drc/built-in-macros
Matthias
Sorry if I sounded demanding, English is not my first language. I am very thankful for your effort and response. @Matthias
Mine either
I did not want to imply you sound demanding. I just wanted to give an advice: try adapting to the tools you have instead of focussing on a specific path which may be difficult to take. Engineering is mostly making the best from the material available. Software is a little easier to take - it can be modified, specifically if it is open source. Still that is an effort and not always someone wants to pay for that.
Matthias