It looks like you're new here. If you want to get involved, click one of these buttons!
Once I write my structure(a lot of PCells) into a .gds file. How can I use Python code to open this .gds file in KLayout? I think this will be much eaiser for me to do visualization.
Is there a function in pya module can realise this.
Comments
That is simple:
The "1" is for "open in a new panel". You can use 0 to replace the current panel with the new layout or 2 to add the layout to the current panel.
Matthias
Thank you for your reply. But when I use this code, I got a tip message
How are you running this code?
Normally, I write them directly in PyCharm and run them to write layout into KLayout.
Today I tried your code in KLaout Macro tab. It works well, but with a small problem. I find that I need to use absolute path rather tham relative path. I mean I put my .gds file with my path file in same directory. Once I run the code like:
It raise an error like below:
What happens here? Is this a bug? I think sometimes by using relative path can make thing become easier.
Inside the application, your current directory is the one that Windows gave to the application when it started it. That may be the installation path or whatever.
Just use a full path when opening the file.
Matthias
OK, I get your idea. But you know if we use python macro in KLayout. We need to add a location. Maybe you can consider to make this location also as the default searching directory. Then we do not need to use
sys.path.add()
to add the searching directory?I will leave a solution here for opening file in Pycharm and VS code by python. Currently I use os module.