Python » ROOM » Block
Block
Topology container: geometry, child placements, and (in C++) nets.
In Python there is no separate Block type — the same data is accessed on
CellContent
(C++: room::Block via content.block()).
More…
| Import: | import room |
|---|---|
| Access: | via layout = cell.layout() — block API is on layout |
| C++: | room::Block (content.block()) |
Public API (on CellContent)
shapes() | Geometric shapes (see Shape). |
instances() | Child cell placements as list[Instance]. |
bbox() | Cached axis-aligned Box. |
add_rect(...) | Append a rectangle. |
add_instance(...) | Append a placement. |
nets() / recomputeBBox() | not yet exposed |
Detailed Description
A C++ room::Block holds shapes, Instance placements, and schematic
Net connectivity for one cell view. On disk, blocks live inside
CellContent.payload (for example payload.layout.block).
In C++ you write content.block().shapes(). In Python the same operations are methods
of CellContent:
C++ (content.block()) | Python (content) |
|---|---|
shapes() | shapes() |
instances() | instances() |
bbox() | bbox() |
nets() | not yet exposed |
recomputeBBox() | not yet exposed (bbox refreshed on save/load) |
Member documentation
shapes() → list[Rect | dict]
Geometric shapes in this block (C++ Block::shapes()).
Rectangles are returned as room.Rect;
other kinds currently as {"type": "...", "index": i}.
instances() → list[Instance]
Child cell placements (C++ Block::instances(), GDS SREF equivalents).
Each Instance has cell_name, x, y, orient, mag.
bbox() → Box
Cached axis-aligned bounding box (C++ Block::bbox()), in DBU.
Instance placements are not included in the bbox calculation.
add_rect(layer_id, llx, lly, urx, ury) → int
Appends a rectangle. layer_id indexes into db.layers().
add_instance(cell_name, x=0, y=0, orient=Orient.R0, mag=1.0) → int
Appends a child placement by master cell name.
Example
layout = cell.ensure_content("layout")
layout.add_rect(0, 0, 0, 500, 300)
layout.add_instance("INV", x=2000, y=2000)
print(len(layout.shapes()), len(layout.instances()), layout.bbox())