Support Forum

Execution of python script


Sunday 19th March 2023
Hello, I have access to full version of Layout Editor. I have been using python scripts (VS Editor) with Layout Editor for some time now. Is there any way, we can transfer data, mostly integer lists, from python script to Layout Editor (C++) script, given that the script starts with Layout editor (C++) script. The reason behind starting with Layout editor script is that it sets the pointer to current cell based on current GDS file, which is useful for Toolbar macro. So far, I have tried using [process::start python script, parameter(stringList)], it works but I couldn’t figure out a way to access the stringList in Python script. Also, I would like to use intList instead of stringList. Any help would be much appreciated.
Sunday 19th March 2023
Hi, you have already mention the correct call to start a Python script from a C++ macro script. The parameter-stringlist are the command line parameter used when calling Python. You can read it with the *sys* module from Python: ``` import sys if __name__ == "__main__": print(f"Arguments count: {len(sys.argv)}") for i, arg in enumerate(sys.argv): print(f"Argument {i:>6}: {arg}") ``` To transfer integer values you can ether convert them to string, and convert it back to integer inside Python or you can write the values to a temporary file and pass just the file name to the Python script. I would recommend the first way for a small amount of integers (for example maximal 100 value) and the file for a bigger amount of values.