Support Forum

Problem in running python script(Layout Editor)

Shruthi

Monday 28th May 2018
Hi everyone, I am new to layout editor and trying to run the python script which is in the example folder of layout editor. But could not find the way to run the python script and I am bit confused with the execute macro. Will the execute macro support python script? If I want to run the python script in the layout editor how to do so? Suggestions are appreciated. Thanking you, Shruthi LS
Jürgen
LayoutEditorFull
Monday 28th May 2018
Attachments:
(only for registered users)

Python-LayoutEditor.png

Hi Shruthi, within the TextEditor the feature *Utilities/LayoutEditor/Execute Macro* will execute a C++ style macro only. To run a Python script please press the *Exec* button in the tool bar. With that button the kind of the script will be checked and executed accordingly. Supported are C++-Macros, Python, Ruby and TCL. In case a design file is opened in the TextEditor, the design will be opened in the LayoutEditor window. ![Python-LayoutEditor.png](/api/img.php?thread=20180528-5059&file=Python-LayoutEditor.png)
Shruthi

Monday 28th May 2018
Attachments:
(only for registered users)

Screenshot from 2018-05-28 17-22-50.png

Hi, Thank you for your fast response. I have tried the above thing which you have mentioned but nothing is reflecting in the layout editor window(Hope testLayoutScript.py as got something to display in the LE window) Could you please let me know how to run the python script. And the same is taken as screenshot and attached for the reference below. Thanking you, Shruthi LS
Jürgen
LayoutEditorFull
Monday 28th May 2018
Python will always run in a separate instance, even if called form the main LayoutEditor application. So you always need to store the results to disk within Python and need to load it into the LayoutEditor to see the results graphical. As a result you will be able to run LayoutScript for Python independent of the main LayoutEditor application and can use it for automation tasks. This is in contrast to C++-Macro where you can access the current open design and do any operation on it.
Shruthi

Tuesday 29th May 2018
Thank you it's working. Is there any other way to change the Instance of the pcell properties other than going into the python script and editing all the time. It looks bit tedious, if want to change the properties of the pcell by calling it's Instance how easy to do so?Thanks again..
Jürgen
LayoutEditorFull
Tuesday 29th May 2018
I guess you don't have a real parametric cell, but a simple script. Examples for parametric cells you will find in the *shape library* of the LayoutEditor. These C++-macros will read the parameter from the user interface and create the cell accordingly.
Shruthi

Tuesday 29th May 2018
I try loading the pcell nmos in the open cell library and it got loaded but still couldn't change the parameters of the pcell.
Jürgen
LayoutEditorFull
Tuesday 29th May 2018
You need to open it in the SchematicEditor form the *Components* sub-window. Once the cell is placed in the schematic you can edit the parameter with the edit feature. The layout is adjusted immediately.
Shruthi

Thursday 31st May 2018
Can the nmos.layout script which is in the C language can be converted to the python script?? If so, can the python script reflect in the Layout Editor Window, without converting to the.gds format at the end?Because I come across the .gds format at the end of all the python script which is dispalying in the Layout Editor Window.
Jürgen
LayoutEditorFull
Thursday 31st May 2018
The programming interfaces for C++Macros and python are very similar, so any C++Macro can be transfered to Python or Ruby and visa versa. To pass parameter from a component in the SchematicEditor to a Python script and to import the result of a Python script back to the LayoutEditor you would need a simple wrapper C++Macro.
Shruthi

Thursday 31st May 2018
Could you please give me an example of wrapper C++Macro which integrates python and C language...for example: how to Implement In the nmos.layout script. Thank you.
Jürgen
LayoutEditorFull
Thursday 31st May 2018
```cpp #!/usr/bin/layout #name=wrapper macro #help=wrapper macro int main(){ stringList parameter; parameter.append(iPar("w")); parameter.append(iPar("l")); string resultFile=process::startPythonScript("/path/to/myscript.py",parameter); layout->drawing->importFile(resultFile); layout->drawing->setCell("newcell"); } ```