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 again

Attributes

attributecell_namestr

Name of the referenced cell.

Methods

func__init__(cell_or_name) -> None

Create a new cell reference.

Example

ref1 = CellRef("my_cell")      # From string
ref2 = CellRef(waveguide_cell) # From Cell object
paramcell_or_nameCell | str

Either a Cell object or a cell name string.

Returns

None
funcat(x, y) -> CellRef

Set the position.

paramxfloat

X coordinate.

paramyfloat

Y coordinate.

Returns

CellRef
funcrotate(angle_deg) -> CellRef

Rotate by angle (in degrees).

paramangle_degfloat

Rotation angle in degrees.

Returns

CellRef
funcmirror_x() -> CellRef

Mirror across X axis (flips Y coordinates).

Returns

CellRef
funcmirror_y() -> CellRef

Mirror across Y axis (flips X coordinates).

Returns

CellRef
funcscale(s) -> CellRef

Scale uniformly.

paramsfloat

Scale factor.

Returns

CellRef
funcport(name, cell) -> Port

Get a transformed port from this cell reference.

Unlike Instance.port(), this requires passing the source Cell because CellRef only stores the cell name.

paramnamestr

Name of the port to retrieve.

paramcellCell

The source Cell object containing the port definition.

Returns

Port

The port with position and direction transformed.

On this page