FLayout cell functionality

reference[source]

reference(***args**)

create a cell reference

Note:
    this is not a native KLayout datastructure,
    but rather a convenience wrapper to ease the cell constructor API.

Args:
    cell: the cell to create a reference for
    trans: the transformation to apply to the cell upon adding

Returns:
    the cell reference
from numpy import linspace, pi, stack, cos, sin
triangle = fl.cell(
    name='triangle',
    shapes={(19, 0): [fl.polygon([(6, 0), (10, -2), (10, 1)])]}
)

@fl.pcell
def circle(
    name="circle",
    radius: float = 0.1,
    layer: pya.LayerInfo = pya.LayerInfo(1, 0),
    num_points=64,
):
    t = linspace(0, 2 * pi, num_points, endpoint=False)
    xy = stack([radius * cos(t), radius * sin(t)], -1)
    cell = fl.cell(
        name,
        shapes={layer: [xy]},
    )
    return cell

lib = fl.library(
    "lib",
    pcells=[circle],
    cells=[triangle],
    description="my library",
)
ref = reference(triangle)
print(f"{type(ref).__name__}(cell={ref.cell.name}, trans={ref.trans})")
Reference(cell=triangle, trans=r0 *1 0,0)
ref = reference(triangle, fl.transform(mag=2.0, rot=90.0, x=3, y=3))
print(f"{type(ref).__name__}(cell={ref.cell.name}, trans={ref.trans})")
Reference(cell=triangle, trans=r90 *2 3000,3000)
ref = reference(lib, triangle, fl.transform(mag=2.0, rot=90.0, x=3, y=3))
print(f"{type(ref).__name__}(lib={ref.lib.name()}, cell={ref.cell.name}, trans={ref.trans})")
LibReference(lib=lib, cell=triangle, trans=r90 *2 3000,3000)
ref = reference(lib, triangle, fl.transform(mag=2.0, rot=90.0, x=3, y=3))
print(f"{type(ref).__name__}(lib={ref.lib.name()}, cell={ref.cell.name}, trans={ref.trans})")
LibReference(lib=lib, cell=triangle, trans=r90 *2 3000,3000)
ref = reference(circle, fl.transform(mag=2.0, rot=90.0, x=3, y=3))
print(f"{type(ref).__name__}(cell={ref.cell.name}, trans={ref.trans})")
PCellReference(cell=circle, trans=r90 *2 3000,3000)
ref = reference(lib, circle, fl.transform(mag=2.0, rot=90.0, x=3, y=3))
print(f"{type(ref).__name__}(lib={ref.lib.name()}, cell={ref.cell.name}, trans={ref.trans})")
PCellLibReference(lib=lib, cell=circle, trans=r90 *2 3000,3000)

copy_tree[source]

copy_tree(source:Cell, dest:Cell, on_same_name:str='skip')

my_cell = fl.cell(
    name='my_cell',
    shapes={(19, 0): [fl.polygon([(0, 0), (5, 0), (5, 5), (0, 5)])]}
)
my_cell
Bokeh Application
copy_tree(triangle, my_cell)
my_cell
Bokeh Application

add_cells_to_layout[source]

add_cells_to_layout(layout:Layout, cells:List[Cell], on_same_name:str='skip', depth:int=0)

layout = fl.layout()
add_cells_to_layout(layout, cells=[my_cell, triangle, circle()])
fig =flbk.draw_layout(None, layout)
bio.show(fig)

add_pcells_to_layout[source]

add_pcells_to_layout(layout, pcells)

add_pcells_to_layout(layout, pcells=[circle])
layout
Bokeh Application