Python » ROOM » Shape
Shape
Geometry inside a block. C++ uses a tagged union room::Shape;
Python currently surfaces rectangles as room.Rect
and other kinds as lightweight dicts.
More…
| Import: | import room — room.Rect, room.ShapeType |
|---|---|
| Access: | content.shapes() / content.add_rect(...) |
| C++: | room::Shape |
Public API
content.shapes() | list[Rect | dict] |
content.add_rect(layer_id, llx, lly, urx, ury) | Append rectangle; returns index. |
room.Rect | Decoded rectangle payload. |
room.ShapeType | RECT, POLYGON, PATH, TEXT, ARC. |
| polygon / path / text / arc accessors | partial — returned as {"type", "index"} |
Detailed Description
In C++, Shape is a variant (rect, polygon, path, text, arc) with type() and
typed accessors. Each variant carries a layerId index into the library layer table
(not a raw GDS layer number).
The Python binding fully decodes rectangles. Other kinds are listed so you can see
the count and type; full polygon/path/text/arc decoding will follow the same pattern as Rect.
Member documentation
content.shapes() → list[Rect | dict]
Returns all shapes in the view block (C++ block().shapes()).
Each rectangle is a room.Rect; other entries look like
{"type": "polygon", "index": 3}.
content.add_rect(layer_id, llx, lly, urx, ury) → int
Appends a rectangle (C++ Shape::RectData). Coordinates are in DBU.
| Parameter | Description |
|---|---|
layer_id | Index into db.layers(). |
llx, lly, urx, ury | Lower-left / upper-right corners. |
room.Rect
Frozen dataclass for a decoded rectangle.
| Field | Type | Description |
|---|---|---|
layer_id | int | Index into db.layers(). |
llx, lly, urx, ury | int | Box corners in DBU. |
room.ShapeType
Discriminator enum mirroring C++ Shape::Type: RECT, POLYGON, PATH, TEXT, ARC.
Example
for s in layout.shapes():
if isinstance(s, room.Rect):
print(s.layer_id, s.llx, s.lly, s.urx, s.ury)
else:
print(s["type"], s["index"])