def assemble_subdies( mask_name, dict_subdies, subdies_directory, mask_directory=None, um_to_grid=UM_TO_GRID, ): """ Args: dict_subdies: {subdie_name: (x, y, rotation) in (um, um, deg)} subdies_directory: directory where the subdies should be looked for """ top_level_layout = pya.Layout() top_level = top_level_layout.create_cell(mask_name) if mask_directory is None: mask_directory = subdies_directory for subdie_name, (x_um, y_um, R) in dict_subdies.items(): gdspath = os.path.join(subdies_directory, subdie_name + ".gds") subdie = load_gds(gdspath).top_cell() _subdie = import_cell(top_level_layout, subdie) t = pya.Trans(R / 2, 0, int(x_um * um_to_grid), int(y_um * um_to_grid)) # t = pya.Trans(0, 0) subdie_instance = pya.CellInstArray(_subdie.cell_index(), t) top_level.insert(subdie_instance) top_level.write(os.path.join(mask_directory, mask_name + ".gds")) return top_level
def load_doe(doe_name, doe_root): """ Load all components for this DOE from the cache """ doe_dir = os.path.join(doe_root, doe_name) content_file = os.path.join(doe_dir, "content.txt") if os.path.isfile(content_file): with open(content_file) as f: lines = f.read().split("\n") line = lines[0] if line.startswith("TEMPLATE:"): """ If using a template, load the GDS from DOE folder used as a template """ template_name = line.split(":")[1].strip() return load_doe(template_name, doe_root) else: """ Otherwise load the GDS from the current folder """ component_names = line.split(" , ") gdspaths = [ os.path.join(doe_dir, name + ".gds") for name in component_names ] cells = [load_gds(gdspath) for gdspath in gdspaths] # print("LOAD DOE") # for _c in cells: # print(_c.top_cell().name) # print() return cells
def _demo(): import pp c = pp.c.waveguide() gdspath = pp.write_component(c) layout1 = load_gds(gdspath) cell1 = layout1.top_cell() cell1_instance1 = pya.CellInstArray(cell1.cell_index(), pya.Trans(10, 0)) layout2 = pya.Layout() cell2 = layout2.create_cell("TOP_LEVEL") layout2.cell("TOP_LEVEL").insert(cell1_instance1) layout2.write("test.gds")
def load_alphabet(filepath=FONT_PATH): c = load_gds(filepath) return {_c.name: _c for _c in c.each_cell()}