GDSII export automation and GDSII real example

The GDSII file format is commonly used to store 2-dimensional geometric data. In this topic, we will walk you through the steps, format, and best practices for exporting your component design to a GDSII file. We will also show a simple but real GDSII example in silicon photonics.

Associated files (1.7 MB)
GDS_GC_Ring.GDS (120.9 KB)
GDS_GC_Ring.lsf (383 Bytes)

See also
GDSII Export Using Finite Element Solvers
GDSII import/export script commands
Layer builder

[1] Lukas Chrostowski, Xu Wang, Jonas Flueckiger, Yichen Wu, Yun Wang, Sahba Talebi Fard, “Impact of Fabrication Non-Uniformity on Chip-Scale Silicon Photonic Integrated Circuits”, Optical Fiber Communication Conference, pp. Th2A.37, 03/2014.
[2] Yun Wang, Xu Wang, Jonas Flueckiger, Han Yun, Wei Shi, Richard Bojko, Nicolas A. F. Jaeger, and Lukas Chrostowski, “Focusing sub-wavelength grating couplers with low back reflections for rapid prototyping of silicon photonic circuits,” Opt. Express 22, 20652-20662 (2014)

GDSII export automation

We can export structures to GDSII using some scripting commands. However, the basic GDSII export script commands have limited capabilities in an automated manner to export structures from Lumerical tools. Here, in the video, we have demonstrations using some advanced scripts that can automate the GDSII export process.

Step 1:
Download the associated files, (1.7 MB) , unzip the folder and put all the files in the same directory.

Step 2:
Open the simulation file GDS_auto_export_test.fsp. We will export all of the structures, except the surface, sphere, pyramid objects. Disabled objects will be ignored during the auto export process.

Step 3:
Open and run the script file GDS_auto_export.lsf within the same instance. The scripts will create and export structures to a GDSII file, in which the top cell has the same name as the structure group and contains a list of subcells corresponding to each of the objects within the structure group. See the instructions in the first section in the GDS_auto_export.lsf file.

Step 4:
Check the generated GDSII file using your layout tools (e.g., KLayout) or Lumerical CAD tools.


  1. Unzip the folder and put all the files in the same working directory.
  2. The elements from the simulation file that belong to a layer are identified by the z min and z max coordinates. Therefore, a layer corresponds to a unique set of z min and z max.
  3. For more info, see the instructions in the first section in the GDS_auto_export.lsf file.

Real GDSII example

The circuit in the associated file, GDS_GC_Ring.GDS, includes one racetrack ring resonator [1], two grating couplers [2], and routing waveguides. Users can import the whole circuit, or the individual cells, into the simulation layout using GUI, or using script commands such as the associated GDS_GC_Ring.lsf file.

The pictures below show a focusing sub-wavelength grating coupler with low back reflections for rapid prototyping of silicon photonic circuits

and a ring resonator used to study the impact of fabrication non-uniformity on silicon photonic chips (Courtesy of the L. Chrostowski group at UBC).


  • 07/2019 - Support for grids and database units < 1nm, but >=1pm
  • 02/2020 - Rotations about z, and ability to import ellipses(circle objects with a second radius). Group rotations are not supported.

Update July 2019

The grid parameter in the GDS_auto_export.lsf defines the coordinate resolution for the GDSII file; however, the default database unit for GDSII files is 1nm. Users trying to write GDSII files with sub nano meter grid resolution found that the grid was being rounded to the database unit. We have updated the file so that when the grid is less than 1nm the database unit is set to be equal to the grid.

I receive an error while trying to run the script file GDS_auto_export.lsf, it says :

Error: Lumerical_GDS_auto_export.lsfx line 13: syntax error

What’s the problem here?

Hey @am35,

I would suggest updating your software to the most recent release. We have not tested this with previous versions.


I did this and the problem was solved, however, I have another problem converting lumerical designs to layout now. The file works and produces a GDS file, but when I try to import that GDS file to cadence as a stream (to add other parts to it), I receive an error saying that the produced GDS file has “multiple definitions” for the cell defined in lumerical. I have only one cell in lumerical, which is my single-layer device. Any ideas?

I have a structure with 6 polygons grouped in a structure group. I can export the structure to GDS file. However it seems if I want to import it then I have to do it for each polygon. Is there a way to import the structure group containing the 6 polygons?

Thank you

Hello @ahmedgabr,

If these polygons have the same z span then they will automatically be sorted into the same layer. You can provide multiple layer definitions by passing the z span of each polygon as a layer. Then you could merge these merge layers in K layout if that is the issue? Also via script you could import each GDS layer by looping over the layers.



I am trying the GDS_auto_export.lsf file to export GDS from a MODE simulation file. However, it gives me the following error:
**** Lumerical_GDS_auto_export is not a valid function or variable name ****

I am not sure why this is happening as I ran the same script last month and it was able to generate my gds.

Hey @niharikakohli,

Please ensure the Lumerical_GDS_auto_export script is in the same folder as the GDS_auto_export.lsf file that you are running.


Thank you. It is working now.

I am trying to convert my structure to GDSII file but it’s giving me the error
Error: Lumerical_GDS_auto_export.lsfx line 129: in get, no items are currently selected
Error: In function calculate_wg_vertices called from: Lumerical_GDS_auto_export.lsfx line 332
Error: In function build_cell called from: Lumerical_GDS_auto_export.lsfx line 507

Hey @uday1,

Thanks for posting can you please share your simulation file so that we can test this behavior out?


Hi Trobertson,
I somehow solve that problem. However, there is 5 nm gap between the joint of waveguides. Please help as soon as possible.