Home Forums Nazca Hashme with multiple cells


This topic contains 2 replies, has 3 voices, and was last updated by  Xaveer 1 month, 2 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #5990



    I am trying to generate a layout containing several cells and I wish to avoid to regenerate the same cells over and over. I understand how this can be done with a single cell using the hashme decorator, but I have some doubts on how to set up my script, which contains nested cells and functions defining parametrized cells.

    I do not understand:

    – Where is the best place to place all the @hashme lines ? If I collect them all together at the beginning of the script, I receive a warning.
    – What is the effect of the ‘hashme = True’ parameter ? The cell seems to be hashed anyway.
    – Why do some of the hashed cells contain an additional name identifier ‘_$####’ and others do not?
    – Why some of the cells end up with a text field listing their parameters, and others not?
    – Is there an alternative way to tell Nazca to always check for already generated cells (based e.g. on the cell name), rather than having to manage this decorator for each cell?


    Below an example code, where the ‘mmi1x2’  cells gets the additional name identifier, but no parameter string printed, differently from the ‘cm’ cells.

    def mmi1x2():
    with nd.Cell(‘MMI_1x2’, hashme = True) as mmi1x2:
    return mmi1x2

    def cm():
    with nd.Cell(name=’cm’, autobbox = True, hashme = True) as cm:
    return cm
    Thank you.



    Dear ale35,

    The tutorial on hashme may be of help.

    All cells generated by hashed function calls have the _$#### hash suffix as unique identifier.
    In newer Nazca versions (0.5.7 and up) the hashme=True has become optional in de Cell() call.

    The hashme decorator does not only check for the cell name, but for the full call profile and it generates a unique cell name based on that (with the hash). You can also manage cell names yourself and simply send or generate a unique cell name every time you call your cell generating function. Hashme does all the work for you in one line with a few characters in case of parametrized cells.




    Dear ale35,

    Because your cell does not seem to take any parameters, the hashme (and even the function definition) are not needed. Just define the cell (in a with statement) and use it:

    import nazca as nd
    with nd.Cell("MMI_1x2") as mmi1x2:
        nd.strt(length=10, width=5).put()
    for i in range(100):
        mmi1x2.put(i * 10, i * 10)


Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.