How to access parameters calculated in produce_imp from display_text_impl

I used to calculate parameters, such as the total length of a chain based on the input parameters in the produce_imp, and then display the value of the parameter value in display_text_impl. With the latest Klayout version, the parameter values are still displayed in the cell. But I get an error in Macro Development saying the pcell object has no attribute of this parameter. How to access parameters created in produce_imp from display_text_imp ? I don't want to repeat the calculation in the display_text_impl.


  • edited July 2021


    The idea is to do the computation in "coerce_parameters_impl" (actually that is a generic callback executed whenever some other parameter changes) and not in "produce_impl". "produce_impl" is called to generate layout and not to compute parameters.

    In "display_text_impl" you can access the parameter by a member with the parameter's name.

    So for example, if you define a readonly parameter called "tot_length" which you want to compute from "l" and "n", use a "coerce_parameters_impl" function like this:

        def coerce_parameters_impl
          set_tot_length = n * l

    and a "display_text_impl" like this:

        def display_text_impl
          "PCell (tot_length=%.12g)" % tot_length


Sign In or Register to comment.