Home Forums Nazca Identify Cells already created Reply To: Identify Cells already created

#5922
Ronald
Keymaster

Dear Daneel,

The first cell you create after evoking the @hashme will get the name created by hashme.

You can simply nest your ‘text’ cell inside the ‘rectangle’ cell to get what you need:

import nazca as nd
import nazca.geometries as geom

@nd.bb_util.hashme('rectangle', 'length', 'width')
def rectangles(length=80, width=80):
    with nd.Cell() as rectangle:
        with nd.Cell() as text:
            nd.text('text', height=30, layer='Label', align='cc').put(0)
        rect=geom.box(length=length, width=width)
        nd.Polygon(points=rect).put(0, 0)
        text.put(100, 0)
    return rectangle

rectangles().put(0)
rectangles().put(0)

nd.export_gds()

If all you ultimately want to do here is to get access the cell name to print it you have other options too. You can use the Cell attribute cell_name and get rid of the second explicit cell altogether:

@nd.bb_util.hashme('rectangle', 'length', 'width')
def rectangles(length=80, width=80):
    with nd.Cell() as rectangle:
        text = nd.text(text=rectangle.cell_name[:-6], height=30,
            layer='Label', align='cc')
        rect=geom.box(length=length, width=width)
        nd.Polygon(points=rect).put(0, 0)
        text.put(100, 0)
    return rectangle

A last alternative is to use a bounding box:

@nd.bb_util.hashme('rectangle', 'length', 'width')
def rectangles(length=80, width=80):
    with nd.Cell() as rectangle:
        rectangle.autobbox = True        
        rect=geom.box(length=length, width=width)
        nd.Polygon(points=rect).put(0, 0)
    return rectangle

Ronald