I am trying to create grating structure in the script file, so I can use stackrt to get reflection coefficients.
also is it possible to generate code for a simulation layout?
You can use python script to create any structure that you want. In Lumerical’s knowledge base there is a link:
https://kb.lumerical.com/en/index.html?ref_sim_obj_complex_structures.html about complex structures and how to create them. Using script it is possible to build the simulation structure, but i suppose that it is very difficult.