CellRef
A reference to another cell with transformation.
CellRef stores the name of a referenced cell along with a GDS-compatible
transform (translation, rotation, mirroring, scale). For most use cases,
prefer the higher-level Instance API via cell.at(x, y) which
preserves the cell reference for ergonomic port queries.
# Preferred: use Instance via cell.at()
gc_in = gc_cell.at(0, 0)
port = gc_in.port("opt") # No need to pass cell again
# Low-level: CellRef requires passing the cell for port queries
ref = CellRef(gc_cell).at(0, 0)
port = ref.port("opt", gc_cell) # Must pass gc_cell againAttributes
attributecell_namestrName of the referenced cell.
Methods
func__init__(cell_or_name) -> NoneCreate a new cell reference.
Example
ref1 = CellRef("my_cell") # From string
ref2 = CellRef(waveguide_cell) # From Cell objectparamcell_or_nameCell | strEither a Cell object or a cell name string.
Returns
Nonefuncat(x, y) -> CellRefSet the position.
paramxfloatX coordinate.
paramyfloatY coordinate.
Returns
CellReffuncrotate(angle_deg) -> CellRefRotate by angle (in degrees).
paramangle_degfloatRotation angle in degrees.
Returns
CellReffuncmirror_x() -> CellRefMirror across X axis (flips Y coordinates).
Returns
CellReffuncmirror_y() -> CellRefMirror across Y axis (flips X coordinates).
Returns
CellReffuncscale(s) -> CellRefScale uniformly.
paramsfloatScale factor.
Returns
CellReffuncport(name, cell) -> PortGet a transformed port from this cell reference.
Unlike Instance.port(), this requires passing the source Cell
because CellRef only stores the cell name.
paramnamestrName of the port to retrieve.
paramcellCellThe source Cell object containing the port definition.
Returns
PortThe port with position and direction transformed.